Skip to content

feat : Add SDK support for YAML-based deployments via deploy_from_yaml#21424

Open
harsh21234i wants to merge 1 commit intoPrefectHQ:mainfrom
harsh21234i:feat/deploy-from-yaml-sdk
Open

feat : Add SDK support for YAML-based deployments via deploy_from_yaml#21424
harsh21234i wants to merge 1 commit intoPrefectHQ:mainfrom
harsh21234i:feat/deploy-from-yaml-sdk

Conversation

@harsh21234i
Copy link
Copy Markdown

Summary

I was exploring this issue and noticed that YAML-based deployments are currently only available through the CLI. This PR adds a simple SDK function deploy_from_yaml so the same thing can be done directly from Python.

What I did

  • Added a new function deploy_from_yaml(path: str)
  • Reused the existing YAML parsing logic from the CLI
  • Created deployments using RunnerDeployment and called .apply()
  • Exposed the function via prefect.deployments

Why this change

Right now, if someone wants to use prefect.yaml inside a Python workflow, they either have to call the CLI or use internal/private methods. This felt like a gap since most of the logic already exists — it just isn’t exposed in the SDK.

This PR basically bridges that gap in a simple way.

Example

from prefect.deployments import deploy_from_yaml

deploy_from_yaml("prefect.yaml")

Notes

  • I reused _load_deploy_configs_and_actions to avoid duplicating parsing logic
  • Used a small DummyConsole to avoid CLI-specific behavior
  • Kept this version minimal (no interactive prompts, build/push steps, etc.)

Future improvements (optional)

  • Move YAML parsing out of CLI into a shared module
  • Support more advanced features like build/push steps
  • Improve async handling

Closes #19503

@github-actions github-actions bot added the enhancement An improvement of an existing feature label Apr 4, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 4, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing harsh21234i:feat/deploy-from-yaml-sdk (8cbedac) with main (31b93ed)

Open in CodSpeed

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.

Client support for prefect.yaml style deployment

1 participant