-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Extend visit_collection
with support for annotations
#7263
Conversation
✅ Deploy Preview for prefect-orion ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
src/prefect/engine.py
Outdated
@@ -1418,7 +1412,7 @@ def resolve_input(expr): | |||
# Do not allow uncompleted upstreams except failures when `allow_failure` has | |||
# been used | |||
if not state.is_completed() and not ( | |||
should_allow_failure and state.is_failed() | |||
isinstance(context.get("annotation"), allow_failure) and state.is_failed() |
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.
Hm. This will break when annotations are nested e.g. allow_failure(quote("foo"))
— maybe I should make the context have a list or set of annotations?
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.
That makes sense to me - it seems that you could even change the key name to annotations
without any backwards compatible breakage since the flow is re-parsed with each run
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.
I'm going to wait for this to be an actual issue so we can keep this simple and get it out there
# Moved to `prefect.utilities.annotations` but preserved here for compatibility | ||
from prefect.utilities.annotations import Quote, quote # noqa | ||
# Quote moved to `prefect.utilities.annotations` but preserved here for compatibility | ||
from prefect.utilities.annotations import BaseAnnotation, Quote, quote # noqa |
Check notice
Code scanning / CodeQL
Unused import
@peytonrunyan please re-review |
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.
lgtm!
Co-authored-by: Andrew <15331990+ahuang11@users.noreply.github.com>
Co-authored-by: Andrew <15331990+ahuang11@users.noreply.github.com>
Co-authored-by: Andrew <15331990+ahuang11@users.noreply.github.com>
Co-authored-by: Andrew <15331990+ahuang11@users.noreply.github.com>
Co-authored-by: Andrew <15331990+ahuang11@users.noreply.github.com>
Co-authored-by: Andrew <15331990+ahuang11@users.noreply.github.com>
Co-authored-by: Andrew <15331990+ahuang11@users.noreply.github.com>
Co-authored-by: Andrew <15331990+ahuang11@users.noreply.github.com>
Co-authored-by: Andrew <15331990+ahuang11@users.noreply.github.com>
Co-authored-by: Andrew <15331990+ahuang11@users.noreply.github.com>
Co-authored-by: Andrew <15331990+ahuang11@users.noreply.github.com>
Co-authored-by: Andrew <15331990+ahuang11@users.noreply.github.com>
Co-authored-by: Andrew <15331990+ahuang11@users.noreply.github.com>
Extends #7248 but solves PrefectHQ/prefect-dask#43 without requiring the changes in PrefectHQ/prefect-dask#45
There is a new
context
dictionary onvisit_collection
. It isNone
by default and ignored. If set, it can be used to store contextual information that persists asvisit_collection
descends into nested items. A shallow copy is used to prevent the changes from leaking "up".This
context
dictionary is populated with an annotation when descending into annotations. Previously,visit_collection
would never descend into annotations. We now explicitly do not parse object within quotes in the engine instead of relying onvisit_collection
to ignore it.Additionally,
visit_collection
now has aremove_annotations: bool = False
setting that is used duringresolve_inputs
to strip annotations from inputs while preserving other behavior i.e. visiting the items within the annotation.Checklist
<link to issue>
"fix
,feature
,enhancement