Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Artifacts/Elastic] Skip partitions #2620

Merged
merged 4 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions flytekit/core/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ def set_reference_artifact(self, artifact: Artifact):
p.reference_artifact = artifact

def __getattr__(self, item):
if item == "partitions" or item == "_partitions":
raise AttributeError("Partitions in an uninitialized state, skipping partitions")
if self.partitions and item in self.partitions:
return self.partitions[item]
raise AttributeError(f"Partition {item} not found in {self}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class ElasticWorkerResult(NamedTuple):

return_value: Any
decks: List[flytekit.Deck]
om: OutputMetadata
om: Optional[OutputMetadata] = None

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Could we please add om to ElasticWorkerResult's doc string? 🙇


def spawn_helper(
Expand Down Expand Up @@ -435,7 +435,7 @@ def fn_partial():
if isinstance(e, FlyteRecoverableException):
create_recoverable_error_file()
raise
return ElasticWorkerResult(return_value=return_val, decks=flytekit.current_context().decks)
return ElasticWorkerResult(return_value=return_val, decks=flytekit.current_context().decks, om=None)

launcher_target_func = fn_partial
launcher_args = ()
Expand Down
12 changes: 12 additions & 0 deletions tests/flytekit/unit/core/test_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,3 +619,15 @@ def test_lims():
# test an artifact with 11 partition keys
with pytest.raises(ValueError):
Artifact(name="test artifact", time_partitioned=True, partition_keys=[f"key_{i}" for i in range(11)])


def test_cloudpickle():
a1_b = Artifact(name="my_data", partition_keys=["b"])

spec = a1_b(b="my_b_value")
import cloudpickle

d = cloudpickle.dumps(spec)
spec2 = cloudpickle.loads(d)

assert spec2.partitions.b.value.static_value == "my_b_value"
Loading