Chris
Chris

Reputation: 31266

What causes a TypeError under all conditions on Kubeflow KFP v2.0.0+?

kfp==2.8.0  # and on 2.7.0
kfp-pipeline-spec==0.3.0
kfp-server-api==2.0.5

Example code:

from kfp import dsl
import kfp


@dsl.component
def add(a: float, b: float) -> float:
    '''Calculates sum of two arguments'''
    return a + b


@dsl.pipeline(
    name='Addition pipeline',
    description='An example pipeline that performs addition calculations.')
def add_pipeline(
    a: float = 1.0,
    b: float = 7.0,
):
    first_add_task = add(a=a, b=4.0)
    second_add_task = add(a=first_add_task.output, b=b)

Source: https://kubeflow-pipelines.readthedocs.io/en/sdk-2.7.0/index.html

Error:

TypeError: Artifacts must have both a schema_title and a schema_version, separated by `@`. Got: float

Error yields at first pipeline definition. I have screwed around for a while, and am stumped. Why would the example fail?

Upvotes: 0

Views: 98

Answers (1)

Chris
Chris

Reputation: 31266

Yeah, this seems to be a weird bug. If I include annotations,

from __future__ import annotations

kfp will not build any pipeline with any inputs under any conditions. This THOROUGHLY BREAKS all error handling related to pipeline input arg type.

After removing annotations, I received salient error messages and was able to get to the bottom of things. To reproduce the problem:

from __future__ import annotations  # comment this out, and it will work again
import kfp
from kfp import dsl


@dsl.component
def add(a: float, b: float) -> float:
    '''Calculates sum of two arguments'''
    return a + b


@dsl.pipeline(name='Addition pipeline', description='An example pipeline that performs addition calculations.')
def add_pipeline( a: float = 1.0, b: float = 7.0):
    first_add_task = add(a=a, b=4.0)
    second_add_task = add(a=first_add_task.output, b=b)

Upvotes: 0

Related Questions