Moe
08/28/2024, 7:07 PMfrom prefect import flow
if __name__ == "__main__":
flow.from_source(
source="<https://github.com/prefecthq/demos.git>",
entrypoint="my_gh_workflow.py:repo_info",
).deploy(
name="my-first-deployment",
work_pool_name="my-managed-pool",
cron="0 1 * * *",
)
But what if it's not in main branch but in a feature branch, how to specify it?Marvin
08/28/2024, 7:08 PMflow.from_source()
. However, based on a GitHub issue addressing a similar requirement, it's possible to set the branch by providing options within the deployment configuration.
Here’s an approach using YAML configuration that includes specifying a branch when deploying from a source:
1. Create a prefect.yaml
file for your deployment:
yaml
# prefect.yaml
name: my-first-deployment
prefect-version: 2.0
build: null
push: null
pull:
- prefect.deployments.steps.set_working_directory:
directory: /mnt
- prefect.deployments.steps.git_clone:
repository: <https://github.com/prefecthq/demos.git>
branch: feature-branch-name
- prefect.deployments.steps.set_working_directory:
directory: /mnt/demos
# Update accordingly to your repo structure
deployments:
- name: my-first-deployment
version: null
entrypoint: my_gh_workflow.py:repo_info
work_pool:
name: my-managed-pool
work_queue_name: null
job_variables: {}
schedule:
cron: "0 1 * * *"
2. Run your deployment with the configured YAML:
bash
prefect deploy --name my-first-deployment
Note:
- Make sure to replace feature-branch-name
with the actual branch name you want to deploy from.
- Adjust directories as need based on the repository's file structure when setting the working directory.
For more detailed information, consider having a look at Prefect's CI/CD guide and the prefect.deployments.steps.git_clone step for how to handle git branches in your deployment.
Links:
- https://docs.prefect.io/latest/guides/ci-cd/
- https://github.com/PrefectHQ/prefect/issues/10420
Does that help?