如何从组件中获取 Kubeflow 管道 运行 名称?

How to obtain the Kubeflow pipeline run name from within a component?

我正在使用 Kubeflow 管道。我想从任务组件内部访问“运行 名称”。例如,在下图中,运行 名称是“我的第一个 XGBoost 运行”——如标题所示。

我知道例如 by passing the parameter {{workflow.uid}} as a command line argument. I have also tried the Argo variable {{ workflow.name }} 是可能的,但这并没有给出正确的字符串。

目前KFP不支持这种内省

你能描述一下需要这个的场景吗?

您可以使用 {{workflow.annotations.pipelines.kubeflow.org/run_name}} argo 变量来获取 run_name

例如,

@func_to_container_op
def dummy(run_id, run_name) -> str:
    return run_id, run_name

@dsl.pipeline(
    name='test_pipeline',
)
def test_pipeline():
  dummy('{{workflow.labels.pipeline/runid}}', '{{workflow.annotations.pipelines.kubeflow.org/run_name}}')

您会发现占位符将被替换为正确的 run_id 和 run_name。