1

Kubeflow pipelines docs mentions that there is a way to add metadata annotations as a key-value pairs. From the other hand, I could not find any relevant documentation of how it can be done.

Is there an option to add some metadata to any kfp component? If yes, can it be done using a python function component? I'd like to add some metadata and annotations a component that will get compiled into the resulting pipeline.

I've seen that:

  1. in the past, one could use add_pod_annotation which is now deprecated and any way it was translated to Kubernetes pod annotations
  2. We can add annotations to Artifacts

But both not relevant to my use case.

Ideally, I'd expect something like that:

@dsl.component(
 packages_to_install=['pandas==1.3.5'],
 metadata={"k1": "v1", "k2":"v2"}
)
def say_hello(name: str) -> str:
    hello_text = f'Hello, {name}!'
    return hello_text

Which will get compiled into some pipeline yaml, where this component has another metadata section with {"k1": "v1", "k2":"v2"}.

Omri
  • 43
  • 1
  • 4

1 Answers1

0

In kubeflow V1 it's possible in the following way:

def add_one(x: float) -> float:
    return x + 1.0

kfp.components.create_component_from_func(
        func=add_one,
        annotations={"sample_annotation": "sample_value"},
        output_component_file=f"./component.yaml"
    )

And the resulting yaml will look like:

name: add one
metadata:
  annotations: {sample_annotation: sample_value}
...
Omri
  • 43
  • 1
  • 4