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

simplify delegated operation doc #5291

Merged
merged 7 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 6 additions & 11 deletions fiftyone/factory/repos/delegated_operation_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ def __init__(
self,
operator: str = None,
delegation_target: str = None,
context: dict = None,
context: ExecutionContext = None,
is_remote: bool = False,
):
self.operator = operator
self.label = None
self.delegation_target = delegation_target
self.context = (
context.to_dict()
if isinstance(context, ExecutionContext)
else context
)
assert isinstance(context, ExecutionContext)
self.context = context
self.run_state = (
ExecutionRunState.SCHEDULED
if is_remote
Expand Down Expand Up @@ -111,11 +108,9 @@ def from_pymongo(self, doc: dict):

def to_pymongo(self) -> dict:
d = self.__dict__
d["context"] = (
d["context"].to_dict()
if isinstance(d["context"], ExecutionContext)
else d["context"]
)
d["context"] = {
"request_params": d["context"]._get_serialized_request_params()
}
d.pop("_doc")
d.pop("id")
return d
5 changes: 5 additions & 0 deletions fiftyone/operators/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,11 @@ def store(self, store_name):
dataset_id = self.dataset._doc.id
return ExecutionStore.create(store_name, dataset_id)

def _get_serialized_request_params(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really liking this as the interface...but didn't feel that changing .serialize() was the right move. However there is no need for panel_state in a serialized ctx. Instead it should really be outside of request_params to begin with. I've started that change elsewhere, but its a much more complex change and regresses some functionality in the dashboard plugin.

request_params_copy = self.request_params.copy()
request_params_copy.pop("panel_state")
return request_params_copy

def serialize(self):
"""Serializes the execution context.

Expand Down
Loading