[英]How do I use an environment in an ML Azure Pipeline
背景
我已經從 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
。 更多信息在這里
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.