若要启动运行，请使用以下命令。To start the run, use the following command.使用此命令时，请为 -c 参数指定 runconfig 文件的名称（如果查看的是文件系统，此名称为 *.runconfig 前面的文本）。When using this command, specify the name of the runconfig file (the text before *.runconfig if you are looking at your file system) against the -c parameter.

如果你的某个 Python 脚本以编程方式创建运行配置对象，则你可以使用 RunConfig.save() 将此对象另存为 runconfig 文件。If you have a Python script that creates a run configuration object programmatically, you can use RunConfig.save() to save it as a runconfig file.

监视运行的状态Monitor the status of a run

使用 SDKUsing the SDK

若要获取运行 ID、执行时间和有关运行的更多详细信息，请使用 get_details() 方法。To get the run ID, execution time, and additional details about the run, use the get_details() method.

print(notebook_run.get_details())

成功完成运行后，使用 complete() 方法将其标记为已完成。When your run finishes successfully, use the complete() method to mark it as completed.

notebook_run.complete()
print(notebook_run.get_status())

如果使用 Python 的 with...as 设计模式，则当运行超出范围时，该运行会自动将自身标记为已完成。If you use Python's with...as design pattern, the run will automatically mark itself as completed when the run is out of scope.无需手动将它标记为已完成。You don't need to manually mark the run as completed.

with exp.start_logging() as notebook_run:
notebook_run.log(name="message", value="Hello from run!")
print(notebook_run.get_status())
print(notebook_run.get_status())

使用 CLIUsing the CLI

若要查看试验的运行列表，请使用以下命令。To view a list of runs for your experiment, use the following command.请将 experiment 替换为你的试验名称。Replace experiment with the name of your experiment:

az ml run list --experiment-name experiment

此命令返回一个 JSON 文档，其中列出了有关此试验的运行的信息。This command returns a JSON document that lists information about runs for this experiment.

如果运行已完成但包含错误（例如，使用了错误的训练脚本），可以使用 fail() 方法将其标记为失败。If your run finishes, but it contains an error (for example, the incorrect training script was used), you can use the fail() method to mark it as failed.

使用 Azure 机器学习工作室Using Azure Machine Learning studio

若要在工作室中取消某个运行，请执行以下步骤：To cancel a run in the studio, using the following steps:

转到“试验” 或“管道” 部分中正在运行的管道。Go to the running pipeline in either the Experiments or Pipelines section.

选择要取消的管道运行编号。Select the pipeline run number you want to cancel.

在工具栏中，选择“取消” In the toolbar, select Cancel

创建子运行Create child runs

创建子运行可将相关的运行组合到一起，例如，以完成不同的超参数优化迭代。Create child runs to group together related runs, such as for different hyperparameter-tuning iterations.

Note

只能使用 SDK 创建子运行。Child runs can only be created using the SDK.

此代码示例使用 hello_with_children.py 脚本，通过 child_run() 方法从已提交的运行内部创建包含五个子运行的批：This code example uses the hello_with_children.py script to create a batch of five child runs from within a submitted run by using the child_run() method:

当子运行超出范围时，会自动标记为已完成。As they move out of scope, child runs are automatically marked as completed.

若要高效地创建许多子运行，请使用 create_children() 方法。To create many child runs efficiently, use the create_children() method.由于每次创建操作都会造成网络调用，因此，创建一批运行比逐个创建更为高效。Because each creation results in a network call, creating a batch of runs is more efficient than creating them one by one.

提交子运行Submit child runs

也可以从父运行提交子运行。Child runs can also be submitted from a parent run.这样，便可以创建父子运行的层次结构，每个层次结构在按通用父运行 ID 连接的不同计算目标上运行。This allows you to create hierarchies of parent and child runs, each running on different compute targets, connected by common parent run ID.

使用 'submit_child()' 方法从父运行内部提交子运行。Use the 'submit_child()' method to submit a child run from within a parent run.若要在父运行脚本中执行此操作，请获取运行上下文，并使用上下文实例的 submit_child 方法提交子运行。To do this in the parent run script, get the run context and submit the child run using the submit_child method of the context instance.

查询子运行Query child runs

若要查询特定父级的子运行，请使用 get_children() 方法。To query the child runs of a specific parent, use the get_children() method.使用 recursive = True 参数可以查询子级和孙级的嵌套树。The recursive = True argument allows you to query a nested tree of children and grandchildren.

print(parent_run.get_children())

标记和查找运行Tag and find runs

在 Azure 机器学习中，可以使用属性与标记来帮助组织运行，以及查询运行以获取重要信息。In Azure Machine Learning, you can use properties and tags to help organize and query your runs for important information.

添加属性和标记Add properties and tags

使用 SDKUsing the SDK

若要将可搜索的元数据添加到运行，请使用 add_properties() 方法。To add searchable metadata to your runs, use the add_properties() method.例如，以下代码将 "author" 属性添加到运行：For example, the following code adds the "author" property to the run:

属性是不可变的，因此它们将创建一条永久记录用于审核目的。Properties are immutable, so they create a permanent record for auditing purposes.以下代码示例会导致出错，因为我们已在前面的代码中添加了 "azureml-user" 作为 "author" 属性值：The following code example results in an error, because we already added "azureml-user" as the "author" property value in the preceding code:

使用 SDKUsing the SDK

使用 CLIUsing the CLI

Azure CLI 支持 JMESPath 查询，可以使用这些查询基于属性和标记来筛选运行。The Azure CLI supports JMESPath queries, which can be used to filter runs based on properties and tags.若要在 Azure CLI 中使用 JMESPath 查询，请使用 --query 参数指定该查询。To use a JMESPath query with the Azure CLI, specify it with the --query parameter.以下示例演示了使用属性和标记的基本查询：The following examples show basic queries using properties and tags: