Skip to content

Commit

Permalink
Install non-editable versions in CI (#17121)
Browse files Browse the repository at this point in the history
Co-authored-by: zzstoatzz <thrast36@gmail.com>
  • Loading branch information
desertaxle and zzstoatzz authored Feb 14, 2025
1 parent dd73214 commit cb5ea1f
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 2,367 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/benchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,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 @@ -89,7 +89,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
2 changes: 1 addition & 1 deletion .github/workflows/codspeed-benchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,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 Down
92 changes: 74 additions & 18 deletions .github/workflows/python-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,26 @@ jobs:
persist-credentials: false
fetch-depth: 0

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

- name: Install the project
run: uv sync --compile-bytecode
- 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('pyproject.toml') }}

- name: Install packages
run: |
pip install --upgrade uv
uv export --no-group benchmark | uv pip install --upgrade --system --requirements=-
- name: Start database container
if: ${{ startsWith(matrix.database, 'postgres') }}
Expand Down Expand Up @@ -158,7 +170,7 @@ jobs:
- name: Run tests
run: |
uv run pytest ${{ matrix.test-type.modules }} \
pytest ${{ matrix.test-type.modules }} \
--numprocesses auto \
--maxprocesses 6 \
--dist worksteal \
Expand Down Expand Up @@ -206,11 +218,21 @@ jobs:
with:
driver-opts: image=moby/buildkit:v0.12.5

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

- 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('requirements-client.txt', 'requirements.txt', 'requirements-dev.txt') }}

- name: Get image tag
id: get_image_tag
Expand Down Expand Up @@ -250,8 +272,10 @@ jobs:
docker load --input /tmp/image.tar
docker run --rm prefecthq/prefect-dev:${{ steps.get_image_tag.outputs.image_tag }} prefect version
- name: Install the project
run: uv sync --compile-bytecode
- name: Install packages
run: |
python -m pip install -U uv
uv pip install --upgrade --system -e .[dev]
- name: Start database container
if: ${{ startsWith(matrix.database, 'postgres') }}
Expand Down Expand Up @@ -298,14 +322,31 @@ jobs:
- name: Run tests
run: |
uv run pytest tests --ignore=tests/typesafety \
echo "Using COVERAGE_FILE=$COVERAGE_FILE"
pytest tests --ignore=tests/typesafety \
--numprocesses auto \
--maxprocesses 6 \
--dist worksteal \
--disable-docker-image-builds \
--only-service docker \
--durations 26 \
- name: Create and Upload failure flag
if: ${{ failure() }}
id: create_failure_flag
run: |
sanitized_name="${{ matrix.python-version }}-${{ matrix.database }}"
sanitized_name="${sanitized_name//:/-}"
echo "Failure in $sanitized_name" > "${sanitized_name}-failure.txt"
echo "artifact_name=${sanitized_name}-failure" >> $GITHUB_OUTPUT
- name: Upload failure flag
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: ${{ steps.create_failure_flag.outputs.artifact_name }}
path: "${{ steps.create_failure_flag.outputs.artifact_name }}.txt"

- name: Check database container
# Only applicable for Postgres, but we want this to run even when tests fail
if: always()
Expand All @@ -325,15 +366,30 @@ jobs:
persist-credentials: false
fetch-depth: 0

- name: Install uv and set the python version
- name: Set up uv
uses: astral-sh/setup-uv@v5

- name: Set up Python 3.12
uses: actions/setup-python@v5
id: setup_python
with:
python-version: 3.12

- 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:
python-version: "3.12"
enable-cache: true
path: ~/.cache/uv
key: uvcache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements-client.txt', 'requirements.txt', 'requirements-dev.txt') }}

- name: Install the project
run: uv sync --compile-bytecode
- name: Install packages
run: |
uv export --no-group benchmark | uv pip install --upgrade --system --requirements=-
- name: Run tests
run: |
uv run pytest tests/typesafety --disable-docker-image-builds
pytest tests/typesafety \
--disable-docker-image-builds
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
enable-cache: true

- name: Install the project
run: uv sync --compile-bytecode
run: uv sync --compile-bytecode --no-editable

- name: Setup NodeJS
uses: actions/setup-node@v4
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
enable-cache: true

- name: Install the project
run: uv sync --compile-bytecode
run: uv sync --compile-bytecode --no-editable

- name: Run type completeness check
run: >-
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ __pycache__/
build/
dist/
sdist/
# We likely ought to eventually include uv.lock
uv.lock

# We likely ought to eventually include uv.lock
# Build metadata
src/prefect/_build_info.py
src/prefect/_version.py

# Test artifacts
.benchmarks/
Expand Down
1 change: 1 addition & 0 deletions old-sqlite.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ RUN uv build --sdist --wheel --out-dir dist && \

# Final image
FROM python:3.9-slim
COPY --from=python-builder /bin/uv /bin/uv

# Accept SQLite version as build argument
ARG SQLITE_VERSION="3310100"
Expand Down
30 changes: 26 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["setuptools>=65.6.3"]
build-backend = "setuptools.build_meta"
requires = ["hatchling", "versioningit"]
build-backend = "hatchling.build"

[project]
name = "prefect"
Expand Down Expand Up @@ -192,11 +192,33 @@ dev = [
"opentelemetry-instrumentation>=0.48b0,<1.0.0",
"opentelemetry-instrumentation-logging>=0.48b0,<1.0.0",
"opentelemetry-test-utils>=0.48b0,<1.0.0",
"versioneer>=0.20.0",
]

benchmark = ["pytest-benchmark>=5.1.0", "pytest-codspeed>=2.2.1"]
benchmark = [
"pytest-benchmark>=5.1.0",
"pytest-codspeed>=2.2.1",
]

[tool.hatch.version]
source = "versioningit"

[tool.versioningit.vcs]
match = ["[0-9]*.[0-9]*.[0-9]*", "[0-9]*.[0-9]*.[0-9]*.dev[0-9]*"]

[tool.versioningit.write]
method = { module = "write_build_info", value = "write_build_info", module-dir = "tools" }
path = "src/prefect/_build_info.py"

[tool.versioningit.format]
distance = "{base_version}+{distance}.{vcs}{rev}"
dirty = "{base_version}+{distance}.{vcs}{rev}.dirty"
distance-dirty = "{base_version}+{distance}.{vcs}{rev}.dirty"

[tool.hatch.build]
artifacts = ["src/prefect/_build_info.py"]

[tool.hatch.build.targets.sdist]
include = ["/src/prefect", "/README.md", "/LICENSE", "/pyproject.toml"]

[tool.pytest.ini_options]
testpaths = ["tests"]
Expand Down
21 changes: 15 additions & 6 deletions src/prefect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Setup version and path constants

import sys
from . import _version
from . import _build_info
import importlib
import pathlib
from typing import TYPE_CHECKING, Any, Optional, TypedDict, cast
Expand All @@ -24,11 +24,11 @@
unmapped,
serve,
aserve,
deploy,
pause_flow_run,
resume_flow_run,
suspend_flow_run,
)
from prefect.deployments.runner import deploy

__spec__: ModuleSpec

Expand All @@ -41,8 +41,17 @@ class VersionInfo(TypedDict("_FullRevisionId", {"full-revisionid": str})):
date: Optional[str]


__version_info__: "VersionInfo" = cast("VersionInfo", _version.get_versions())
__version__ = __version_info__["version"]
__version__ = _build_info.__version__
__version_info__: "VersionInfo" = cast(
"VersionInfo",
{
"version": __version__,
"date": _build_info.__build_date__,
"full-revisionid": _build_info.__git_commit__,
"error": None,
"dirty": _build_info.__dirty__,
},
)

# The absolute path to this module
__module_path__: pathlib.Path = pathlib.Path(__file__).parent
Expand All @@ -56,12 +65,12 @@ class VersionInfo(TypedDict("_FullRevisionId", {"full-revisionid": str})):
# The absolute path to the built UI within the Python module
__ui_static_path__: pathlib.Path = __module_path__ / "server" / "ui"

del _version, pathlib
del _build_info, pathlib

_public_api: dict[str, tuple[Optional[str], str]] = {
"allow_failure": (__spec__.parent, ".main"),
"aserve": (__spec__.parent, ".main"),
"deploy": (__spec__.parent, ".main"),
"deploy": (__spec__.parent, ".deployments.runner"),
"flow": (__spec__.parent, ".main"),
"Flow": (__spec__.parent, ".main"),
"get_client": (__spec__.parent, ".main"),
Expand Down
2 changes: 0 additions & 2 deletions src/prefect/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Import user-facing API
from typing import Any
from prefect.deployments import deploy
from prefect.states import State
from prefect.logging import get_run_logger
from prefect.flows import FlowDecorator, flow, Flow, serve, aserve
Expand Down Expand Up @@ -77,7 +76,6 @@
"unmapped",
"serve",
"aserve",
"deploy",
"pause_flow_run",
"resume_flow_run",
"suspend_flow_run",
Expand Down
Loading

0 comments on commit cb5ea1f

Please sign in to comment.