Пример #1
0
def build_input_artifact_spec(
    channel_spec: channel.Channel
) -> pipeline_pb2.ComponentInputsSpec.ArtifactSpec:
    """Builds artifact type spec for an input channel."""
    artifact_instance = channel_spec.type()
    result = pipeline_pb2.ComponentInputsSpec.ArtifactSpec()
    result.artifact_type.CopyFrom(
        pipeline_pb2.ArtifactTypeSchema(
            instance_schema=get_artifact_schema(artifact_instance)))
    _validate_properties_schema(
        instance_schema=result.artifact_type.instance_schema,
        properties=channel_spec.type.PROPERTIES)
    return result
Пример #2
0
def build_output_artifact_spec(
    channel_spec: channel.Channel
) -> pipeline_pb2.TaskOutputsSpec.OutputArtifactSpec:
    """Builds the Kubeflow pipeline output artifact spec from TFX channel spec."""
    artifact_instance = channel_spec.type()
    result = pipeline_pb2.TaskOutputsSpec.OutputArtifactSpec()
    result.artifact_type.CopyFrom(
        pipeline_pb2.ArtifactTypeSchema(
            instance_schema=get_artifact_schema(artifact_instance)))
    for k, v in convert_from_tfx_properties(
            artifact_instance.mlmd_artifact.properties).items():
        result.properties[k].CopyFrom(v)
    for k, v in convert_from_tfx_properties(
            artifact_instance.mlmd_artifact.custom_properties).items():
        result.custom_properties[k].CopyFrom(v)
    return result
Пример #3
0
def build_output_artifact_spec(
    channel_spec: channel.Channel
) -> pipeline_pb2.ComponentOutputsSpec.ArtifactSpec:
    """Builds artifact type spec for an output channel."""
    # We use the first artifact instance if available from channel, otherwise
    # create one.
    artifacts = list(channel_spec.get())
    artifact_instance = artifacts[0] if artifacts else channel_spec.type()

    result = pipeline_pb2.ComponentOutputsSpec.ArtifactSpec()
    result.artifact_type.CopyFrom(
        pipeline_pb2.ArtifactTypeSchema(
            instance_schema=get_artifact_schema(artifact_instance)))

    _validate_properties_schema(
        instance_schema=result.artifact_type.instance_schema,
        properties=channel_spec.type.PROPERTIES)

    struct_proto = pack_artifact_properties(artifact_instance)
    if struct_proto:
        result.metadata.CopyFrom(struct_proto)
    return result