Skip to content

Code Review Bench PR #20160 - Add arun_deployment and replace @sync_compatible with @async_dispatch#6

Open
tomerqodo wants to merge 3 commits intobase_pr_20160_20260125_5936from
corrupted_pr_20160_20260125_5936
Open

Code Review Bench PR #20160 - Add arun_deployment and replace @sync_compatible with @async_dispatch#6
tomerqodo wants to merge 3 commits intobase_pr_20160_20260125_5936from
corrupted_pr_20160_20260125_5936

Conversation

@tomerqodo
Copy link

Code Review Bench PR PrefectHQ#20160

Original PR Title: Add arun_deployment and replace @sync_compatible with @async_dispatch
Original PR Description: Related to PrefectHQ#15008

This PR is needed for the Custom Deployment SDK feature (see plans/2026-01-06-custom-deployment-sdks.md).

Summary

  • Add arun_deployment as an explicit async function for running deployments
  • Replace @sync_compatible with @async_dispatch on run_deployment
  • run_deployment now automatically dispatches to arun_deployment in async context
  • Sync context uses SyncPrefectClient directly (no event loop magic)
  • Export arun_deployment from prefect.deployments

Changes

The run_deployment function now uses the @async_dispatch pattern instead of @sync_compatible:

# Async context - dispatches to arun_deployment
async def my_flow():
    flow_run = await run_deployment("my-flow/my-deployment")

# Sync context - runs synchronously with SyncPrefectClient
def my_sync_code():
    flow_run = run_deployment("my-flow/my-deployment")

# Explicit async - can also call arun_deployment directly
async def explicit_async():
    flow_run = await arun_deployment("my-flow/my-deployment")

Backward Compatibility

  • The run_deployment signature is maintained
  • The run_deployment.aio attribute is preserved, pointing to arun_deployment
  • All existing tests continue to pass

🤖 Generated with Claude Code
Original PR URL: PrefectHQ#20160

desertaxle and others added 3 commits January 25, 2026 12:10
This change follows the intent of issue PrefectHQ#15008 to replace implicit
sync/async conversion with explicit, type-safe alternatives.

Changes:
- Add `arun_deployment` as an explicit async function for running deployments
- Replace `@sync_compatible` with `@async_dispatch` on `run_deployment`
- `run_deployment` now dispatches to `arun_deployment` in async context
- Sync context uses `SyncPrefectClient` directly (no event loop magic)
- Export `arun_deployment` from `prefect.deployments`
- Add comprehensive tests for both sync and async behavior

The `run_deployment.aio` attribute is preserved for backward compatibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

2 participants