背景
我已经从conda environment.yml
以及一些docker配置和环境变量创建了ML Workspace环境。我可以在Python笔记本中访问它:
env = Environment.get(workspace=ws, name='my-environment', version='1')
我可以成功地使用它来运行Python脚本作为实验,即
runconfig = ScriptRunConfig(source_directory='script/', script='my-script.py', arguments=script_params)
runconfig.run_config.target = compute_target
runconfig.run_config.environment = env
run = exp.submit(runconfig)
问题
我现在想与管道运行相同的脚本,以便可以使用不同的参数触发多次运行。我创建了管道,如下所示:
pipeline_step = PythonScriptStep(
source_directory='script', script_name='my-script.py',
arguments=['-a', param1, '-b', param2],
compute_target=compute_target,
runconfig=runconfig
)
steps = [pipeline_step]
pipeline = Pipeline(workspace=ws, steps=steps)
pipeline.validate()
然后尝试运行管道时:
pipeline_run = Experiment(ws, 'my_pipeline_run').submit(
pipeline, pipeline_parameters={...}
)
我收到以下错误:Response status code does not indicate success: 400 (Conda dependencies were not specified. Please make sure that all conda dependencies were specified i).
[当我查看在Azure门户中运行的管道时,似乎尚未拾取环境:没有配置我的conda依赖项,因此代码无法运行。我在做什么错?
您快到了,但是您需要使用RunConfiguration
而不是ScriptRunConfig
。更多信息here
from azureml.core.runconfig import RunConfiguration
env = Environment.get(workspace=ws, name='my-environment', version='1')
# create a new runconfig object
runconfig = RunConfiguration()
runconfig.environment = env
pipeline_step = PythonScriptStep(
source_directory='script', script_name='my-script.py',
arguments=['-a', param1, '-b', param2],
compute_target=compute_target,
runconfig=runconfig
)
pipeline = Pipeline(workspace=ws, steps=[pipeline_step])
pipeline_run = Experiment(ws, 'my_pipeline_run').submit(pipeline)