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

Persist task_run_count using state context #1556

Merged
merged 4 commits into from
Sep 28, 2019
Merged

Conversation

cicdw
Copy link
Member

@cicdw cicdw commented Sep 27, 2019

Thanks for contributing to Prefect!

Please describe your work and make sure your PR:

  • adds new tests (if appropriate)
  • updates CHANGELOG.md (if appropriate)
  • updates docstrings for any new functions or function arguments, including 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 introduced state.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 to Scheduled states, as attaching it to other states causes the run count to effectively "freeze" across runs.

Why is this PR important?

Closes #1177

@codecov
Copy link

codecov bot commented Sep 27, 2019

Codecov Report

Merging #1556 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@ -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")
Copy link
Member

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

Copy link
Member Author

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.

@cicdw cicdw merged commit cada526 into master Sep 28, 2019
@cicdw cicdw deleted the more-uses-of-context branch September 28, 2019 00:48
zanieb pushed a commit that referenced this pull request Apr 13, 2022
Social cards for our docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

signals.TRIGGERFAIL leading to retry attemp reset
2 participants