PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
15.97k stars 1.57k forks source link

Add remote flow storage support to `prefect.yaml` deployments #15575

Open trymzet opened 4 hours ago

trymzet commented 4 hours ago

Describe the current behavior

Currently, it's not possible to deploy flows stored in remote storage with the CLI/prefect.yaml (prefect deploy command). This is because even if a pull step is specified in the YAML, Prefect tries to find the file defined in entrypoint before the code is pulled from remote storage, resulting in a FileNotFoundError.

It would be great to have equivalent functionality of the Python SDK's flow.from_source().deploy() available in the CLI.

Describe the proposed behavior

If pull step is specified, Prefect should perform it before trying to apply the deployment. Currently, it seems it makes the assumption that the flow code is also available locally, at the same relative path as in the remote storage.

Example Use

They could eg. store flows in one repository and deployments in another. Or more generally, apply deployments from an environment which doesn't have flows available locally.

Additional context

No response

desertaxle commented 2 hours ago

Thanks for the enhancement request @trymzet!

You're correct; when building the prefect deploy CLI, we assumed that the flow to deploy would always be available locally, but it sounds like that isn't true in the case you're describing. I think an equivalent to .from_source() in YAML-based deployments makes much sense when deployment definitions is stored separately from flow code.

I think one way we could make this flexible is by adding an additional command that allows you to pull code for a deployment before running prefect deploy.

I'm imagining your CI could look something like this:

prefect deployment fetch <deployment_name>
prefect deploy <deployment_name>

This way the prefect deploy CLI doesn't need any changes for this expanded use case.

Let me know what you think, or if you have any other ideas!