Skip to content

Commit

Permalink
Migrate to pyproject.toml (#17116)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Streed <desertaxle@users.noreply.github.com>
Co-authored-by: Alex Streed <alex.s@prefect.io>
  • Loading branch information
3 people authored Feb 18, 2025
1 parent 1c38054 commit ed3c9aa
Show file tree
Hide file tree
Showing 57 changed files with 751 additions and 3,849 deletions.
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[codespell]
skip = .git,*.pdf,*.svg,versioneer.py,package-lock.json,_vendor,*.css,.codespellrc,tests/utilities/test_text.py
skip = .git,*.pdf,*.svg,package-lock.json,_vendor,*.css,.codespellrc,tests/utilities/test_text.py
# from https://github.com/PrefectHQ/prefect/pull/10813#issuecomment-1732676130
ignore-regex = .*lazy=\"selectin\"|.*e import Bloc$|America/Nome

Expand Down
8 changes: 0 additions & 8 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ env/
venv/

# Documentation artifacts
docs/
site/

# UI artifacts
src/prefect/server/ui/*
ui/node_modules
ui-v2/

# Databases
*.db
Expand All @@ -50,9 +48,3 @@ dask-worker-space/
# Editors
.idea/
.vscode/

# Other
tests/
compat-tests/
benches/
build/
2 changes: 1 addition & 1 deletion .github/workflows/api-compatibility-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
# Versioneer only generates correct versions with a full fetch
# Versioningit only generates correct versions with a full fetch
fetch-depth: 0
persist-credentials: false
submodules: true
Expand Down
31 changes: 9 additions & 22 deletions .github/workflows/benchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,15 @@ jobs:
persist-credentials: false
fetch-depth: 0

- name: Set up Docker Buildx
if: ${{ matrix.build-docker-images }}
uses: docker/setup-buildx-action@v3
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
driver-opts: image=moby/buildkit:v0.12.5
python-version: "3.12"
enable-cache: true
cache-dependency-glob: "pyproject.toml"

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: UV Cache
uses: actions/cache@v4
id: cache-uv
with:
path: ~/.cache/uv
key: uvcache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements-client.txt', 'requirements.txt', 'requirements-dev.txt') }}

- name: Install packages
run: |
python -m pip install -U uv
uv pip install --upgrade --system -e .[dev]
- name: Install the project
run: uv sync --group benchmark --compile-bytecode

- name: Prepare benchmark comparisons
# Note: We use a "cache" instead of artifacts because artifacts are not available
Expand All @@ -76,7 +63,7 @@ jobs:
- name: Start server
run: |
PREFECT_HOME=$(pwd) prefect server start&
PREFECT_HOME=$(pwd) uv run prefect server start&
PREFECT_API_URL="http://127.0.0.1:4200/api" ./scripts/wait-for-server.py
# TODO: Replace `wait-for-server` with dedicated command
Expand All @@ -103,7 +90,7 @@ jobs:
sanitized_uniquename="${uniquename//[^a-zA-Z0-9_\-]/_}"
PREFECT_API_URL="http://127.0.0.1:4200/api" \
python -m benches \
uv run python -m benches \
--ignore=benches/bench_import.py \
--timeout=180 \
--benchmark-save="${sanitized_uniquename}" \
Expand Down
34 changes: 10 additions & 24 deletions .github/workflows/codspeed-benchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
on:
pull_request:
paths:
- .github/workflows/benchmarks.yaml
- .github/workflows/codspeed-benchmarks.yaml
- .github/workflows/python-tests.yaml
- "src/prefect/**/*.py"
- requirements.txt
Expand Down Expand Up @@ -37,33 +37,19 @@ jobs:
persist-credentials: false
fetch-depth: 0

- name: Set up Docker Buildx
if: ${{ matrix.build-docker-images }}
uses: docker/setup-buildx-action@v3
with:
driver-opts: image=moby/buildkit:v0.12.5

- name: Set up Python 3.12
uses: actions/setup-python@v5
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"

- name: UV Cache
uses: actions/cache@v4
id: cache-uv
with:
path: ~/.cache/uv
key: uvcache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements-client.txt', 'requirements.txt', 'requirements-dev.txt') }}

- name: Install packages
run: |
python -m pip install -U uv
uv pip install --upgrade --system .[dev] pytest-codspeed
uv pip uninstall --system pytest-benchmark
enable-cache: true
cache-dependency-glob: "pyproject.toml"

- name: Install the project
run: uv sync --group benchmark --compile-bytecode

- name: Start server
run: |
PREFECT_HOME=$(pwd) prefect server start&
PREFECT_HOME=$(pwd) uv run prefect server start&
PREFECT_API_URL="http://127.0.0.1:4200/api" ./scripts/wait-for-server.py
# TODO: Replace `wait-for-server` with dedicated command
Expand All @@ -75,7 +61,7 @@ jobs:
PREFECT_API_URL: "http://127.0.0.1:4200/api"
with:
run: >
pytest
uv run pytest
benches/bench_import.py
benches/bench_tasks.py
benches/bench_flows.py::bench_flow_decorator
Expand Down
29 changes: 8 additions & 21 deletions .github/workflows/integration-package-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,33 +62,20 @@ jobs:
with:
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
id: setup_python
- name: Set up uv and Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: UV Cache
# Manually cache the uv cache directory
# until setup-python supports it:
# https://github.com/actions/setup-python/issues/822
uses: actions/cache@v4
id: cache-uv
with:
path: ~/.cache/uv
key: uvcache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles(format('src/integrations/{0}/pyproject.toml', matrix.package)) }}
cache-dependency-glob: "pyproject.toml"

- name: Install dependencies
working-directory: src/integrations/${{ matrix.package }}
# install uv, the package, and bleeding edge prefect
run: |
python -m pip install -U uv
uv pip install --upgrade --system -e .[dev]
uv pip install --upgrade --system -e ../../../
run: uv sync --extra dev

- name: Build dev docker image
if: matrix.package == 'prefect-docker'
run : prefect dev build-image
run : uv run prefect dev build-image

- name: Start redis
if: matrix.package == 'prefect-redis'
Expand All @@ -105,7 +92,7 @@ jobs:
PREFECT_API_DATABASE_CONNECTION_URL: "sqlite+aiosqlite:///./orion-tests.db"
working-directory: src/integrations/${{ matrix.package }}
run: >
pytest tests
uv run pytest tests
--numprocesses auto
--maxprocesses 4
--dist worksteal
Expand All @@ -117,4 +104,4 @@ jobs:
PREFECT_API_DATABASE_CONNECTION_URL: "sqlite+aiosqlite:///./orion-tests.db"
working-directory: src/integrations/${{ matrix.package }}
run: >
pytest tests
uv run pytest tests
29 changes: 8 additions & 21 deletions .github/workflows/markdown-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,36 +74,23 @@ jobs:
persist-credentials: false
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
id: setup_python
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: UV Cache
# Manually cache the uv cache directory
# until setup-python supports it:
# https://github.com/actions/setup-python/issues/822
uses: actions/cache@v4
id: cache-uv
with:
path: ~/.cache/uv
key: uvcache-markdown-tests-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements-client.txt', 'requirements.txt', 'requirements-dev.txt', 'requirements-markdown.txt') }}
cache-dependency-glob: "pyproject.toml"

- name: Install packages
run: |
python -m pip install -U uv
uv pip install --upgrade -r requirements-markdown-tests.txt
uv pip install --upgrade -e '.[dev]'
uv pip uninstall pytest-benchmark
run: uv sync --group markdown-docs

- name: Start server
run: |
PREFECT_HOME=$(pwd) prefect server start&
PREFECT_API_URL="http://127.0.0.1:4200/api" ./scripts/wait-for-server.py
PREFECT_HOME=$(pwd) uv run prefect server start&
PREFECT_API_URL="http://127.0.0.1:4200/api" uv run ./scripts/wait-for-server.py
- name: Run tests
run: >
PREFECT_API_URL="http://127.0.0.1:4200/api" pytest docs/ --markdown-docs -m markdown-docs
PREFECT_API_URL="http://127.0.0.1:4200/api" uv run pytest docs/ --markdown-docs -m markdown-docs
--numprocesses auto
--maxprocesses 6
29 changes: 11 additions & 18 deletions .github/workflows/prefect-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,18 @@ name: Verify prefect-client build

on:
pull_request:
branches:
- main
paths:
- client/*
- src/prefect/**/*.py
- requirements.txt
- requirements-client.txt
- setup.cfg
- pyproject.toml
- .github/workflows/prefect-client.yaml
push:
branches:
- main
paths:
- client/*
- src/prefect/**/*.py
- requirements.txt
- requirements-client.txt
- setup.cfg
- pyproject.toml
- .github/workflows/prefect-client.yaml
workflow_call:
inputs:
Expand All @@ -39,16 +33,15 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
# Versioneer only generates correct versions with a full fetch
fetch-depth: 0
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v5
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: "3.9"
cache: "pip"
cache-dependency-path: "requirements-client.txt"
cache-dependency-glob: "pyproject.toml"

- name: Create a temp dir to stage our build
run: echo "TMPDIR=$(mktemp -d)" >> $GITHUB_ENV
Expand All @@ -59,11 +52,11 @@ jobs:
TMPDIR: ${{ env.TMPDIR }}

- name: Build a binary wheel and a source tarball
run: pip install wheel && python setup.py sdist bdist_wheel
run: uv build
working-directory: ${{ env.TMPDIR }}

- name: Install the built client from the locally built package
run: pip install dist/*.tar.gz
run: uv pip install dist/*.tar.gz
working-directory: ${{ env.TMPDIR }}

- name: Get the version of built `prefect-client`
Expand All @@ -74,14 +67,14 @@ jobs:
id: prefect_client_version

- name: Run the smoke test flow using the built client
run: python client/client_flow.py
run: uv run python client/client_flow.py
working-directory: ${{ env.TMPDIR }}
env:
PREFECT_API_KEY: ${{ secrets.PREFECT_CLIENT_SA_API_KEY }}
PREFECT_API_URL: "https://api.prefect.cloud/api/accounts/9b649228-0419-40e1-9e0d-44954b5c0ab6/workspaces/96bd3cf8-85c9-4545-9713-b4e3c3e03466" # sandbox, prefect-client workspace

- name: Install prefect from source
run: pip install .
run: uv pip install .

- name: Get the version of built `prefect`
run: |
Expand All @@ -97,7 +90,7 @@ jobs:
fi
- name: Run the smoke test flow again with prefect and prefect-client installed
run: python client/client_flow.py
run: uv run python client/client_flow.py
working-directory: ${{ env.TMPDIR }}
env:
PREFECT_API_KEY: ${{ secrets.PREFECT_CLIENT_SA_API_KEY }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/python-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commit }}
# Versioneer only generates correct versions with a full fetch
fetch-depth: 0
persist-credentials: false

Expand Down
Loading

0 comments on commit ed3c9aa

Please sign in to comment.