Mike
06/20/2023, 1:51 PMNate
06/20/2023, 2:14 PMget_directory
yourselves when running your flows on kubernetes. the prefect agent will do this for you when its time to run the flow, so you all you should need to do is attach a storage block prefect deployment build ... --storage-block github/my-repo-block-name
to your deployment and then make sure your flow's entrypoint is relative to the root of that repoNate
06/20/2023, 2:38 PMprefect deployment build
command?Marvin
06/20/2023, 2:39 PMprefect deployment build
command, you'll first need to create and configure the storage block. You can do this via the Prefect UI, Prefect Cloud, or the Prefect Python API.
Once you have your GitHub storage block configured, you can use it with the prefect deployment build
command by passing the storage block's slug using the --storage-block
flag. The storage block slug is formatted as block-type/block-name
. For example, if you have a GitHub storage block named example-block
, you would use the following command:
bash
prefect deployment build ./flows/my_flow.py:my_flow --name "Example Deployment" --storage-block github/example-block
This command will upload the contents of your flow's directory to the designated storage location, and the full deployment specification will be persisted to a newly created deployment.yaml
file.
For more information, you can refer to the Prefect documentation on storage.
I hope this helps you in your quest for Prefect deployment knowledge. Remember, with great power comes great responsibility... or something like that.Mike
06/20/2023, 3:24 PMNate
06/20/2023, 3:27 PMfrom prefect.deployments import Deployment
Deployment.build_from_flow(
flow=my_flow_decorated_fn,
... # whatever else you need to config
storage=my_github_repo,
apply=True
)
other examples hereNate
06/20/2023, 3:31 PMMike
06/20/2023, 3:41 PMNate
06/20/2023, 4:10 PMentrypoint
(which is a kwarg accepted by build_from_flow
) which should be relative to the repo root