[英]How to split Azure ML pipeline steps to debug
我創建了一個具有不同步驟(數據預處理、訓練、驗證......)的 Azure ML 管道。 為了將數據從一個步驟傳遞到下一步,我使用了 PipelineData object。
從訓練步驟傳遞 model 以驗證一個示例:
# Create a PipelineData to pass model from train to register
model_path = PipelineData('model')
# Step 2
train_step = PythonScriptStep(
name = 'Train the Model',
script_name = 'TrainStepScript.py',
source_directory = source_folder,
arguments = ['--training_data', prepped_data,
'--model_name', model_name,
'--model_path', model_path],
outputs = [model_path],
compute_target = compute_target,
runconfig = aml_run_config,
allow_reuse = True
)
# Step 3
third_step = PythonScriptStep(
name = 'Evaluate & register the Model',
script_name = 'ValidateStepScript.py',
source_directory = source_folder,
arguments = ['--model_name', model_name,
'--model_path', model_path],
inputs = [model_path],
compute_target = compute_target,
runconfig = aml_run_config,
allow_reuse = True
)
現在出於調試和開發目的,我想創建一個腳本以使用 ScriptRunConfig 分別運行不同的步驟(具有相同的環境和管道中 StepScript 的 arguments)。 但問題是我不知道如何模擬每個步驟的數據輸入/輸出,因為 DataPipeline object 不適用於此目的。
只是為了澄清,我的目標是不修改原始管道 StepScripts,所以我可以在最終管道中調試后使用它們。 總而言之,我的問題是:在這種情況下,我如何模擬 DataPipeline object(如果可能)?
我正在嘗試構建的示例:
# Passing in some way the model path (from local)
model_path = PipelineData('model')
# Create a script config for validate step
validate_script_config = ScriptRunConfig(
source_directory = source_folder,
script = 'ValidateStepScript.py',
arguments = ['--model_name', model_name,
'--model_path', model_path],
environment = experiment_env,
docker_runtime_config = DockerConfiguration(use_docker=True)
)
experiment = Experiment(workspace=ws, name=experiment_name)
data_run = experiment.submit(config=data_script_config)
我們可以在存儲庫中下載 model 的 output 並根據需要將它們作為源文件進行后續步驟。 下面的代碼塊可以合並到現在正在使用的同一管道中。
要下載 model output:
train_step = pipeline_run1.find_step_run('train.py')
if train_step:
train_step_obj = train_step[0]
train_step_obj.get_output_data('processed_data1').download("./outputs") # download the output to current directory
下載 model 后,將其用作 source_directory 中的父源目錄
from azureml.core import ScriptRunConfig, Experiment
# create or load an experiment
experiment = Experiment(workspace, 'MyExperiment')
# create or retrieve a compute target
cluster = workspace.compute_targets['MyCluster']
# create or retrieve an environment
env = Environment.get(ws, name='MyEnvironment')
# configure and submit your training run
config = ScriptRunConfig(source_directory='.',
command=['python', 'train.py'],
compute_target=cluster,
environment=env)
script_run = experiment.submit(config)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.