Back to Prefect

Prefect recipes

docs/v3/resources/recipes.mdx

3.6.30.dev34.3 KB
Original Source

Prefect recipes are common, extensible examples for setting up Prefect in your execution environment with ready-made ingredients such as Dockerfiles, Terraform files, and GitHub Actions.

These recipes show you how to deploy a worker, use event-driven flows, set up unit testing, and more.

The following recipes are specific to Prefect 2. You can find a full repository of recipes at https://github.com/PrefectHQ/prefect-recipes.

Recipe catalog

Contributing recipes

We're always looking for new recipe contributions. See the Prefect Recipes repository for details about how to add your Prefect recipe, share best practices with fellow Prefect users, and earn some swag.

Prefect recipes provide a cookbook of helpful code examples and common steps for specific Prefect use cases.

Contribute recipes that other Prefect users could benefit from (for example, a Prefect flow that loads data into Snowflake).

Have a blog post or tutorial you'd like to share as a recipe? All submissions are welcome. Clone the prefect-recipes repo, create a branch, add a link to your recipe to the README, and submit a PR.

Steps to add your recipe

How to create a recipe:

bash
# Clone the repository
git clone [email protected]:PrefectHQ/prefect-recipes.git
cd prefect-recipes

# Create and checkout a new branch

git checkout -b new_recipe_branch_name
  1. Add your recipe. Your code may simply be a copy/paste of a single Python file or an entire folder. If you're unsure where to add your file or folder, add it under the flows-advanced/ folder. A Prefect Recipes maintainer will help you find the best place for your recipe. To direct others to a project you made, such as a repo or a blogpost, link to it in the Prefect Recipes README.
  2. (Optional) Write a README.
  3. Include a dependencies file, if applicable.
  4. Push your code and make a PR to the repository.

Common ingredients of a good recipe

  • Easy to understand: Can a user easily follow your recipe? Would a README or code comments help? A simple explanation providing context on how to use the example code is useful, but not required. A good README can set a recipe apart, so check out additional suggestions for README files below.
  • Code and more: Sometimes a use case is best represented in Python code or shell scripts. Sometimes a configuration file is the most important artifact. Think of a Dockerfile or Terraform file for configuring infrastructure.
  • All-inclusive: Share as much code as you can. Even boilerplate code like Dockerfiles or Terraform or Helm files are useful. Just don't share company secrets or IP.
  • Specific: Don't worry about generalizing your code. Other users will extrapolate their own unique solutions from your example.

Tips for a good recipe README

A thoughtful README can take a recipe from good to great. Here are some best practices for a great recipe README:

  • Provide a brief explanation of what your recipe demonstrates. This helps users determine quickly whether the recipe is relevant to their needs or answers their questions.
  • List which files are included and what each is meant to do. Each explanation can contain only a few words.
  • Describe any dependencies and prerequisites (in addition to any dependencies you include in a requirements file). This includes both libraries or modules and any services your recipe depends upon.
  • If steps are involved or there's an order to do things, a simple list of steps is helpful.
  • Bonus: include troubleshooting steps or tips where other users might get tripped up.

Next steps

We hope you'll feel comfortable sharing your Prefect solutions as recipes in the prefect-recipes repo. Collaboration and knowledge sharing are defining attributes of our Prefect Community.

Have questions about sharing or using recipes? Reach out on our active Prefect Slack Community.