Yaron Levi
06/23/2024, 9:05 AMMarvin
06/23/2024, 9:05 AMfrom_source() and deploy() functions, and how to configure the steps argument with pip_install_requirements and clone.
### Key Excerpts:
- from_source function:
python
from prefect import flow
from prefect.deployments import Deployment
@flow
def my_flow():
print("Hello, Prefect!")
Deployment.from_source(
source="<https://github.com/prefecthq/demos.git>",
entrypoint="repo_info.py:get_repo_info"
).deploy(
name="my-first-deployment",
work_pool_name="my-managed-pool",
)
In the from_source method, you specify the source of your flow code. You can use various remote storage solutions such as GitHub, Docker images, AWS S3, etc.
- deploy function:
python
Deployment.from_source(
source="<https://github.com/prefecthq/demos.git>",
entrypoint="repo_info.py:get_repo_info"
).deploy(
name="my-first-deployment",
work_pool_name="my-managed-pool",
)
The deploy function is used to specify the deployment's name and the work pool.
### Using steps argument with pip_install_requirements and clone
The steps argument can include actions like pip installation and cloning repositories. Here's an example deployment configuration in YAML:
yaml
build:
- requires: prefect
function: clone
arguments:
repository: "<https://github.com/your-repo.git>"
- requires: prefect
function: pip_install_requirements
arguments:
file: "requirements.txt"
push:
- requires: prefect
function: pip_install_requirements
arguments:
file: "requirements.txt"
- requires: prefect
function: clone
arguments:
repository: "<https://github.com/your-repo.git>"
In the deploy mechanics, when you run prefect deploy in a directory containing prefect.yaml, steps are executed in order from build, push, and then pull sections.
For additional details, refer to these sections of Prefect documentation:
- Deployments
- Deployment configuration
If you need specific examples or further elaboration, feel free to ask!Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by