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

I'm working with Kubeflow pipelines. I would like to access the "Run name" from inside the a task component. For example in the below image the run name is "My first XGBoost run" - as seen in the title.

enter image description here

I know for example it's possible to obtain the workflow ID by passing the parameter {{workflow.uid}} as a command line argument. I have also tried the Argo variable {{ workflow.name }} but this doesn't give the correct string.



Solution 1:[1]

You can use {{workflow.annotations.pipelines.kubeflow.org/run_name}} argo variable to get the run_name

For example,

@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}}')

You will find that the placeholders will be replaced with the correct run_id and run_name.

Solution 2:[2]

Currently KFP does not support this kind of introspection.

Can you please describe a scenario where this is needed?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jack Lin
Solution 2 Ark-kun