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 message for submitted tasks that are not waited #13845

Merged
merged 8 commits into from
Jun 10, 2024

Conversation

desertaxle
Copy link
Member

@desertaxle desertaxle commented Jun 6, 2024

This PR adds a useful help message in cases where tasks can't be started because their parent flow is already completed.

New logged output will look something like this:

09:20:37.219 | ERROR   | Task run 'say_hello_3-6' - Task run was aborted: The enclosing flow must be running to begin task execution.
09:20:37.220 | ERROR   | Task run 'say_hello_3-6' - Finished in state Pending(). Please wait for all submitted tasks to complete before exiting your flow.

Closes #13832

Example

For this script that doesn't wait for submitting tasks:

from prefect import flow, task


@task
def say_hello_3(name):
    return f"Hello {name}!"


@flow
def my_flow():
    for i in range(10):
        say_hello_3.submit(name=range(10))


if __name__ == "__main__":
    my_flow()

New output

09:20:36.566 | INFO    | prefect.engine - Created flow run 'delicate-herring' for flow 'my-flow'
09:20:36.588 | INFO    | Flow run 'delicate-herring' - Submitting task say_hello_3 to thread pool executor...
09:20:36.590 | INFO    | Flow run 'delicate-herring' - Submitting task say_hello_3 to thread pool executor...
09:20:36.590 | INFO    | Flow run 'delicate-herring' - Submitting task say_hello_3 to thread pool executor...
09:20:36.594 | INFO    | Flow run 'delicate-herring' - Submitting task say_hello_3 to thread pool executor...
09:20:36.595 | INFO    | Flow run 'delicate-herring' - Submitting task say_hello_3 to thread pool executor...
09:20:36.596 | INFO    | Flow run 'delicate-herring' - Submitting task say_hello_3 to thread pool executor...
09:20:36.598 | INFO    | Flow run 'delicate-herring' - Submitting task say_hello_3 to thread pool executor...
09:20:36.598 | INFO    | Flow run 'delicate-herring' - Submitting task say_hello_3 to thread pool executor...
09:20:36.598 | INFO    | Flow run 'delicate-herring' - Submitting task say_hello_3 to thread pool executor...
09:20:36.599 | INFO    | Flow run 'delicate-herring' - Submitting task say_hello_3 to thread pool executor...
09:20:36.644 | INFO    | prefect.engine - Created task run 'say_hello_3-8' for task 'say_hello_3'
09:20:37.121 | INFO    | prefect.engine - Created task run 'say_hello_3-6' for task 'say_hello_3'
09:20:37.135 | INFO    | prefect.engine - Created task run 'say_hello_3-7' for task 'say_hello_3'
09:20:37.192 | INFO    | Task run 'say_hello_3-8' - Finished in state Completed()
09:20:37.200 | INFO    | Task run 'say_hello_3-7' - Finished in state Completed()
09:20:37.219 | ERROR   | Task run 'say_hello_3-6' - Task run was aborted: The enclosing flow must be running to begin task execution.
09:20:37.220 | ERROR   | Task run 'say_hello_3-6' - Finished in state Pending(). Please wait for all submitted tasks to complete before exiting your flow.
09:20:37.300 | INFO    | prefect.engine - Created task run 'say_hello_3-1' for task 'say_hello_3'
09:20:37.312 | INFO    | prefect.engine - Created task run 'say_hello_3-3' for task 'say_hello_3'
09:20:37.347 | ERROR   | Task run 'say_hello_3-3' - Task run was aborted: The enclosing flow must be running to begin task execution.
09:20:37.347 | ERROR   | Task run 'say_hello_3-3' - Finished in state Pending(). Please wait for all submitted tasks to complete before exiting your flow.
09:20:37.365 | ERROR   | Task run 'say_hello_3-1' - Task run was aborted: The enclosing flow must be running to begin task execution.
09:20:37.366 | ERROR   | Task run 'say_hello_3-1' - Finished in state Pending(). Please wait for all submitted tasks to complete before exiting your flow.
09:20:37.399 | INFO    | prefect.engine - Created task run 'say_hello_3-4' for task 'say_hello_3'
09:20:37.407 | INFO    | prefect.engine - Created task run 'say_hello_3-5' for task 'say_hello_3'
09:20:37.428 | ERROR   | Task run 'say_hello_3-4' - Task run was aborted: The enclosing flow must be running to begin task execution.
09:20:37.429 | ERROR   | Task run 'say_hello_3-4' - Finished in state Pending(). Please wait for all submitted tasks to complete before exiting your flow.
09:20:37.436 | ERROR   | Task run 'say_hello_3-5' - Task run was aborted: The enclosing flow must be running to begin task execution.
09:20:37.437 | ERROR   | Task run 'say_hello_3-5' - Finished in state Pending(). Please wait for all submitted tasks to complete before exiting your flow.
09:20:37.506 | INFO    | prefect.engine - Created task run 'say_hello_3-2' for task 'say_hello_3'
09:20:37.525 | ERROR   | Task run 'say_hello_3-2' - Task run was aborted: The enclosing flow must be running to begin task execution.
09:20:37.526 | ERROR   | Task run 'say_hello_3-2' - Finished in state Pending(). Please wait for all submitted tasks to complete before exiting your flow.
09:20:37.611 | INFO    | prefect.engine - Created task run 'say_hello_3-0' for task 'say_hello_3'
09:20:37.632 | ERROR   | Task run 'say_hello_3-0' - Task run was aborted: The enclosing flow must be running to begin task execution.
09:20:37.633 | ERROR   | Task run 'say_hello_3-0' - Finished in state Pending(). Please wait for all submitted tasks to complete before exiting your flow.
09:20:37.719 | INFO    | prefect.engine - Created task run 'say_hello_3-9' for task 'say_hello_3'
09:20:37.741 | ERROR   | Task run 'say_hello_3-9' - Task run was aborted: The enclosing flow must be running to begin task execution.
09:20:37.741 | ERROR   | Task run 'say_hello_3-9' - Finished in state Pending(). Please wait for all submitted tasks to complete before exiting your flow.
09:20:37.742 | INFO    | Flow run 'delicate-herring' - Finished in state Completed()

Checklist

  • This pull request references any related issue by including "closes <link to issue>"
    • If no issue exists and your change is not a small fix, please create an issue first.
  • If this pull request adds new functionality, it includes unit tests that cover the changes
  • This pull request includes a label categorizing the change e.g. maintenance, fix, feature, enhancement, docs.

For documentation changes:

  • This pull request includes redirect settings in mint.json for files that are removed or renamed.

For new functions or classes in the Python SDK:

  • This pull request includes helpful docstrings.
  • If a new Python file was added, this pull request contains a stub page in the Python SDK docs and an entry in docs/mint.json navigation.

@desertaxle desertaxle requested a review from a team as a code owner June 6, 2024 21:05
@desertaxle desertaxle marked this pull request as draft June 6, 2024 21:10
@desertaxle desertaxle changed the title Add helpful message when submitted tasks don't start Improved handling for submitted tasks that are not waited Jun 6, 2024
@desertaxle desertaxle changed the title Improved handling for submitted tasks that are not waited Add message for submitted tasks that are not waited Jun 7, 2024
@desertaxle desertaxle marked this pull request as ready for review June 7, 2024 14:44
@desertaxle desertaxle merged commit 522b1db into main Jun 10, 2024
26 checks passed
@desertaxle desertaxle deleted the warn-on-unwaited-submitted-tasks branch June 10, 2024 13:29
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.

Task run '<name>' - Finished in state Pending() when submitting task runs
2 participants