How to return a dsl.component value to be used in a google vertex custom training op

I had a successfully running pipeline but needed to update to create a datetime string to attach as a suffix to my model names, this value is important to reference the model later on in the pipeline.

I have this (truncated) code:

from kfp import compiler, dsl
from google_cloud_pipeline_components.v1.custom_job import CustomTrainingJobOp

@dsl.component(base_image="python:3.10")
def init() -> str:
    from datetime import datetime

    datetime_suffix = datetime.now().strftime("%Y%m%d-%H%M%S")
    return "datetime_suffix"


@dsl.pipeline(name="Training Pipeline", description="Training pipeline on Vertex AI")
def training_pipeline():
    init_op = init()
    datetime_suffix = init_op.output

    retrieval_job_name = "train-retrieval-model"
    train_retrieval_job = (
        CustomTrainingJobOp(
            project=PROJECT_ID,
            display_name=retrieval_job_name,
            location="us-west1",
            worker_pool_specs=[
                {
                    "machine_spec": {
                        "machine_type": "n1-standard-16",
                        "accelerator_type": "NVIDIA_TESLA_T4",  # See: https://cloud.google.com/vertex-ai/docs/training/configure-compute#gpu-compatibility-table
                        "accelerator_count": 1,
                    },
                    "replica_count": "1",
                    "container_spec": {
                        "image_uri": RETRIEVAL_TRAIN_IMAGE,
                        "env": [
                            {
                                "name": "ENTRYPOINT_SCRIPT",
                                "value": "trainer.retrieval.task",
                            },
                            {
                                "name": "ENVIRONMENT",
                                "value": "prod",
                            },
                            {
                                "name": "MODEL_SUFFIX",
                                "value": datetime_suffix,
                            },
                        ],
                    },
                }
            ],
        )
        .after(init_op)
        .set_display_name(retrieval_job_name)
    )

And I get the error:

Traceback (most recent call last):
  File "/Users/pthieu/python/commit/matchmaking/pipeline/main.py", line 93, in <module>
    @dsl.pipeline(name="Training Pipeline", description="Training pipeline on Vertex AI")
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/dsl/pipeline_context.py", line 65, in pipeline
    return component_factory.create_graph_component_from_func(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/dsl/component_factory.py", line 673, in create_graph_component_from_func
    return graph_component.GraphComponent(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/dsl/graph_component.py", line 68, in __init__
    pipeline_spec, platform_spec = builder.create_pipeline_spec(
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/compiler/pipeline_spec_builder.py", line 1919, in create_pipeline_spec
    build_spec_by_group(
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/compiler/pipeline_spec_builder.py", line 1272, in build_spec_by_group
    subgroup_task_spec = build_task_spec_for_task(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/compiler/pipeline_spec_builder.py", line 309, in build_task_spec_for_task
    to_protobuf_value(input_value))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/compiler/pipeline_spec_builder.py", line 78, in to_protobuf_value
    values=[to_protobuf_value(v) for v in value]))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/compiler/pipeline_spec_builder.py", line 78, in <listcomp>
    values=[to_protobuf_value(v) for v in value]))
            ^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/compiler/pipeline_spec_builder.py", line 74, in to_protobuf_value
    fields={k: to_protobuf_value(v) for k, v in value.items()}))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/compiler/pipeline_spec_builder.py", line 74, in <dictcomp>
    fields={k: to_protobuf_value(v) for k, v in value.items()}))
               ^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/compiler/pipeline_spec_builder.py", line 74, in to_protobuf_value
    fields={k: to_protobuf_value(v) for k, v in value.items()}))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/compiler/pipeline_spec_builder.py", line 74, in <dictcomp>
    fields={k: to_protobuf_value(v) for k, v in value.items()}))
               ^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/compiler/pipeline_spec_builder.py", line 78, in to_protobuf_value
    values=[to_protobuf_value(v) for v in value]))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/compiler/pipeline_spec_builder.py", line 78, in <listcomp>
    values=[to_protobuf_value(v) for v in value]))
            ^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/compiler/pipeline_spec_builder.py", line 74, in to_protobuf_value
    fields={k: to_protobuf_value(v) for k, v in value.items()}))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/compiler/pipeline_spec_builder.py", line 74, in <dictcomp>
    fields={k: to_protobuf_value(v) for k, v in value.items()}))
               ^^^^^^^^^^^^^^^^^^^^
  File "/Users/pthieu/python/commit/matchmaking/pipeline/venv/lib/python3.11/site-packages/kfp/compiler/pipeline_spec_builder.py", line 80, in to_protobuf_value
    raise ValueError('Value must be one of the following types: '
ValueError: Value must be one of the following types: str, int, float, bool, dict, and list. Got: "{{channel:task=init;name=Output;type=String;}}" of type "<class 'kfp.dsl.pipeline_channel.PipelineParameterChannel'>".

Looks like CustomTrainingJobOp is not interpreting the returned value properly?

Here are my package versions:

google-cloud-pipeline-components==2.14.1
kfp==2.7.0
kfp-pipeline-spec==0.3.0
kfp-server-api==2.0.5

Note that I’m importing google-cloud-pipeline-components.v1 as I googled and people are saying there isn’t a proper equivalent in V2.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật