Skip to content

Commit

Permalink
Switch from Poetry to UV (#137)
Browse files Browse the repository at this point in the history
* Switch from Poetry to UV

Signed-off-by: Fabrice Normandin <[email protected]>

* Fix pre-commit issues, get removesuffix from `str`

Signed-off-by: Fabrice Normandin <[email protected]>

* Remove poetry.lock

Signed-off-by: Fabrice Normandin <[email protected]>

* Add missing uv.lock file

Signed-off-by: Fabrice Normandin <[email protected]>

* Add missing pytest-skip-slow test dependency

Signed-off-by: Fabrice Normandin <[email protected]>

* Fix issue in testing.yml reusable workflow

Signed-off-by: Fabrice Normandin <[email protected]>

* Update codecov action (?)

Getting inconsistent errors in CI, maybe due to a codecov issue?
- Example: https://github.com/mila-iqia/milatools/actions/runs/12419445408/job/34676165915?pr=137
- Issue on the CodeCov action repo: codecov/codecov-action#1580

Signed-off-by: Fabrice Normandin <[email protected]>

---------

Signed-off-by: Fabrice Normandin <[email protected]>
  • Loading branch information
lebrice authored Dec 20, 2024
1 parent be3ce2b commit 63cc24f
Show file tree
Hide file tree
Showing 14 changed files with 885 additions and 1,727 deletions.
49 changes: 23 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,18 @@ jobs:
PLATFORM: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Install poetry (not on MacOS)
if: runner.os != 'macOS'
run: pip install poetry

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
cache: ${{ matrix.platform != 'macos-latest' && 'poetry' || '' }}

- name: Install poetry (only on MacOS)
if: runner.os == 'macOS'
run: pip install poetry

version: "latest"
enable-cache: true
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#github-authentication-token
github-token: ${{ secrets.GITHUB_TOKEN }}
cache-suffix: ${{ matrix.python-version }}
- name: Pin Python version to ${{ matrix.python-version }}
run: uv python pin ${{ matrix.python-version }}
- name: Install dependencies
run: poetry install --with=dev

run: uv sync
- name: Setup passwordless SSH access to localhost for tests
# Adapted from https://stackoverflow.com/a/60367309/6388696
if: runner.os == 'Linux'
Expand All @@ -75,7 +70,7 @@ jobs:
ssh -o 'StrictHostKeyChecking no' localhost id
- name: Test with pytest
run: poetry run pytest --cov=milatools --cov-report=xml --cov-append
run: uv run pytest --cov=milatools --cov-report=xml --cov-append

- name: Store coverage report as an artifact
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -130,19 +125,21 @@ jobs:
chmod og-rw ~
ssh -o 'StrictHostKeyChecking no' localhost id
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}

version: "latest"
enable-cache: true
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#github-authentication-token
github-token: ${{ secrets.GITHUB_TOKEN }}
cache-suffix: ${{ matrix.python-version }}
- name: Pin Python version to ${{ matrix.python-version }}
run: uv python pin ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install --with=dev
run: uv sync

- name: Launch integration tests
run: poetry run pytest --slow --cov=milatools --cov-report=xml --cov-append -vvv --log-level=DEBUG
run: uv run pytest --slow --cov=milatools --cov-report=xml --cov-append -vvv --log-level=DEBUG
timeout-minutes: 15
env:
SLURM_CLUSTER: localhost
Expand Down Expand Up @@ -188,7 +185,7 @@ jobs:
# Next step if this doesn't work would be to give the coverage files a unique name and use merge-multiple: true
path: coverage_reports
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
# file: ./coverage.xml # Search for all coverage files from each workflow.
Expand Down
20 changes: 11 additions & 9 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,22 @@ jobs:
ssh -O check -oStrictHostKeyChecking=no ${{ inputs.cluster }}

- uses: actions/checkout@v4
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ inputs.python-version }}

version: "latest"
enable-cache: true
# https://github.com/astral-sh/setup-uv?tab=readme-ov-file#github-authentication-token
github-token: ${{ secrets.GITHUB_TOKEN }}
cache-suffix: ${{ inputs.python-version }}
- name: Pin Python version to ${{ inputs.python-version }}
run: uv python pin ${{ inputs.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install --with=dev
run: uv sync

- name: Launch integration tests
id: self_hosted_integration_tests
run: poetry run pytest --slow --cov=milatools --cov-report=xml --cov-append -vvv --log-level=DEBUG
run: uv run pytest --slow --cov=milatools --cov-report=xml --cov-append -vvv --log-level=DEBUG
timeout-minutes: ${{ inputs.timeout-minutes }}
env:
SLURM_CLUSTER: ${{ inputs.cluster }}
Expand Down
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ repos:
- id: check-added-large-files
require_serial: true

- repo: https://github.com/python-poetry/poetry
rev: 1.7.0
hooks:
- id: poetry-check
require_serial: true

- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: v0.1.14
Expand Down
2 changes: 1 addition & 1 deletion milatools/cli/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import asyncio
import shutil
from collections.abc import Awaitable
from logging import getLogger as get_logger
from pathlib import PurePosixPath
from typing import Awaitable

from milatools.cli import console
from milatools.cli.init_command import DRAC_CLUSTERS
Expand Down
12 changes: 0 additions & 12 deletions milatools/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,6 @@ def stripped_lines_of(text: str) -> list[str]:
return [line.strip() for line in text.splitlines()]


if sys.version_info < (3, 9):

def removesuffix(s: str, suffix: str) -> str:
"""Backport of `str.removesuffix` for Python<3.9."""
if s.endswith(suffix):
return s[: -len(suffix)]
else:
return s
else:
removesuffix = str.removesuffix


class AllocationFlagsAction(argparse._StoreAction):
def __call__(
self,
Expand Down
2 changes: 1 addition & 1 deletion milatools/utils/parallel_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import asyncio
import functools
from collections.abc import Coroutine
from logging import getLogger as get_logger
from typing import (
Coroutine,
Protocol,
TypedDict,
TypeVar,
Expand Down
2 changes: 1 addition & 1 deletion milatools/utils/vscode_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import subprocess
import sys
import textwrap
from collections.abc import Sequence
from logging import getLogger as get_logger
from pathlib import Path
from typing import Sequence

from milatools.cli.utils import (
CommandNotFoundError,
Expand Down
Loading

0 comments on commit 63cc24f

Please sign in to comment.