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

问题描述

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

enter image description here

例如,我知道可以通过将参数{{workflow.uid}}作为命令行参数来传递obtain the workflow ID。我也尝试过Argo variable {{ workflow.name }},但这不能提供正确的字符串。

解决方法

您可以使用 {{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。

,

当前,KFP不支持这种自省。

能否请您描述一下需要这样做的情况?