Skip to content

Commit

Permalink
fix artifact class construction
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-mccarthy committed Sep 1, 2022
1 parent 7cb474f commit 904febf
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions sdk/python/kfp/components/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,14 @@ def make_artifact(
func: Callable,
) -> Any:
artifact_cls = func.__annotations__.get(name)
return create_artifact_instance(runtime_artifact, artifact_cls)
if type_annotations.is_artifact(artifact_cls):
# handles artifacts
return create_artifact_instance(
runtime_artifact, artifact_cls=artifact_cls)
else:
# handles InputPath and OutputPath
return create_artifact_instance(
runtime_artifact, artifact_cls=artifact_types.Artifact)

def makedirs_recursively(self, path: str) -> None:
os.makedirs(os.path.dirname(path), exist_ok=True)
Expand Down Expand Up @@ -317,10 +324,9 @@ def create_artifact_instance(
dictionary."""
schema_title = runtime_artifact.get('type', {}).get('schemaTitle', '')

artifact_type = artifact_types._SCHEMA_TITLE_TO_TYPE.get(schema_title)
if not artifact_type:
artifact_type = artifact_cls or artifact_types.Artifact
return artifact_type(
artifact_cls = artifact_types._SCHEMA_TITLE_TO_TYPE.get(
schema_title) or artifact_cls or artifact_types.Artifact
return artifact_cls(
uri=runtime_artifact.get('uri', ''),
name=runtime_artifact.get('name', ''),
metadata=runtime_artifact.get('metadata', {}),
Expand Down

0 comments on commit 904febf

Please sign in to comment.