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

[FEAT] Enable to_json_string for physical plan #3023

Merged
merged 2 commits into from
Oct 15, 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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions daft/daft/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,7 @@ class PhysicalPlanScheduler:
def num_partitions(self) -> int: ...
def repr_ascii(self, simple: bool) -> str: ...
def repr_mermaid(self, options: MermaidOptions) -> str: ...
def to_json_string(self) -> str: ...
def to_partition_tasks(self, psets: dict[str, list[PartitionT]]) -> physical_plan.InProgressPhysicalPlan: ...
def run(self, psets: dict[str, list[PartitionT]]) -> Iterator[PyMicroPartition]: ...

Expand Down
3 changes: 3 additions & 0 deletions daft/logical/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def to_physical_plan_scheduler(self, daft_execution_config: PyDaftExecutionConfi
used to generate executable tasks for the physical plan.

This should be called after triggering optimization with self.optimize().

**Warning**: This function is not part of the stable API and may change
without notice. It is intended for internal or experimental use only.
"""
from daft.plan_scheduler.physical_plan_scheduler import PhysicalPlanScheduler

Expand Down
3 changes: 3 additions & 0 deletions daft/plan_scheduler/physical_plan_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
def __repr__(self) -> str:
return self._scheduler.repr_ascii(simple=False)

def to_json_string(self) -> str:
return self._scheduler.to_json_string()

Check warning on line 57 in daft/plan_scheduler/physical_plan_scheduler.py

View check run for this annotation

Codecov / codecov/patch

daft/plan_scheduler/physical_plan_scheduler.py#L57

Added line #L57 was not covered by tests

def to_partition_tasks(
self, psets: dict[str, list[PartitionT]], results_buffer_size: int | None
) -> physical_plan.MaterializedPhysicalPlan:
Expand Down
1 change: 1 addition & 0 deletions src/daft-scheduler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ daft-plan = {path = "../daft-plan", default-features = false}
daft-scan = {path = "../daft-scan", default-features = false}
pyo3 = {workspace = true, optional = true}
serde = {workspace = true, features = ["rc"]}
serde_json = {workspace = true}

[dev-dependencies]
rstest = {workspace = true}
Expand Down
4 changes: 4 additions & 0 deletions src/daft-scheduler/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
Ok(self.plan().repr_mermaid(options))
}

pub fn to_json_string(&self) -> PyResult<String> {
serde_json::to_string(&self.plan())
.map_err(|e| pyo3::PyErr::new::<pyo3::exceptions::PyValueError, _>(e.to_string()))
}

Check warning on line 86 in src/daft-scheduler/src/scheduler.rs

View check run for this annotation

Codecov / codecov/patch

src/daft-scheduler/src/scheduler.rs#L83-L86

Added lines #L83 - L86 were not covered by tests
/// Converts the contained physical plan into an iterator of executable partition tasks.
pub fn to_partition_tasks(
&self,
Expand Down
Loading