Aj Floersch
11/02/2023, 1:06 AMMarvin
11/02/2023, 1:07 AMdeployment = Deployment( name="a-name-you-used", flow_name="name-of-flow" )
deployment.load() # loads server-side settings
Once the existing deployment settings are loaded, you may update them as needed by changing deployment properties. You can view all of the parameters for the Deployment object in the Python API documentation.
Please note that the infrastructure type of your Prefect deployment describes how you want Prefect agents to run flows for the deployment. For example, with DockerContainer infrastructure, the agent will try to use Docker to spin up a new container for each flow run. If you are starting your own container on ACI, you don't need Prefect to do it for you. Specifying process infrastructure on the deployment tells Prefect you want the agent to run flows by starting a process in your ACI container. You can use any storage type as long as you've configured it correctly.
For more details, you can refer to the Prefect documentation.Aj Floersch
11/02/2023, 1:17 AMstorage
attribute would look like. I'm surprised to see it is None
when I configured a git clone pull in the prefect.yaml
on deployment. How does the cloning configuration get related to the Deployment object if not through storage
?Marvin
11/02/2023, 1:17 AMstorage
attribute of the Deployment object in Prefect does not directly relate to the git clone pull configured in the prefect.yaml
file. Instead, the storage
attribute is used for specifying where your flow's code is stored, such as Docker, S3, GCS, etc.
The git clone pull configured in the prefect.yaml
file is part of the deployment process, which is separate from the flow's storage configuration. When you run prefect deploy
, the git clone pull is executed as part of the build process, which prepares your flow for deployment by pulling the latest code from your git repository.
After the build process, the push_to_s3
step is executed, which pushes your built flow to the specified S3 bucket. This is where the storage
attribute comes into play - it tells Prefect where to retrieve your flow's code when it needs to run the flow.
In summary, the git clone pull and the storage
attribute serve different purposes. The git clone pull is part of the build process, which prepares your flow for deployment, while the storage
attribute tells Prefect where to retrieve your flow's code when it needs to run the flow.Aj Floersch
11/02/2023, 1:21 AMstorage
attribute of a Deployment so that it will retrieve the flow code from Github at runtime?Marvin
11/02/2023, 1:22 AMStorage
base class.
Here is a simple example of what a custom Github storage class might look like:
from prefect import Storage
class GithubStorage(Storage):
def __init__(self, repo: str, path: str):
self.repo = repo
self.path = path
def get_flow(self, flow_location: str) -> "Flow":
# Implement logic to retrieve and return flow from Github
You would then use this custom storage class when creating your flow:
flow = Flow('my-flow', storage=GithubStorage(repo='my-repo', path='path/to/flow.py'))
Please note that this is a simplified example and the actual implementation would need to handle authentication with Github and retrieving the flow code from the specified repository and path.
Alternatively, you can store your code in an AWS S3 bucket, Azure Blob Storage container, or GCP GCS bucket and specify the destination directly in the push and pull steps of your prefect.yaml
file. For more details, you can refer to the Prefect documentation.