From 3bae330e92f4965b728a6bc5907d8f1eeefbf259 Mon Sep 17 00:00:00 2001 From: Yee Hing Tong Date: Mon, 4 Sep 2023 10:20:07 -0700 Subject: [PATCH] Remove artifactID from literal oneof, add to metadata (#2) --- flytekit/core/interface.py | 5 ++--- flytekit/models/literals.py | 10 ---------- flytekit/remote/remote.py | 7 ++++++- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/flytekit/core/interface.py b/flytekit/core/interface.py index ee69e74279..53a966b685 100644 --- a/flytekit/core/interface.py +++ b/flytekit/core/interface.py @@ -224,9 +224,8 @@ def transform_inputs_to_parameters( if isinstance(_default, identifier_pb2.ArtifactQuery): params[k] = _interface_models.Parameter(var=v, required=False, artifact_query=_default) elif isinstance(_default, Artifact): - artifact_id = _default.as_artifact_id - lit = Literal(artifact_id=artifact_id) - params[k] = _interface_models.Parameter(var=v, required=False) # fix this, placeholder + artifact_id = _default.as_artifact_id # may raise + params[k] = _interface_models.Parameter(var=v, required=False, artifact_id=artifact_id) else: required = _default is None default_lv = None diff --git a/flytekit/models/literals.py b/flytekit/models/literals.py index c2c75e43b0..a1e2280e03 100644 --- a/flytekit/models/literals.py +++ b/flytekit/models/literals.py @@ -3,7 +3,6 @@ import pytz as _pytz from flyteidl.core import literals_pb2 as _literals_pb2 -from flyteidl.core.identifier_pb2 import ArtifactID from google.protobuf.struct_pb2 import Struct from flytekit.exceptions import user as _user_exceptions @@ -860,7 +859,6 @@ def __init__( collection: Optional[LiteralCollection] = None, map: Optional[LiteralMap] = None, hash: Optional[str] = None, - artifact_id: Optional[ArtifactID] = None, ): """ This IDL message represents a literal value in the Flyte ecosystem. @@ -868,13 +866,11 @@ def __init__( :param Scalar scalar: :param LiteralCollection collection: :param LiteralMap map: - :param artifact_id: """ self._scalar = scalar self._collection = collection self._map = map self._hash = hash - self._artifact_id = artifact_id @property def scalar(self): @@ -916,10 +912,6 @@ def hash(self): """ return self._hash - @property - def artifact_id(self): - return self._artifact_id - @hash.setter def hash(self, value): self._hash = value @@ -933,7 +925,6 @@ def to_flyte_idl(self): collection=self.collection.to_flyte_idl() if self.collection is not None else None, map=self.map.to_flyte_idl() if self.map is not None else None, hash=self.hash, - artifact_id=self.artifact_id, ) @classmethod @@ -950,6 +941,5 @@ def from_flyte_idl(cls, pb2_object): scalar=Scalar.from_flyte_idl(pb2_object.scalar) if pb2_object.HasField("scalar") else None, collection=collection, map=LiteralMap.from_flyte_idl(pb2_object.map) if pb2_object.HasField("map") else None, - artifact_id=pb2_object.artifact_id if pb2_object.HasField("artifact_id") else None, hash=pb2_object.hash if pb2_object.hash else None, ) diff --git a/flytekit/remote/remote.py b/flytekit/remote/remote.py index 9fe8770e6d..4af3f57c8f 100644 --- a/flytekit/remote/remote.py +++ b/flytekit/remote/remote.py @@ -1079,7 +1079,12 @@ def _execute( if v.literal is not None: lit = v.literal elif v.artifact_id is not None: - lit = literal_models.Literal(artifact_id=v.artifact_id) + fetched_artifact = self.get_artifact(artifact_id=v.artifact_id) + if not fetched_artifact: + raise user_exceptions.FlyteValueException( + v.artifact_id, "Could not find artifact with ID given" + ) + lit = fetched_artifact.literal else: raise user_exceptions.FlyteValueException( v, "When binding input to Artifact, either the Literal or the ID must be set"