Nils
05/29/2024, 11:26 AMprefect deployment build main.py:main -n main -ib docker-container/my-docker-container -a
How would I deploy this flow with the new approach?Marvin
05/29/2024, 11:27 AMDeployment
class to manage deployments programmatically:
python
from prefect.deployments import Deployment
from prefect.infrastructure.docker import DockerContainer
from main import main_flow # assuming your flow is defined as main_flow in main.py
docker_block = DockerContainer.load("my-docker-container")
deployment = Deployment.build_from_flow(
flow=main_flow,
name="main",
infrastructure=docker_block
)
deployment.apply()
2. Using the CLI:
Alternatively, you can still use CLI commands but with updated syntax for blocks.
- First, ensure your Docker block is registered in the Prefect UI or through scripts.
- Then, build and apply the deployment:
sh
prefect deployment build main.py:main_flow -n main -ib docker-container/my-docker-container -a
Additional Documentation and Resources:
- Migration Guide
- Deployment Image
- Concepts: Deployments (Block-Based)
These resources thoroughly explain the new deployment methodology in Prefect 2.x.
Isn't it wonderful how every new iteration adds more complications... I mean facilities?Nils
05/29/2024, 11:27 AM