<@ULVA73B9P> when doing code-based deployments (ex...
# ask-marvin
m
@Marvin when doing code-based deployments (ex: "my_prefect_workflow.deploy(...config here...)"), are any settings carried over from the prefect.yaml file in my project root folder, or from any of my local Prefect config? Or does it only use things explicitly set up within the ".deploy()" call?
m
When doing code-based deployments with Prefect, such as using
my_prefect_workflow.deploy(...config here...)
, the settings are primarily those explicitly defined within the
.deploy()
call. However, the
prefect.yaml
file in your project can define base settings for deployments, procedural steps, and execution environment configurations. This file can influence deployments if your setup references it. The
prefect.yaml
file typically resides in your project's root directory, but with Prefect 3.x, it can be located elsewhere as long as it's referenced correctly. If you want to use a different configuration file, you can specify it with the
--prefect-file
argument in CLI commands. For more details on how
prefect.yaml
affects deployments, see the Prefect documentation on YAML deployments. In summary, while the
.deploy()
call is explicit, the
prefect.yaml
file can provide default configurations unless overridden in your deployment call.
m
@Marvin so if I remove everything from prefect.yaml except for this, I assume I'd need to create a docker image (docker_image = DockerImage(...)), build it (docker_image.build()), push it (docker_image.push()), and then refer to it inside of my_workflow.deploy(); is that correct? This is what I'm talking about when I say "remove everything from prefect.yaml":
Copy code
name: elt
prefect-version: 3.2.0

# build section allows you to manage and build docker images
build: null

# push section allows you to manage if and how this project is uploaded to remote locations
push: null
# pull section allows you to provide instructions for cloning this project in remote locations
pull:
- prefect.deployments.steps.set_working_directory:
    directory: /opt/prefect/elt

# the deployments section allows you to provide configuration for deploying flows
deployments:
m
Yes, your understanding is correct. If you remove the build and push sections from your
prefect.yaml
, you'll need to manage Docker images manually. Here's a concise breakdown of what you would do: 1. Create Docker Image: Use
DockerImage
to define your Docker image configuration.
Copy code
python
   from prefect.infrastructure.docker import DockerImage

   docker_image = DockerImage(...)
2. Build the Image: Execute the build method on your DockerImage instance.
Copy code
python
   docker_image.build()
3. Push the Image: Push the built image to your desired registry.
Copy code
python
   docker_image.push()
4. Deploy Workflow: Reference the Docker image in your deployment call.
Copy code
python
   my_workflow.deploy(infrastructure=docker_image, ...)
By doing this, you are explicitly managing your Docker infrastructure outside of Prefect's automatic configurations. The
prefect.yaml
file you provided focuses on setting the working directory and doesn't handle Docker image management, so manual steps are necessary. For more detailed instructions, you might want to review the Prefect Docker documentation.