Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
tensorflow
GitHub Repository: tensorflow/docs-l10n
Path: blob/master/site/zh-cn/tfx/guide/cli.md
25118 views

使用 TFX 命令行接口

TFX 命令行接口 (CLI) 使用流水线编排器(例如 Kubeflow Pipelines、Vertex Pipelines)执行各种流水线操作。本地编排器还可以用于加快开发或调试速度。支持 Apache Beam 和 Apache Airflow 作为实验性功能。例如,您可以使用 CLI 执行以下操作:

  • 创建、更新和删除流水线。

  • 运行流水线并监视在各种编排器上的运行。

  • 列出流水线和流水线运行。

注:TFX CLI 目前不提供兼容性保证。随着新版本的发布,CLI 接口可能会更改。

关于 TFX CLI

TFX CLI 作为 TFX 软件包的一部分进行安装。所有 CLI 命令都遵循以下结构:


tfx <var>command-group</var> <var>command</var> <var>flags</var>

目前支持以下 command-group 选项:

  • tfx pipeline - 创建并管理 TFX 流水线。

  • tfx run - 在各种编排平台上创建和管理 TFX 流水线的运行。

  • tfx template - 用于列出和复制 TFX 流水线模板的实验性命令。

每个命令组都提供一组 commands。请遵循流水线命令运行命令模板命令部分中的说明,详细了解这些命令的用法。

警告:目前并非每个编排器都支持所有命令。这些命令明确提到了支持的引擎。

您可以通过标记将参数传递到 CLI 命令中。标记中的单词用连字符 (-) 或下划线 (_) 分隔。例如,流水线名称标记可以指定为 --pipeline-name--pipeline_name。为了简洁起见,本文档将使用下划线指定标记。详细了解在 TFX CLI 中使用的 flags

tfx pipeline

tfx pipeline 命令组中的命令结构如下:

tfx pipeline <var>command</var> <var>required-flags</var> [<var>optional-flags</var>]

使用以下各个部分详细了解 tfx pipeline 命令组中的命令。

create

在给定的编排器中创建新的流水线。

用法:

tfx pipeline create --pipeline_path=<var>pipeline-path</var> [--endpoint=<var>endpoint</var> --engine=<var>engine</var> \
--iap_client_id=<var>iap-client-id</var> --namespace=<var>namespace</var> \
--build_image --build_base_image=<var>build-base-image</var>]
--pipeline_path=pipeline-path
流水线配置文件的路径。
--endpoint=endpoint

(可选)Kubeflow Pipelines API 服务的端点。Kubeflow Pipelines API 服务的端点与 Kubeflow Pipelines 信息中心的网址相同。您的端点值应类似于:

<pre>https://<var>host-name</var>/pipeline</pre> <p> If you do not know the endpoint for your Kubeflow Pipelines cluster, contact you cluster administrator. </p> <p> If the <code>--endpoint</code> is not specified, the in-cluster service DNS name is used as the default value. This name works only if the CLI command executes in a pod on the Kubeflow Pipelines cluster, such as a <a href="https://www.kubeflow.org/docs/components/notebooks/jupyter-tensorflow-examples/" class="external">Kubeflow Jupyter notebooks</a> instance. </p>
--engine=engine

(可选)用于流水线的编排器。引擎的值必须与以下值匹配:

  • kubeflow:将引擎设置为 Kubeflow
  • local:将引擎设置为本地编排器
  • vertex:将引擎设置为 Vertex Pipelines
  • airflow:(实验性)将引擎设置为 Apache Airflow
  • beam :(实验性)将引擎设置为 Apache Beam

如果未设置引擎,则会根据环境自动检测引擎。

** 重要说明:DagRunner 在流水线配置文件中所需的编排器必须与所选或自动检测到的引擎匹配。引擎自动检测基于用户环境。如果未安装 Apache Airflow 和 Kubeflow Pipelines,则默认使用本地编排器。

--iap_client_id=iap-client-id
(可选)使用 Kubeflow Pipelines 时受 IAP 保护的端点的客户端 ID。
--namespace=namespace
(可选)要连接到 Kubeflow Pipelines API 的 Kubernetes 命名空间。如果未指定命名空间,则值将默认为 kubeflow
--build_image

(可选)当 enginekubeflowvertex 时,TFX 会为您的流水线创建容器镜像(如果已指定)。将使用当前目录下的 `Dockerfile`,如果不存在,则 TFX 会自动生成。

构建的镜像将被推送到在 `KubeflowDagRunnerConfig` 或 `KubeflowV2DagRunnerConfig` 中指定的远程注册表。

--build_base_image=build-base-image

(可选)当 enginekubeflow 时,TFX 会为您的流水线创建容器镜像。build-base-image 指定要在构建流水线容器镜像时使用的基础容器镜像。

示例:

Kubeflow:

tfx pipeline create --engine=kubeflow --pipeline_path=<var>pipeline-path</var> \
--iap_client_id=<var>iap-client-id</var> --namespace=<var>namespace</var> --endpoint=<var>endpoint</var> \
--build_image

本地:

tfx pipeline create --engine=local --pipeline_path=<var>pipeline-path</var>

Vertex:

tfx pipeline create --engine=vertex --pipeline_path=<var>pipeline-path</var> \
--build_image

要从用户环境自动检测引擎,只需避免使用引擎标记(如下面的示例所示)。有关更多详细信息,请查看标记部分。

tfx pipeline create --pipeline_path=<var>pipeline-path</var>

update

更新给定编排器中的现有流水线。

用法:

tfx pipeline update --pipeline_path=<var>pipeline-path</var> [--endpoint=<var>endpoint</var> --engine=<var>engine</var> \
--iap_client_id=<var>iap-client-id</var> --namespace=<var>namespace</var> --build_image]
--pipeline_path=pipeline-path
流水线配置文件的路径。
--endpoint=endpoint

(可选)Kubeflow Pipelines API 服务的端点。Kubeflow Pipelines API 服务的端点与 Kubeflow Pipelines 信息中心的网址相同。您的端点值应类似于:

<pre>https://<var>host-name</var>/pipeline</pre> <p> If you do not know the endpoint for your Kubeflow Pipelines cluster, contact you cluster administrator. </p> <p> If the <code>--endpoint</code> is not specified, the in-cluster service DNS name is used as the default value. This name works only if the CLI command executes in a pod on the Kubeflow Pipelines cluster, such as a <a href="https://www.kubeflow.org/docs/components/notebooks/jupyter-tensorflow-examples/" class="external">Kubeflow Jupyter notebooks</a> instance. </p>
--engine=engine

(可选)用于流水线的编排器。引擎的值必须与以下值匹配:

  • kubeflow:将引擎设置为 Kubeflow
  • local:将引擎设置为本地编排器
  • vertex:将引擎设置为 Vertex Pipelines
  • airflow:(实验性)将引擎设置为 Apache Airflow
  • beam :(实验性)将引擎设置为 Apache Beam

如果未设置引擎,则会根据环境自动检测引擎。

** 重要说明:DagRunner 在流水线配置文件中所需的编排器必须与所选或自动检测到的引擎匹配。引擎自动检测基于用户环境。如果未安装 Apache Airflow 和 Kubeflow Pipelines,则默认使用本地编排器。

--iap_client_id=iap-client-id
(可选)受 IAP 保护的端点的客户端 ID。
--namespace=namespace
(可选)要连接到 Kubeflow Pipelines API 的 Kubernetes 命名空间。如果未指定命名空间,则值将默认为 kubeflow
--build_image

(可选)当 enginekubeflowvertex 时,TFX 会为您的流水线创建容器镜像(如果已指定)。将使用当前目录中的 `Dockerfile`。

构建的镜像将被推送到在 `KubeflowDagRunnerConfig` 或 `KubeflowV2DagRunnerConfig` 中指定的远程注册表。

示例:

Kubeflow:

tfx pipeline update --engine=kubeflow --pipeline_path=<var>pipeline-path</var> \
--iap_client_id=<var>iap-client-id</var> --namespace=<var>namespace</var> --endpoint=<var>endpoint</var> \
--build_image

本地:

tfx pipeline update --engine=local --pipeline_path=<var>pipeline-path</var>

Vertex:

tfx pipeline update --engine=vertex --pipeline_path=<var>pipeline-path</var> \
--build_image

compile

编译流水线配置文件,以在 Kubeflow 中创建工作流文件并在编译时执行以下检查:

  1. 检查流水线路径是否有效。

  2. 检查是否从流水线配置文件中成功提取了流水线详细信息。

  3. 检查流水线配置中的 DagRunner 是否与引擎匹配。

  4. 检查是否在提供的软件包路径中成功创建了工作流文件(仅适用于 Kubeflow)。

建议在创建或更新流水线之前使用。

用法:

tfx pipeline compile --pipeline_path=<var>pipeline-path</var> [--engine=<var>engine</var>]
--pipeline_path=pipeline-path
流水线配置文件的路径。
--engine=engine

(可选)用于流水线的编排器。引擎的值必须与以下值匹配:

  • kubeflow:将引擎设置为 Kubeflow
  • local:将引擎设置为本地编排器
  • vertex:将引擎设置为 Vertex Pipelines
  • airflow:(实验性)将引擎设置为 Apache Airflow
  • beam :(实验性)将引擎设置为 Apache Beam

如果未设置引擎,则会根据环境自动检测引擎。

** 重要说明:DagRunner 在流水线配置文件中所需的编排器必须与所选或自动检测到的引擎匹配。引擎自动检测基于用户环境。如果未安装 Apache Airflow 和 Kubeflow Pipelines,则默认使用本地编排器。

示例:

Kubeflow:

tfx pipeline compile --engine=kubeflow --pipeline_path=<var>pipeline-path</var>

本地:

tfx pipeline compile --engine=local --pipeline_path=<var>pipeline-path</var>

Vertex:

tfx pipeline compile --engine=vertex --pipeline_path=<var>pipeline-path</var>

delete

从给定的编排器中删除流水线。

用法:

tfx pipeline delete --pipeline_path=<var>pipeline-path</var> [--endpoint=<var>endpoint</var> --engine=<var>engine</var> \
--iap_client_id=<var>iap-client-id</var> --namespace=<var>namespace</var>]
--pipeline_path=pipeline-path
流水线配置文件的路径。
--endpoint=endpoint

(可选)Kubeflow Pipelines API 服务的端点。Kubeflow Pipelines API 服务的端点与 Kubeflow Pipelines 信息中心的网址相同。您的端点值应类似于:

<pre>https://<var>host-name</var>/pipeline</pre> <p> If you do not know the endpoint for your Kubeflow Pipelines cluster, contact you cluster administrator. </p> <p> If the <code>--endpoint</code> is not specified, the in-cluster service DNS name is used as the default value. This name works only if the CLI command executes in a pod on the Kubeflow Pipelines cluster, such as a <a href="https://www.kubeflow.org/docs/components/notebooks/jupyter-tensorflow-examples/" class="external">Kubeflow Jupyter notebooks</a> instance. </p>
--engine=engine

(可选)用于流水线的编排器。引擎的值必须与以下值匹配:

  • kubeflow:将引擎设置为 Kubeflow
  • local:将引擎设置为本地编排器
  • vertex:将引擎设置为 Vertex Pipelines
  • airflow:(实验性)将引擎设置为 Apache Airflow
  • beam :(实验性)将引擎设置为 Apache Beam

如果未设置引擎,则会根据环境自动检测引擎。

** 重要说明:DagRunner 在流水线配置文件中所需的编排器必须与所选或自动检测到的引擎匹配。引擎自动检测基于用户环境。如果未安装 Apache Airflow 和 Kubeflow Pipelines,则默认使用本地编排器。

--iap_client_id=iap-client-id
(可选)受 IAP 保护的端点的客户端 ID。
--namespace=namespace
(可选)要连接到 Kubeflow Pipelines API 的 Kubernetes 命名空间。如果未指定命名空间,则值将默认为 kubeflow

示例:

Kubeflow:

tfx pipeline delete --engine=kubeflow --pipeline_name=<var>pipeline-name</var> \
--iap_client_id=<var>iap-client-id</var> --namespace=<var>namespace</var> --endpoint=<var>endpoint</var>

本地:

tfx pipeline delete --engine=local --pipeline_name=<var>pipeline-name</var>

Vertex:

tfx pipeline delete --engine=vertex --pipeline_name=<var>pipeline-name</var>

list

列出给定编排器中的所有流水线。

用法:

tfx pipeline list [--endpoint=<var>endpoint</var> --engine=<var>engine</var> \
--iap_client_id=<var>iap-client-id</var> --namespace=<var>namespace</var>]
--endpoint=endpoint

(可选)Kubeflow Pipelines API 服务的端点。Kubeflow Pipelines API 服务的端点与 Kubeflow Pipelines 信息中心的网址相同。您的端点值应类似于:

<pre>https://<var>host-name</var>/pipeline</pre> <p> If you do not know the endpoint for your Kubeflow Pipelines cluster, contact you cluster administrator. </p> <p> If the <code>--endpoint</code> is not specified, the in-cluster service DNS name is used as the default value. This name works only if the CLI command executes in a pod on the Kubeflow Pipelines cluster, such as a <a href="https://www.kubeflow.org/docs/components/notebooks/jupyter-tensorflow-examples/" class="external">Kubeflow Jupyter notebooks</a> instance. </p>
--engine=engine

(可选)用于流水线的编排器。引擎的值必须与以下值匹配:

  • kubeflow:将引擎设置为 Kubeflow
  • local:将引擎设置为本地编排器
  • vertex:将引擎设置为 Vertex Pipelines
  • airflow:(实验性)将引擎设置为 Apache Airflow
  • beam :(实验性)将引擎设置为 Apache Beam

如果未设置引擎,则会根据环境自动检测引擎。

** 重要说明:DagRunner 在流水线配置文件中所需的编排器必须与所选或自动检测到的引擎匹配。引擎自动检测基于用户环境。如果未安装 Apache Airflow 和 Kubeflow Pipelines,则默认使用本地编排器。

--iap_client_id=iap-client-id
(可选)受 IAP 保护的端点的客户端 ID。
--namespace=namespace
(可选)要连接到 Kubeflow Pipelines API 的 Kubernetes 命名空间。如果未指定命名空间,则值将默认为 kubeflow

示例:

Kubeflow:

tfx pipeline list --engine=kubeflow --iap_client_id=<var>iap-client-id</var> \
--namespace=<var>namespace</var> --endpoint=<var>endpoint</var>

本地:

tfx pipeline list --engine=local

Vertex:

tfx pipeline list --engine=vertex

tfx run

tfx run 命令组中的命令结构如下:

tfx run <var>command</var> <var>required-flags</var> [<var>optional-flags</var>]

使用以下各个部分详细了解 tfx run 命令组中的命令。

create

在编排器中为流水线创建新的运行实例。对于 Kubeflow,会使用集群中流水线的最新版本。

用法:

tfx run create --pipeline_name=<var>pipeline-name</var> [--endpoint=<var>endpoint</var> \
--engine=<var>engine</var> --iap_client_id=<var>iap-client-id</var> --namespace=<var>namespace</var>]
--pipeline_name=pipeline-name
流水线的名称。
--endpoint=endpoint

(可选)Kubeflow Pipelines API 服务的端点。Kubeflow Pipelines API 服务的端点与 Kubeflow Pipelines 信息中心的网址相同。您的端点值应类似于:

<pre>https://<var>host-name</var>/pipeline</pre> <p> If you do not know the endpoint for your Kubeflow Pipelines cluster, contact you cluster administrator. </p> <p> If the <code>--endpoint</code> is not specified, the in-cluster service DNS name is used as the default value. This name works only if the CLI command executes in a pod on the Kubeflow Pipelines cluster, such as a <a href="https://www.kubeflow.org/docs/components/notebooks/jupyter-tensorflow-examples/" class="external">Kubeflow Jupyter notebooks</a> instance. </p>
--engine=engine

(可选)用于流水线的编排器。引擎的值必须与以下值匹配:

  • kubeflow:将引擎设置为 Kubeflow
  • local:将引擎设置为本地编排器
  • vertex:将引擎设置为 Vertex Pipelines
  • airflow:(实验性)将引擎设置为 Apache Airflow
  • beam :(实验性)将引擎设置为 Apache Beam

如果未设置引擎,则会根据环境自动检测引擎。

** 重要说明:DagRunner 在流水线配置文件中所需的编排器必须与所选或自动检测到的引擎匹配。引擎自动检测基于用户环境。如果未安装 Apache Airflow 和 Kubeflow Pipelines,则默认使用本地编排器。

--runtime_parameter=parameter-name=parameter-value
(可选)设置运行时参数值。可以多次设置来设置多个变量的值。仅适用于 `airflow`、`kubeflow` 和 `vertex` 引擎。
--iap_client_id=iap-client-id
(可选)受 IAP 保护的端点的客户端 ID。
--namespace=namespace
(可选)要连接到 Kubeflow Pipelines API 的 Kubernetes 命名空间。如果未指定命名空间,则值将默认为 kubeflow
--project=GCP-project-id
(Vertex 必需)Vertex 流水线的 GCP 项目 ID。
--region=GCP-region
(Vertex 必需)GCP 区域名称,例如 us-central1。有关可用区域,请参阅 [Vertex 文档] (https://cloud.google.com/vertex-ai/docs/general/locations)。

示例:

Kubeflow:

tfx run create --engine=kubeflow --pipeline_name=<var>pipeline-name</var> --iap_client_id=<var>iap-client-id</var> \
--namespace=<var>namespace</var> --endpoint=<var>endpoint</var>

本地:

tfx run create --engine=local --pipeline_name=<var>pipeline-name</var>

Vertex:

tfx run create --engine=vertex --pipeline_name=<var>pipeline-name</var> \
  --runtime_parameter=<var>var_name</var>=<var>var_value</var> \
  --project=<var>gcp-project-id</var> --region=<var>gcp-region</var>

terminate

停止给定流水线的运行。

** 重要说明:目前仅在 Kubeflow 中受支持。

用法:

tfx run terminate --run_id=<var>run-id</var> [--endpoint=<var>endpoint</var> --engine=<var>engine</var> \
--iap_client_id=<var>iap-client-id</var> --namespace=<var>namespace</var>]
--run_id=run-id
流水线运行的唯一标识符。
--endpoint=endpoint

(可选)Kubeflow Pipelines API 服务的端点。Kubeflow Pipelines API 服务的端点与 Kubeflow Pipelines 信息中心的网址相同。您的端点值应类似于:

<pre>https://<var>host-name</var>/pipeline</pre> <p> If you do not know the endpoint for your Kubeflow Pipelines cluster, contact you cluster administrator. </p> <p> If the <code>--endpoint</code> is not specified, the in-cluster service DNS name is used as the default value. This name works only if the CLI command executes in a pod on the Kubeflow Pipelines cluster, such as a <a href="https://www.kubeflow.org/docs/components/notebooks/jupyter-tensorflow-examples/" class="external">Kubeflow Jupyter notebooks</a> instance. </p>
--engine=engine

(可选)用于流水线的编排器。引擎的值必须与以下值匹配:

  • kubeflow:将引擎设置为 Kubeflow

如果未设置引擎,则会根据环境自动检测引擎。

** 重要说明:DagRunner 在流水线配置文件中所需的编排器必须与所选或自动检测到的引擎匹配。引擎自动检测基于用户环境。如果未安装 Apache Airflow 和 Kubeflow Pipelines,则默认使用本地编排器。

--iap_client_id=iap-client-id
(可选)受 IAP 保护的端点的客户端 ID。
--namespace=namespace
(可选)要连接到 Kubeflow Pipelines API 的 Kubernetes 命名空间。如果未指定命名空间,则值将默认为 kubeflow

示例:

Kubeflow:

tfx run delete --engine=kubeflow --run_id=<var>run-id</var> --iap_client_id=<var>iap-client-id</var> \
--namespace=<var>namespace</var> --endpoint=<var>endpoint</var>

list

列出流水线的所有运行。

** 重要说明:目前在本地和 Apache Beam 中不受支持。

用法:

tfx run list --pipeline_name=<var>pipeline-name</var> [--endpoint=<var>endpoint</var> \
--engine=<var>engine</var> --iap_client_id=<var>iap-client-id</var> --namespace=<var>namespace</var>]
--pipeline_name=pipeline-name
流水线的名称。
--endpoint=endpoint

(可选)Kubeflow Pipelines API 服务的端点。Kubeflow Pipelines API 服务的端点与 Kubeflow Pipelines 信息中心的网址相同。您的端点值应类似于:

<pre>https://<var>host-name</var>/pipeline</pre> <p> If you do not know the endpoint for your Kubeflow Pipelines cluster, contact you cluster administrator. </p> <p> If the <code>--endpoint</code> is not specified, the in-cluster service DNS name is used as the default value. This name works only if the CLI command executes in a pod on the Kubeflow Pipelines cluster, such as a <a href="https://www.kubeflow.org/docs/components/notebooks/jupyter-tensorflow-examples/" class="external">Kubeflow Jupyter notebooks</a> instance. </p>
--engine=engine

(可选)用于流水线的编排器。引擎的值必须与以下值匹配:

  • kubeflow:将引擎设置为 Kubeflow
  • airflow:(实验性)将引擎设置为 Apache Airflow

如果未设置引擎,则会根据环境自动检测引擎。

** 重要说明:DagRunner 在流水线配置文件中所需的编排器必须与所选或自动检测到的引擎匹配。引擎自动检测基于用户环境。如果未安装 Apache Airflow 和 Kubeflow Pipelines,则默认使用本地编排器。

--iap_client_id=iap-client-id
(可选)受 IAP 保护的端点的客户端 ID。
--namespace=namespace
(可选)要连接到 Kubeflow Pipelines API 的 Kubernetes 命名空间。如果未指定命名空间,则值将默认为 kubeflow

示例:

Kubeflow:

tfx run list --engine=kubeflow --pipeline_name=<var>pipeline-name</var> --iap_client_id=<var>iap-client-id</var> \
--namespace=<var>namespace</var> --endpoint=<var>endpoint</var>

status

返回运行的当前状态。

** 重要说明:目前在本地和 Apache Beam 中不受支持。

用法:

tfx run status --pipeline_name=<var>pipeline-name</var> --run_id=<var>run-id</var> [--endpoint=<var>endpoint</var> \
--engine=<var>engine</var> --iap_client_id=<var>iap-client-id</var> --namespace=<var>namespace</var>]
--pipeline_name=pipeline-name
流水线的名称。
--run_id=run-id
流水线运行的唯一标识符。
--endpoint=endpoint

(可选)Kubeflow Pipelines API 服务的端点。Kubeflow Pipelines API 服务的端点与 Kubeflow Pipelines 信息中心的网址相同。您的端点值应类似于:

<pre>https://<var>host-name</var>/pipeline</pre> <p> If you do not know the endpoint for your Kubeflow Pipelines cluster, contact you cluster administrator. </p> <p> If the <code>--endpoint</code> is not specified, the in-cluster service DNS name is used as the default value. This name works only if the CLI command executes in a pod on the Kubeflow Pipelines cluster, such as a <a href="https://www.kubeflow.org/docs/components/notebooks/jupyter-tensorflow-examples/" class="external">Kubeflow Jupyter notebooks</a> instance. </p>
--engine=engine

(可选)用于流水线的编排器。引擎的值必须与以下值匹配:

  • kubeflow:将引擎设置为 Kubeflow
  • airflow:(实验性)将引擎设置为 Apache Airflow

如果未设置引擎,则会根据环境自动检测引擎。

** 重要说明:DagRunner 在流水线配置文件中所需的编排器必须与所选或自动检测到的引擎匹配。引擎自动检测基于用户环境。如果未安装 Apache Airflow 和 Kubeflow Pipelines,则默认使用本地编排器。

--iap_client_id=iap-client-id
(可选)受 IAP 保护的端点的客户端 ID。
--namespace=namespace
(可选)要连接到 Kubeflow Pipelines API 的 Kubernetes 命名空间。如果未指定命名空间,则值将默认为 kubeflow

示例:

Kubeflow:

tfx run status --engine=kubeflow --run_id=<var>run-id</var> --pipeline_name=<var>pipeline-name</var> \
--iap_client_id=<var>iap-client-id</var> --namespace=<var>namespace</var> --endpoint=<var>endpoint</var>

delete

删除给定流水线的运行。

** 重要说明:目前仅在 Kubeflow 中受支持。

用法:

tfx run delete --run_id=<var>run-id</var> [--engine=<var>engine</var> --iap_client_id=<var>iap-client-id</var> \
--namespace=<var>namespace</var> --endpoint=<var>endpoint</var>]
--run_id=run-id
流水线运行的唯一标识符。
--endpoint=endpoint

(可选)Kubeflow Pipelines API 服务的端点。Kubeflow Pipelines API 服务的端点与 Kubeflow Pipelines 信息中心的网址相同。您的端点值应类似于:

<pre>https://<var>host-name</var>/pipeline</pre> <p> If you do not know the endpoint for your Kubeflow Pipelines cluster, contact you cluster administrator. </p> <p> If the <code>--endpoint</code> is not specified, the in-cluster service DNS name is used as the default value. This name works only if the CLI command executes in a pod on the Kubeflow Pipelines cluster, such as a <a href="https://www.kubeflow.org/docs/components/notebooks/jupyter-tensorflow-examples/" class="external">Kubeflow Jupyter notebooks</a> instance. </p>
--engine=engine

(可选)用于流水线的编排器。引擎的值必须与以下值匹配:

  • kubeflow:将引擎设置为 Kubeflow

如果未设置引擎,则会根据环境自动检测引擎。

** 重要说明:DagRunner 在流水线配置文件中所需的编排器必须与所选或自动检测到的引擎匹配。引擎自动检测基于用户环境。如果未安装 Apache Airflow 和 Kubeflow Pipelines,则默认使用本地编排器。

--iap_client_id=iap-client-id
(可选)受 IAP 保护的端点的客户端 ID。
--namespace=namespace
(可选)要连接到 Kubeflow Pipelines API 的 Kubernetes 命名空间。如果未指定命名空间,则值将默认为 kubeflow

示例:

Kubeflow:

tfx run delete --engine=kubeflow --run_id=<var>run-id</var> --iap_client_id=<var>iap-client-id</var> \
--namespace=<var>namespace</var> --endpoint=<var>endpoint</var>

tfx template [实验性]

tfx template 命令组中的命令结构如下:

tfx template <var>command</var> <var>required-flags</var> [<var>optional-flags</var>]

使用以下部分详细了解 tfx template 命令组中的命令。模板是一项实验性功能,随时可能更改。

list

列出可用的 TFX 流水线模板。

用法:

tfx template list

copy

将模板复制到目标目录。

用法:

tfx template copy --model=<var>model</var> --pipeline_name=<var>pipeline-name</var> \
--destination_path=<var>destination-path</var>
--model=model
由流水线模板构建的模型的名称。
--pipeline_name=pipeline-name
流水线的名称。
--destination_path=destination-path
要将模板复制到的路径。

了解 TFX CLI 标记

通用标记

--engine=engine

用于流水线的编排器。引擎的值必须与以下值匹配:

  • kubeflow:将引擎设置为 Kubeflow
  • local:将引擎设置为本地编排器
  • vertex:将引擎设置为 Vertex Pipelines
  • airflow:(实验性)将引擎设置为 Apache Airflow
  • beam :(实验性)将引擎设置为 Apache Beam

如果未设置引擎,则会根据环境自动检测引擎。

** 重要说明:DagRunner 在流水线配置文件中所需的编排器必须与所选或自动检测到的引擎匹配。引擎自动检测基于用户环境。如果未安装 Apache Airflow 和 Kubeflow Pipelines,则默认使用本地编排器。

--pipeline_name=pipeline-name
流水线的名称。
--pipeline_path=pipeline-path
流水线配置文件的路径。
--run_id=run-id
流水线运行的唯一标识符。

Kubeflow 专用标记

--endpoint=endpoint

Kubeflow Pipelines API 服务的端点。Kubeflow Pipelines API 服务的端点与 Kubeflow Pipelines 信息中心的网址相同。您的端点值应类似于:

<pre>https://<var>host-name</var>/pipeline</pre> <p> If you do not know the endpoint for your Kubeflow Pipelines cluster, contact you cluster administrator. </p> <p> If the <code>--endpoint</code> is not specified, the in-cluster service DNS name is used as the default value. This name works only if the CLI command executes in a pod on the Kubeflow Pipelines cluster, such as a <a href="https://www.kubeflow.org/docs/components/notebooks/jupyter-tensorflow-examples/" class="external">Kubeflow Jupyter notebooks</a> instance. </p>
--iap_client_id=iap-client-id
受 IAP 保护的端点的客户端 ID。
--namespace=namespace
要连接到 Kubeflow Pipelines API 的 Kubernetes 命名空间。如果未指定命名空间,则值将默认为 kubeflow

由 TFX CLI 生成的文件

创建并运行流水线后,会生成几个文件用于流水线管理。

  • ${HOME}/tfx/local、beam、airflow、vertex

    • 从配置中读取的流水线元数据存储在 ${HOME}/tfx/${ORCHESTRATION_ENGINE}/${PIPELINE_NAME} 下。可以通过设置环境变量(如 AIRFLOW_HOMEKUBEFLOW_HOME)来自定义此位置。在未来的版本中可能会改变此行为。此目录用于存储流水线信息,包括创建运行或更新流水线所需的 Kubeflow Pipelines 集群中的流水线 ID。

    • 在 TFX 0.25 之前,这些文件位于 ${HOME}/${ORCHESTRATION_ENGINE} 下。在 TFX 0.25 中,旧位置中的文件将自动移动到新位置,以便顺利迁移。

    • 从 TFX 0.27 开始,Kubeflow 不会在本地文件系统中创建这些元数据文件。但是,请参阅以下内容,了解 Kubeflow 创建的其他文件。

  • (仅限 Kubeflow)Dockerfile 和容器镜像

    • Kubeflow Pipelines 需要两种流水线输入。这些文件由 TFX 在当前目录下生成。

    • 一种是容器镜像,用于在流水线中运行组件。此容器镜像在使用 --build-image 标记创建或更新 Kubeflow Pipelines 的流水线时构建。如果不存在,TFX CLI 将生成 Dockerfile,并构建容器镜像并将其推送到 KubeflowDagRunnerConfig 中指定的注册表。