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

add ExecutionOptions to execute_operator() #3850

Merged
merged 7 commits into from
Dec 1, 2023

Conversation

brimoor
Copy link
Contributor

@brimoor brimoor commented Nov 29, 2023

Change log

  • Adds support for passing request_delegation and delegation_target to execute_operator()
  • Documents the new resolve_execution_options() and set_progress() methods
  • Documents the updated best practices for programmatically executing delegated operators

Note: if a user passes request_delegation=True but the operator doesn't support delegated execution, it will log a warning and just execute immediately instead:

foo.execute_operator(operator_uri, ctx=ctx, request_delegation=True)
# This operation does not support delegated execution; it will be executed immediately

@brimoor brimoor added the enhancement Code enhancement label Nov 29, 2023
@brimoor brimoor requested a review from ritch November 29, 2023 17:37
@brimoor brimoor self-assigned this Nov 29, 2023
Copy link

codecov bot commented Nov 29, 2023

Codecov Report

Attention: 34 lines in your changes are missing coverage. Please review.

Comparison is base (1eb8558) 15.56% compared to head (db73ce1) 15.56%.
Report is 13 commits behind head on release/v0.23.0.

Files Patch % Lines
app/packages/state/src/recoil/color.ts 8.57% 32 Missing ⚠️
...pp/packages/app/src/useSetters/onSetColorScheme.ts 0.00% 1 Missing ⚠️
app/packages/core/src/plugins/SchemaIO/index.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##           release/v0.23.0    #3850      +/-   ##
===================================================
- Coverage            15.56%   15.56%   -0.01%     
===================================================
  Files                  729      729              
  Lines                80994    81365     +371     
  Branches              1075     1085      +10     
===================================================
+ Hits                 12609    12661      +52     
- Misses               68385    68704     +319     
Flag Coverage Δ
app 15.56% <15.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

resolved_delegation = self.resolve_delegation(ctx)
if resolved_delegation is None:
# legacy behavior
if resolved_delegation is not None:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ritch this is the key change: if resolve_delgation() != None, then we rely on it to set ExecutionOptions

Copy link
Contributor

Choose a reason for hiding this comment

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

Excellent 👍


if params is None:
params = ctx.get("params", {})
ctx = {**ctx, **kwargs} # don't modify input `ctx` in-place
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ritch this is the other key change: it allows for request_delegation and delegation_target to be correctly passed through to the ExecutionContext using either of these syntaxes:

foo.execute_operator(..., ctx={"request_delegation": True, ...})
foo.execute_operator(..., request_delegation=True)

Copy link
Contributor

Choose a reason for hiding this comment

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

Great - and I'm assuming this is backwards compatible. Doesn't appear to be but I would be surprised if you missed that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, backwards compatible 👍

nebulae
nebulae previously approved these changes Nov 30, 2023
Copy link
Contributor

@nebulae nebulae left a comment

Choose a reason for hiding this comment

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

Nice! Thank you 🙏

ritch
ritch previously approved these changes Nov 30, 2023
@brimoor brimoor dismissed stale reviews from ritch and nebulae via 4da1d07 December 1, 2023 00:40
@brimoor brimoor merged commit d864afb into release/v0.23.0 Dec 1, 2023
7 checks passed
@brimoor brimoor deleted the execution-options branch December 1, 2023 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Code enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants