-
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
Adds as_completed
utility for PrefectFuture
#14641
Conversation
CodSpeed Performance ReportMerging #14641 will not alter performanceComparing Summary
|
…ctHQ/prefect into ascompleted-future-utility
I think this implementation will be good for now, but it looks like futures early in the list will block futures later in the list from being yielded when they are complete until the futures earlier in the list are finished. Could you see if an implementation that would allow the behavior of this utility to not be dependent on the ordering of the passed in futures? I think a callback structure on |
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.
a few stray debug logs that I think need to be removed, and a question
FYI, I think we'll want to support this for the Dask and Ray flavors of |
…ctHQ/prefect into ascompleted-future-utility
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.
nice!
a couple nits and:
maybe we should add a test or two for cases where we throw exceptions / timeout? just to be explicit on what we expect
def as_completed( | ||
futures: List[PrefectFuture], timeout: Optional[float] = None | ||
) -> Generator[PrefectFuture, None]: |
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.
seems pretty elegant to me!
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.
some small nitpicks about tests and duplicated code, the core implementation makes sense to me
Really weird that Ray is behaving strangely; @jeanluciano I don't think we need to optimize for a perfectly reversed output, as there is probably some latency in spinup that is allowing the 5 second sleep to execute faster. Maybe just assert that |
I would keep the Dask test as-is and only change the Ray test, between the two it's decent coverage |
Yeah I thought it had to do with the way I was converting the object ref into a future, but setting the callback on the object ref directly behaves the same way. |
Adds a utility that yields completed futures in order they are completed. Closes #14241
Example
Checklist
maintenance
,fix
,feature
,enhancement
,docs
.<link to issue>
"mint.json
.