Skip to content

Commit

Permalink
♻️ switch to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgafni committed Sep 7, 2024
1 parent 740087f commit 42ba550
Show file tree
Hide file tree
Showing 6 changed files with 3,773 additions and 95 deletions.
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
!dagster_ray
!tests
!pyproject.toml
!poetry.lock
!poetry.toml
!uv.lock
!README.md
!.pre-commit-config.yaml
14 changes: 5 additions & 9 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,20 @@ jobs:
os:
- Ubuntu
py:
# - "3.12"
- "3.12"
- "3.11"
- "3.10"
- "3.9"
# - "3.8"
steps:
- name: Setup python for test ${{ matrix.py }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py }}
- uses: actions/checkout@v4
- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Install and configure uv
uses: yezz123/setup-uv@v4
with:
version: 1.8.2
virtualenvs-create: false
virtualenvs-in-project: false
installer-parallel: true
uv-version: "0.1.12"
- uses: azure/[email protected]
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -51,7 +47,7 @@ jobs:
start: false
driver: docker
- name: Install dependencies
run: poetry install --all-extras --sync
run: uv sync --all-extras --frozen
- name: Run tests
env:
PYTEST_KUBERAY_VERSIONS: "1.0.0,1.1.0" # will run tests for all these KubeRay versions
Expand Down
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

53 changes: 15 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,16 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y git jq curl gcc python3-dev libpq-dev wget

# install poetry
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_HOME="/opt/poetry" \
POETRY_NO_INTERACTION=1 \
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv"

ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH" \
POETRY_VERSION=1.8.2 \
POETRY_DYNAMIC_VERSIONING_PLUGIN_VERSION=1.2.0 \
POETRY_DYNAMIC_VERSIONING_COMMANDS=version,build,publish

RUN mkdir "$HOME/opt/" \
&& curl -sSL https://install.python-poetry.org > /tmp/get-poetry.py \
&& python3 /tmp/get-poetry.py \
&& poetry config virtualenvs.create false \
&& mkdir -p /cache/poetry \
&& poetry config cache-dir /cache/poetry \
&& python -m pip install --upgrade pip wheel setuptools \
&& poetry self add "poetry-dynamic-versioning[plugin]=$POETRY_DYNAMIC_VERSIONING_PLUGIN_VERSION"

ARG INSTALLER_PARALLEL=true
RUN poetry config installer.parallel $INSTALLER_PARALLEL

# install uv (https://github.com/astral-sh/uv)
# docs for using uv with Docker: https://docs.astral.sh/uv/guides/integration/docker/
COPY --from=ghcr.io/astral-sh/uv:0.3.4 /uv /bin/uv
# RUN curl -LsSf https://astral.sh/uv/0.3.4/install.sh | sh

ENV UV_SYSTEM_PYTHON=1 \
UV_BREAK_SYSTEM_PACKAGES=true \
UV_CACHE_DIR=/root/.cache/uv


ENV DAGSTER_HOME=/opt/dagster/dagster_home
RUN mkdir -p $DAGSTER_HOME
Expand All @@ -45,10 +28,10 @@ FROM base AS base-prod

WORKDIR /src

COPY pyproject.toml poetry.lock ./
COPY pyproject.toml uv.lock ./

RUN --mount=type=cache,target=/cache/poetry \
poetry install --no-root --only main --all-extras
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --all-extras --no-dev --no-install-project

FROM base-prod AS base-dev

Expand All @@ -63,7 +46,7 @@ RUN --mount=type=cache,target=/cache/downloads \
&& tar -xzC /opt/ -f /cache/downloads/$NODE_PACKAGE.tar.gz

RUN --mount=type=cache,target=/cache/poetry \
poetry install --no-root --only dev --all-extras
uv sync --frozen --all-extras --no-install-project

# -------------------------------------------------------------
FROM base-${BUILD_DEPENDENCIES} AS final
Expand All @@ -72,10 +55,4 @@ FROM base-${BUILD_DEPENDENCIES} AS final
COPY . .

# finally install all our code
RUN poetry install --all-extras

ARG POETRY_DYNAMIC_VERSIONING_BYPASS=unset
ENV POETRY_DYNAMIC_VERSIONING_BYPASS_TMP=$POETRY_DYNAMIC_VERSIONING_BYPASS
RUN if [ $POETRY_DYNAMIC_VERSIONING_BYPASS_TMP != unset ]; \
then export POETRY_DYNAMIC_VERSIONING_BYPASS=$POETRY_DYNAMIC_VERSIONING_BYPASS_TMP && poetry dynamic-versioning; \
fi
RUN uv sync --frozen --all-extras
75 changes: 30 additions & 45 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
[tool.poetry]

[project]
authors = [
{name = "Daniel Gafni", email = "[email protected]"},
]
license = {text = "Apache-2.0"}
requires-python = ">=3.8.1"
dependencies = [
"pyyaml>=4.0.0",
"kubernetes>=20.0.0",
"tenacity>=8.0.0",
"ray[all]>=2.7.0",
"dagster>=1.6.0",
]
name = "dagster-ray"
version = "0.0.0"
description = "Dagster integration library for Ray"
authors = [
"Daniel Gafni <[email protected]>"
]
readme = "README.md"
packages = [{include = "dagster_ray"}]
repository = "https://github.com/danielgafni/dagster-ray"
keywords = [
"dagster",
"ray",
Expand All @@ -23,50 +31,27 @@ classifiers = [
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
]
license = "Apache-2.0"

[tool.poetry.dependencies]
python = ">=3.8.1,<3.13"
pyyaml = ">=4.0.0"
kubernetes = ">=20.0.0" # no idea what's a good lower bound
tenacity = ">=8.0.0"
ray = {extras = ["all"], version = ">=2.7.0"}
dagster = ">=1.6.0"
[project.urls]
repository = "https://github.com/danielgafni/dagster-ray"

[tool.poetry.extras]
kuberay = [
"pyyaml",
"kubernetes",
"python-client",
]

[tool.poetry.group.dev.dependencies]
hypothesis = "^6.77.0"
pytest = "^7.3.1"
ruff = "^0.3.0"
pyright = "^1.1.313"
pre-commit = "^3.3.2"
dagit = "^1.3.9"
pytest-cases = "^3.6.14"
pytest-kubernetes = "^0.3.1"
blacken-docs = "^1.16.0"
[tool.uv]
dev-dependencies = [
"hypothesis<7.0.0,>=6.77.0",
"pytest<8.0.0,>=7.3.1",
"ruff<1.0.0,>=0.3.0",
"pyright<2.0.0,>=1.1.313",
"pre-commit<4.0.0,>=3.3.2",
"dagit<2.0.0,>=1.3.9",
"pytest-cases<4.0.0,>=3.6.14",
"pytest-kubernetes<1.0.0,>=0.3.1",
"blacken-docs<2.0.0,>=1.16.0",
]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry-dynamic-versioning]
enable = true
strict = false
vcs = "git"
style = "pep440"
dirty = true

[tool.poetry-dynamic-versioning.substitution]
files = [
"pyproject.toml",
"dagster_ray/_version.py"
]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.pytest.ini_options]
addopts = "-vvv --capture=no --log-disable=faker"
Expand Down
Loading

0 comments on commit 42ba550

Please sign in to comment.