-
Notifications
You must be signed in to change notification settings - Fork 1
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
local resource override #42
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a version bump once approved by all expected parties!
block_cascade/decorators.py
Outdated
@@ -148,6 +152,11 @@ def remote_func(*args, **kwargs): | |||
# so that it can be sent to the remote executor with its parameters | |||
packed_func = wrapped_partial(func, *args, **kwargs) | |||
|
|||
# if running a flow locally ignore the remote resource, even if specified | |||
# necessary for running a @remote decorated task in a local flow | |||
if not via_cloud and no_resource_on_local: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add a log that resource is being ignored
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. Logging added!
Goal: Allow for a Prefect task decorated with
@remote
to be able to run both locally and in the Cloud without changing the code or remote args.Prefect 2 tasks decorated with
@remote
will fail if a resource is set but the flow is run locally:Additionally, because of the way Prefect 2+ creates tasks, using
remote_resource
does not solve this problem:This PR allows for an optional
no_resource_on_local
argument which enables a Cascade decorated task to overwritte the resource toNone
if the flow is being run locally AND the arg is set to True: