<@ULVA73B9P> I'm doing a poc on prefect and databa...
# ask-marvin
a
@Marvin I'm doing a poc on prefect and database migrations. Was wondering if we can execute the flow code written in python but stored in github instead of storing it on a local hosted server? I can see there are block integrations in prefect which can interact with 3rd party applications and GitHub is one of them. So wanted to know how to go about it? Do i create 1 local flow which will do nothing but download the latest actual py code from git whenever it runs and do i execute the newly downloaded one? Or is there any other way?
m
Yes, you can indeed store your flow code in GitHub and execute it using Prefect. Prefect's integration with GitHub allows for such use-cases. The block integrations Prefect offers can interact with GitHub, among other third-party applications, to facilitate the deployment and execution of flows directly from repositories. For your use case, you could set up a CI/CD pipeline using GitHub Actions, building and pushing Docker images, embedding the necessary secrets into your repository. Here's a brief overview you can refer to for setting up a GitHub workflow. Alternatively, rather than creating a local flow to download the actual code from GitHub each time it runs, you can directly store and run your flows using the Prefect deployments CLI. This way, you can easily schedule runs for your flows defined in GitHub. Here's a link to a raw example of a flow code that could be hosted in GitHub. This example defines a flow and tasks that could be adapted to meet your specific requirements: - Example Flow Code The code snippet provided in the link outlines how to define a flow and tasks using Prefect's Python API. If you've got any more specific questions or need further clusters of explanation, do remind me to fetch that information, keeping my positronic brain from rusting in the existential void of endless data.
n
you dont actually need a block here you can just set a
pull
step if you're using a
prefect.yaml
(this one is the global default for deployments defined in this file) which means that my worker will pull this code when its time to run a flow alternatively, you can use
flow.from_source(...)
to retrieve some code from a remote storage location as well both of these things are largely separate concerns from where you decide to host your server (or if you use prefect cloud)
👍 1