-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Persist task_run_count using state context #1556
Conversation
@@ -280,6 +280,9 @@ def __init__( | |||
): | |||
super().__init__(message=message, result=result, cached_inputs=cached_inputs) | |||
self.start_time = pendulum.instance(start_time or pendulum.now("utc")) | |||
run_count = prefect.context.get("task_run_count") |
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.
This "feels" like a very fragile thing but I can't think of a better way to do it
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.
Yea that's fair; this field is populated in every task runner pipeline step (which is where all state transitions occur), but I understand your point. I think the way to think about it is that this will be populated within a "run context" but not otherwise, and this key is always present within a run context.
Thanks for contributing to Prefect!
Please describe your work and make sure your PR:
CHANGELOG.md
(if appropriate)docs/outline.toml
for API reference docs (if appropriate)Note that your PR will not be reviewed unless all three boxes are checked.
What does this PR change?
This PR persists
task_run_count
within the newly introducedstate.context
attribute for communicating the current run count across multiple state transitions (e.g., Retrying -> Paused -> Resume -> Running -> Failed -> Retrying -> etc.). Note that this PR only attaches this data toScheduled
states, as attaching it to other states causes the run count to effectively "freeze" across runs.Why is this PR important?
Closes #1177