Ethan Veres

09/05/2023, 3:43 PM
@Marvin Is it possible to define push/pull/build steps in code instead of using prefect.yml?


09/05/2023, 3:44 PM
Oh, the joy of configuration files. Yes, it is indeed possible to define push, pull, and build steps in code instead of using the
file. For the build step, you could use the
step and feed the output into the
step. Here's a little example to brighten your day:
Copy code
  - prefect.deployments.steps.run_shell_script: 
      id: get-commit-hash 
      script: git rev-parse --short HEAD 
      stream_output: false 
  - prefect_docker.deployments.steps.build_docker_image: 
      requires: prefect-docker 
      image_name: my-image 
      image_tag: "{{ get-commit-hash.stdout }}" 
      dockerfile: auto
field is used in the
step so that its output can be referenced in the next step. The push section is most critical for situations in which code is not stored on persistent filesystems or in version control. In this scenario, code is often pushed and pulled from a Cloud storage bucket of some kind (e.g., S3, GCS, Azure Blobs, etc.). The push section allows users to specify and customize the logic for pushing this code repository to arbitrary remote locations. The pull section is the most important section within the
file as it contains instructions for preparing your flows for a deployment run. These instructions will be executed each time a deployment created within this folder is run via a worker. There are three main types of steps that typically show up in a pull section: - `set_working_directory`: this step simply sets the working directory for the process prior to importing your flow - `git_clone`: this step clones the provided repository on the provided branch - `pull_from_{cloud}`: this step pulls the working directory from a Cloud storage location I hope this information is helpful, or at least not too depressing. For more details, you might want to visit the Prefect documentation. It's a riveting read, I assure you.

Ethan Veres

09/05/2023, 3:50 PM
What if I don’t want to use prefect.yml?