-
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
add arun_deployment
#16605
base: main
Are you sure you want to change the base?
add arun_deployment
#16605
Conversation
CodSpeed Performance ReportMerging #16605 will not alter performanceComparing Summary
|
b7259ed
to
dc299b1
Compare
Callable[..., Coroutine[Any, Any, R]], | ||
"classmethod[type[Any], ..., Coroutine[Any, Any, R]]", |
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 is because the sync and async versions of run_deployment
need to take different types of clients. i could make them both Optional[Any]
but thought that would be more unclear and this way it pushes folks who care about typing to use the explicit async one
src/prefect/deployments/flow_runs.py
Outdated
@async_dispatch(arun_deployment) | ||
def run_deployment( | ||
name: Union[str, UUID], | ||
client: Optional["SyncPrefectClient"] = 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.
While this is decorated with @async_dispatch
, I think we might need to only accept PrefectClient
instances. My thinking is that if a SyncPrefectClient
is passed in an async context, then arun_deployment
will fail.
The transition will be a little messy, but I think we can create a sync client internally if one isn't passed and handle a provided async client with run_coro_as_sync
. Once we start warning on async dispatch, we can also start warning on passed async clients so that users know to provide a sync client or use arun_deployment
.
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.
ah that's a great point
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.
hmm the tricky thing about this is that run_coro_as_sync might try to put it in a new thread, which causes "bound to a different even loop" issues 🤔
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.
in the case where an async client is passed to run deployment in a sync context, im not sure how to call those asynchronous methods without running into the bound to a different event loop
... i could just create a new client (which works) but not using the client that was explicitly passed feels wrong
dc299b1
to
010e4cb
Compare
removes
sync_compatible
fromrun_deployment