Skip to content

Commit

Permalink
Add .result() method on SingleOutputPartitionTask
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Chia committed Nov 22, 2023
1 parent 30ea7ee commit 2843588
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions daft/execution/execution_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,28 +176,29 @@ def set_result(self, result: list[MaterializedResult[PartitionT]]) -> None:
def done(self) -> bool:
return self._result is not None

def result(self) -> MaterializedResult[PartitionT]:
assert self._result is not None, "Cannot call .result() on a PartitionTask that is not done"
return self._result

def cancel(self) -> None:
# Currently only implemented for Ray tasks.
if self._result is not None:
self._result.cancel()
if self.done():
self.result().cancel()

def partition(self) -> PartitionT:
"""Get the PartitionT resulting from running this PartitionTask."""
assert self._result is not None
return self._result.partition()
return self.result().partition()

def partition_metadata(self) -> PartitionMetadata:
"""Get the metadata of the result partition.
(Avoids retrieving the actual partition itself if possible.)
"""
assert self._result is not None
return self._result.metadata()
return self.result().metadata()

def vpartition(self) -> Table:
"""Get the raw vPartition of the result."""
assert self._result is not None
return self._result.vpartition()
return self.result().vpartition()

def __str__(self) -> str:
return super().__str__()
Expand Down
2 changes: 1 addition & 1 deletion daft/execution/physical_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ def materialize(
# Check if any inputs finished executing.
while len(materializations) > 0 and materializations[0].done():
done_task = materializations.popleft()
yield done_task._result
yield done_task.result()

# Materialize a single dependency.
try:
Expand Down

0 comments on commit 2843588

Please sign in to comment.