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

Updates PrefectDistributedFuture to use an event websocket to determine task completion #13763

Merged
merged 11 commits into from
Jun 6, 2024

Conversation

desertaxle
Copy link
Member

@desertaxle desertaxle commented Jun 4, 2024

Example

Flows like this still work (assuming you're running the appropriate task worker):

from prefect.task_runners import PrefectTaskRunner
from prefect import flow

from tasks import square, neg, summation


@flow(task_runner=PrefectTaskRunner())
def example_flow():
    A = square.map(range(10))
    B = neg.map(A)
    total = summation.submit(B)

    return total.result()


if __name__ == "__main__":
    result = example_flow()
    print(result)

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.

src/prefect/futures.py Show resolved Hide resolved
src/prefect/futures.py Outdated Show resolved Hide resolved
@desertaxle desertaxle force-pushed the websocket-distributed-future branch from 8f7493c to 6769bcd Compare June 5, 2024 17:24
Copy link
Contributor

@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is really cool! I really like the idea of using the consumer here

wondering if you ran into any pubsub "backup" that caused us to wait longer than we really should have for the event to trickle through? just thinking through the tradeoffs

Comment on lines +161 to +173
@overload
def get_client(
httpx_settings: Optional[Dict[str, Any]] = None, sync_client: Literal[False] = False
) -> "PrefectClient":
...


@overload
def get_client(
httpx_settings: Optional[Dict[str, Any]] = None, sync_client: Literal[True] = True
) -> "SyncPrefectClient":
...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇

Copy link
Collaborator

@chrisguidry chrisguidry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@desertaxle
Copy link
Member Author

wondering if you ran into any pubsub "backup" that caused us to wait longer than we really should have for the event to trickle through? just thinking through the tradeoffs

Our latency has improved a ton since we removed logs from the rest of the events stream, but it is something that we'll need to keep an eye on.

@desertaxle desertaxle added the enhancement An improvement of an existing feature label Jun 5, 2024
src/prefect/futures.py Outdated Show resolved Hide resolved
@desertaxle desertaxle force-pushed the websocket-distributed-future branch from d1ac6e8 to 40556c7 Compare June 5, 2024 19:53
@desertaxle desertaxle marked this pull request as ready for review June 6, 2024 03:47
@desertaxle desertaxle requested a review from a team as a code owner June 6, 2024 03:47
@desertaxle desertaxle merged commit 0bc4821 into main Jun 6, 2024
27 checks passed
@desertaxle desertaxle deleted the websocket-distributed-future branch June 6, 2024 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants