我有 3 个 python 脚本(a.py、b.py、c.py),需要在 ML studio Pipelines 中按顺序运行。 我正在尝试复制下面代码中的示例。 但是,此代码不会按顺序运行管道作业。
我确实需要在 Azure ML Pipelines 中运行该流程(而不是作为三个脚本的单个作业),并且我知道我可以为每个命令创建虚拟输入和输出,以便设置我想要的作业的层次结构运行。
但是,我确实发现有点复杂,我想问是否有人知道另一种设置层次结构的方法。
例如,如果有一种方法可以配置作业“b”b_job.run_after(a_job),但我找不到任何有效的方法。 设置作业的层次结构应该很容易,无需创建虚拟输入和输出。
谢谢您的帮助,
马里奥斯
import warnings
warnings.filterwarnings("ignore")
import yaml
from azure.ai.ml import command, dsl
from azure.ai.ml.entities import PipelineJobSettings
import os
import sys
# Append the directory to system path
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
# Load environment variables
if __name__ == "__main__":
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
# Load configuration from YAML file
with open(os.path.join("conda.yaml"), encoding="utf-8") as stream:
config = yaml.safe_load(stream)
# Initialize MLStudioHandler
from ml_studio_jobs.mlstudio_handling import MLStudioHandler
ml_studio_handler = MLStudioHandler()
env = ml_studio_handler.get_env_version(config['name'])
compute = ml_studio_handler.get_or_start_compute(os.environ.get("COMPUTE_NAME"))
mode = "a"
a_job = command(
code="/.", # location of source code
command="python a.py",
environment=env,
display_name=f"test_{mode}",
)
a_component = ml_studio_handler.create_or_update(a_job.component)
mode = "b"
b_job = command(
code="/.", # location of source code
command="python b.py",
environment=env,
display_name=f"test_{mode}",
)
b_component = ml_studio_handler.create_or_update(b_job.component)
mode = "c"
c_job = command(
code="/.", # location of source code
command="python c.py",
environment=env,
display_name=f"test_{mode}",
)
c_component = ml_studio_handler.create_or_update(c_job.component)
# Define the pipeline
@dsl.pipeline(
compute=compute.name,
description="E2E Churn Prediction Pipeline",
)
def process():
# Step 1: Get Data - produces dummy output
a_job = a_component()
b_job = b_component()
c_job = c_component()
# Create the pipeline
pipeline = process()
pipeline.settings = PipelineJobSettings(force_rerun=True, continue_on_step_failure=True)
# Submit the pipeline job
pipeline_job = ml_studio_handler.create_or_update_jobs(
jobs=pipeline,
experiment_name="test_experiment_ml",
)
除非组件之间存在某些依赖关系,否则您无法按顺序运行它们。
所以,这里的依赖关系是输入和输出。
您想要找到的东西在没有输入和输出的azure ml管道中是不可能的。
基本上,azure ml Designer 管道中的每个组件都由输入和输出节点组成,您需要在其中配置并用于按顺序运行它们。
mldesigner
来构建命令组件
此外,请检查如何管理组件中的输入和输出。