Skip to content

Commit

Permalink
Remove artifactID from literal oneof, add to metadata (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
wild-endeavor authored Sep 4, 2023
1 parent 1570071 commit 3bae330
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
5 changes: 2 additions & 3 deletions flytekit/core/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions flytekit/models/literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -860,21 +859,18 @@ 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.
: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):
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
)
7 changes: 6 additions & 1 deletion flytekit/remote/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3bae330

Please sign in to comment.