Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Examples tab to docs which indexes PrefectHQ/examples #16966

Merged
merged 5 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,17 @@
],
"version": "v3"
},
{
"group": "Examples",
"pages": [
"v3/examples/index",
"v3/examples/flows",
"v3/examples/deployments",
"v3/examples/infrastructure",
"v3/examples/scripts"
],
"version": "v3"
},
{
"group": "Contribute",
"pages": [
Expand Down Expand Up @@ -1403,6 +1414,10 @@
"name": "APIs & SDK",
"url": "v3/api-ref"
},
{
"name": "Examples",
"url": "v3/examples"
},
{
"name": "Integrations",
"url": "integrations"
Expand Down
15 changes: 15 additions & 0 deletions docs/v3/examples/deployments.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Deployment Examples
sidebarTitle: Deployments
---

The following examples show how to create Prefect [deployments](/v3/deploy/index).
These examples are sourced from the [PrefectHQ/examples](https://github.com/PrefectHQ/examples) repository.

| Example | Description |
|---------|-------------|
| [deploy-docker-existing-image.py](https://github.com/PrefectHQ/examples/blob/main/deploy/deploy-docker-existing-image.py) | Shows how to deploy a flow using an existing Docker image that contains your flow code. |
| [deploy-docker-in-docker.py](https://github.com/PrefectHQ/examples/blob/main/deploy/deploy-docker-in-docker.py) | Demonstrates deploying a flow from inside a Docker container using the container's own image. |
| [deploy-many.py](https://github.com/PrefectHQ/examples/blob/main/deploy/deploy-many.py) | An example of discovering and deploying multiple flows from a directory with customizable patterns. |
| [source-docker.py](https://github.com/PrefectHQ/examples/blob/main/deploy/source-docker.py) | Shows how to deploy a flow in a Prefect-built Docker image with options for registry pushing and platform specification. |
| [source-github.py](https://github.com/PrefectHQ/examples/blob/main/deploy/source-github.py) | Demonstrates deploying a flow directly from a GitHub repository with authentication and scheduling. |
19 changes: 19 additions & 0 deletions docs/v3/examples/flows.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Flow Examples
sidebarTitle: Flows
---

The following examples demonstrate various features and patterns of Prefect [flows](/v3/develop/write-flows).
These examples are sourced from the [PrefectHQ/examples](https://github.com/PrefectHQ/examples) repository.

| Example | Description |
|---------|-------------|
| [hello-world.py](https://github.com/PrefectHQ/examples/blob/main/flows/hello-world.py) | A simple "Hello World" flow demonstrating basic flow creation and execution. |
| [access-run-context.py](https://github.com/PrefectHQ/examples/blob/main/flows/access-run-context.py) | Shows how to access and use flow run context information within flows and tasks. |
| [force-out-of-memory.py](https://github.com/PrefectHQ/examples/blob/main/flows/force-out-of-memory.py) | Demonstrates how to reproduce and diagnose memory issues in flows. |
| [local-concurrency-with-async.py](https://github.com/PrefectHQ/examples/blob/main/flows/local-concurrency-with-async.py) | Implements concurrent API requests using Python's native async capabilities. |
| [local-concurrency-with-task-runner.py](https://github.com/PrefectHQ/examples/blob/main/flows/local-concurrency-with-task-runner.py) | Shows how to achieve concurrency using Prefect's ThreadPoolTaskRunner. |
| [return-custom-state.py](https://github.com/PrefectHQ/examples/blob/main/flows/return-custom-state.py) | Demonstrates returning custom states from tasks, specifically for implementing retry logic. |
| [update-flow-run-state-from-hook.py](https://github.com/PrefectHQ/examples/blob/main/flows/update-flow-run-state-from-hook.py) | Shows how to update flow run states using hooks and the Prefect client. |
| [update-flow-run-tags.py](https://github.com/PrefectHQ/examples/blob/main/flows/update-flow-run-tags.py) | Demonstrates updating flow run tags during execution. |
| [whoami.py](https://github.com/PrefectHQ/examples/blob/main/flows/whoami.py) | A diagnostic flow that logs information about the current execution environment. |
16 changes: 16 additions & 0 deletions docs/v3/examples/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: Code Examples
sidebarTitle: Overview
---

The [PrefectHQ/examples](https://github.com/PrefectHQ/examples) repository contains a collection of examples that you can use to get started with Prefect.

First, clone the repository and set up pre-commit checks.

```bash
git clone https://github.com/PrefectHQ/examples.git
cd examples
uvx pre-commit
```

See the [flows](/v3/examples/flows), [deployments](/v3/examples/deployments), [infrastructure](/v3/examples/infrastructure), and [scripts](/v3/examples/scripts) pages for a brief description of the examples included in the repository.
13 changes: 13 additions & 0 deletions docs/v3/examples/infrastructure.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Infrastructure Examples
sidebarTitle: Infrastructure
---

The following examples demonstrate how to provision and manage Prefect infrastructure using Terraform.
These examples are sourced from the [PrefectHQ/examples](https://github.com/PrefectHQ/examples) repository.

| Example | Description |
|---------|-------------|
| [infra/azure-bucket-sensor/](https://github.com/PrefectHQ/examples/tree/main/infra/azure-bucket-sensor) | Sets up an Azure Storage Account with Event Grid integration to trigger Prefect workflows when new blobs are created. |
| [infra/cross-workspace-events/](https://github.com/PrefectHQ/examples/tree/main/infra/cross-workspace-events) | Demonstrates how to set up event forwarding between different Prefect workspaces using webhooks and automations. |
| [infra/prefect-cloud/](https://github.com/PrefectHQ/examples/tree/main/infra/prefect-cloud) | Creates a basic Prefect Cloud workspace with a service account, work pools, and necessary access controls. |
15 changes: 15 additions & 0 deletions docs/v3/examples/scripts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Script Examples
sidebarTitle: Scripts
---

The following examples demonstrate various utility scripts and automation tools built with the Prefect API.
These examples are sourced from the [PrefectHQ/examples](https://github.com/PrefectHQ/examples) repository.

| Example | Description |
|---------|-------------|
| [create-automation.py](https://github.com/PrefectHQ/examples/blob/main/scripts/create-automation.py) | Creates a Prefect automation that sends email notifications when flow runs fail or crash. Demonstrates block and automation creation via the API. |
| [cross-workspace-flow-runs.py](https://github.com/PrefectHQ/examples/blob/main/scripts/cross-workspace-flow-runs.py) | Lists flow run counts by state and date across all workspaces in an account. Useful for analyzing flow run patterns and workspace usage. |
| [extract-with-dlt.py](https://github.com/PrefectHQ/examples/blob/main/scripts/extract-with-dlt.py) | Shows how to extract Prefect Cloud data (deployments, flows, flow runs) using the dlt (data load tool) library into a DuckDB database. |
| [list-block-versions.py](https://github.com/PrefectHQ/examples/blob/main/scripts/list-block-versions.py) | Displays a table of all block types in a workspace with their versions, creation dates, and checksums. Helpful for auditing block versions. |
| [update-deployment-concurrency-limit.py](https://github.com/PrefectHQ/examples/blob/main/scripts/update-deployment-concurrency-limit.py) | Updates a deployment's concurrency limits via the API. Useful when working with Prefect 2.x installations where direct model updates aren't supported. |