Skip to content

Commit

Permalink
Merge pull request #2 from PrefectHQ/inline-script-deps
Browse files Browse the repository at this point in the history
inline script deps
  • Loading branch information
zzstoatzz authored Feb 5, 2025
2 parents 3610cb6 + d6b89d6 commit 3f64f73
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 2,180 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,7 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# uv stuff
.python-version
uv.lock
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

These are examples that show how to use Prefect. They are intended to be simple starting points rather than complete solutions. We hope that you will find them useful!

> [!IMPORTANT]
> This repository uses [uv](https://docs.astral.sh/uv/) for python environment management.
If you've cloned the repository, you can run any of the examples with `uv run flows/<example_name>.py`, for example:

```bash
uv run flows/hello_world.py
```

If you haven't, you can point `uv run` at the url of the python file, for example:

```bash
uv run https://github.com/PrefectHQ/examples/blob/main/flows/hello_world.py
```



## Development

This repository uses [uv](https://docs.astral.sh/uv/) for dependency management. To set up pre-commit checks, run `uvx pre-commit`.
To set up pre-commit checks, run `uvx pre-commit`.
4 changes: 4 additions & 0 deletions flows/access_run_context.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# /// script
# dependencies = ["prefect"]
# ///

"""
Examples of accessing Prefect's runtime context to get information about the current flow run:
- List the fields in the context
Expand Down
4 changes: 4 additions & 0 deletions flows/force_out_of_memory.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# /// script
# dependencies = ["prefect", "psutil"]
# ///

"""
This script is used to force an out-of-memory error in a Prefect flow.
Expand Down
4 changes: 4 additions & 0 deletions flows/hello_world.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# /// script
# dependencies = ["prefect"]
# ///

"""
A simple flow that says hello.
"""
Expand Down
4 changes: 4 additions & 0 deletions flows/local_concurrency_with_async.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# /// script
# dependencies = ["prefect"]
# ///

"""Implement extract flow using Python native async concurrency"""

import asyncio
Expand Down
4 changes: 4 additions & 0 deletions flows/local_concurrency_with_task_runner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# /// script
# dependencies = ["prefect"]
# ///

"""Implements a data extract flow using task runner concurrency"""

from typing import Any
Expand Down
4 changes: 4 additions & 0 deletions flows/return_custom_state.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# /// script
# dependencies = ["prefect"]
# ///

"""
Demonstrates directly returning a state. In this case, an AwaitingRetry state
which causes a task to be retried after a delay.
Expand Down
4 changes: 4 additions & 0 deletions flows/update_flow_run_state_from_hook.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# /// script
# dependencies = ["prefect"]
# ///

"""
Demonstrates using the client to update flow run state from a hook.
"""
Expand Down
6 changes: 5 additions & 1 deletion flows/update_flow_run_tags.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# /// script
# dependencies = ["prefect"]
# ///

"""
Demonstrates using the client to update flow run tags.
"""

from prefect import flow, get_run_logger, get_client, tags
from prefect import flow, get_client, get_run_logger, tags
from prefect.context import get_run_context


Expand Down
6 changes: 5 additions & 1 deletion flows/whoami.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# /// script
# dependencies = ["prefect"]
# ///

"""
This flow will log information about the current environment. Use it to
diagnose issues with your environment, especially when deploying to
Expand All @@ -18,10 +22,10 @@
```
"""

import sys
import os
import platform
import socket
import sys

import prefect

Expand Down
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ version = "0.1.0"
description = "Examples of how to use Prefect"
readme = "README.md"
requires-python = ">=3.9"
dependencies = [
"prefect-docker>=0.6.1",
"prefect>=3.1.2",
"psutil>=6.1.0",
]

[project.urls]
Code = "https://github.com/PrefectHQ/examples"
2,171 changes: 0 additions & 2,171 deletions uv.lock

This file was deleted.

0 comments on commit 3f64f73

Please sign in to comment.