Skip to content

Commit

Permalink
Update uv.lock + CI tweaks + fix pymatgen issue (#6676)
Browse files Browse the repository at this point in the history
Recreate the uv lockfile (`uv.lock`) with a newer uv version that uses an updated resolution strategy.

Previously, it tried to find a version of the package that would be compatible with all supported Python versions, which in turn meant that if a package dropped support for 3.9 for example, we'd be stuck on an old version.
In the new uv version, this is not the case, and uv will try to find the newest version of a package for a given python version.

Incidentally, this also help partly resolve the pymatgen issue, see #6680. The issue has been fixed in a new version of monty package, which however does not support Python 3.9. So in the updated lockfile, the issue is fixed for Python >=3.10.

For Python 3.9, a workaround suggested in materialsproject/pymatgen#4243, and unset the CI environmental variable.
Since this workaround is quite targeted (only in two specific job steps, and only for Python 3.9), I believe this is acceptable, and we will be dropping Python 3.9 support sometimes this year anyway.
  • Loading branch information
danielhollas authored Jan 8, 2025
1 parent 02cbe0c commit 1093026
Show file tree
Hide file tree
Showing 5 changed files with 1,449 additions and 925 deletions.
19 changes: 10 additions & 9 deletions .github/actions/install-aiida-core/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ inputs:
default: '3.9' # Lowest supported version
required: false
extras:
description: aiida-core extras (including brackets)
default: ''
description: list of optional dependencies
# NOTE: The default 'pre-commit' extra recursively contains
# other extras needed to run the tests.
default: pre-commit
required: false
# NOTE: Hard-learned lesson: we cannot use type=boolean here, apparently :-(
# https://stackoverflow.com/a/76294014
# NOTE2: When installing from lockfile, aiida-core and its dependencies
# are installed in a virtual environment located in .venv directory.
# Subsuquent jobs steps must either activate the environment or use `uv run`
from-lock:
description: Install aiida-core dependencies from a uv lock file
description: Install aiida-core dependencies from uv lock file
default: 'true'
required: false

Expand All @@ -29,19 +31,18 @@ runs:
python-version: ${{ inputs.python-version }}

- name: Set up uv
uses: astral-sh/setup-uv@v4
uses: astral-sh/setup-uv@v5
with:
version: 0.5.6
version: 0.5.x
python-version: ${{ inputs.python-version }}

- name: Install dependencies from uv lock
if: ${{ inputs.from-lock == 'true' }}
# NOTE: We're asserting that the lockfile is up to date
# NOTE2: 'pre-commit' extra recursively contains other extras
# needed to run the tests.
run: uv sync --locked --extra pre-commit
run: uv sync --locked ${{ inputs.extras && format('--extra {0}', inputs.extras) || '' }}
shell: bash

- name: Install aiida-core
if: ${{ inputs.from-lock != 'true' }}
run: uv pip install --system -e .${{ inputs.extras }}
run: uv pip install -e .${{ inputs.extras }}
shell: bash
19 changes: 14 additions & 5 deletions .github/workflows/ci-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,22 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Setup environment
# Note: The virtual environment in .venv was created by uv in previous step
run: source .venv/bin/activate && .github/workflows/setup.sh
run: .github/workflows/setup.sh

- name: Run test suite
env:
AIIDA_TEST_PROFILE: test_aiida
AIIDA_WARN_v3: 1
# Python 3.12 has a performance regression when running with code coverage
# NOTE1: Python 3.12 has a performance regression when running with code coverage
# so run code coverage only for python 3.9.
run: uv run pytest -n auto --db-backend psql -m 'not nightly' tests/ ${{ matrix.python-version == '3.9' && '--cov aiida' || '' }}
# NOTE2: Unset CI envvar to workaround a pymatgen issue for Python 3.9
# https://github.com/materialsproject/pymatgen/issues/4243
# TODO: Remove a workaround for VIRTUAL_ENV once the setup-uv action is updated
# https://github.com/astral-sh/setup-uv/issues/219
run: |
${{ matrix.python-version == '3.9' && 'unset CI' || '' }}
${{ matrix.python-version == '3.9' && 'VIRTUAL_ENV=$PWD/.venv' || '' }}
pytest -n auto --db-backend psql -m 'not nightly' tests/ ${{ matrix.python-version == '3.9' && '--cov aiida' || '' }}
- name: Upload coverage report
if: matrix.python-version == 3.9 && github.repository == 'aiidateam/aiida-core'
Expand Down Expand Up @@ -122,7 +128,10 @@ jobs:
uses: ./.github/actions/install-aiida-core
with:
python-version: '3.12'
from-lock: 'false'
from-lock: 'true'
# NOTE: The `verdi devel check-undesired-imports` fails if
# the 'tui' extra is installed.
extras: ''

- name: Run verdi tests
run: |
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
schedule:
- cron: 30 02 * * * # nightly build

env:
FORCE_COLOR: 1

# https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
# only cancel in-progress jobs or runs for the current workflow - matches against branch & tags
Expand All @@ -32,18 +35,18 @@ jobs:
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.11'

- name: Set up uv
uses: astral-sh/setup-uv@v4
uses: astral-sh/setup-uv@v5
with:
version: 0.5.6
version: 0.5.x

- name: Install utils/ dependencies
run: uv pip install --system -r utils/requirements.txt

- name: Validate uv lockfile
run: uv lock --locked
run: uv lock --check

- name: Validate conda environment file
run: python ./utils/dependency_management.py validate-environment-yml
Expand Down Expand Up @@ -208,4 +211,11 @@ jobs:
env:
AIIDA_TEST_PROFILE: test_aiida
AIIDA_WARN_v3: 1
run: pytest -n auto --db-backend psql tests -m 'not nightly' tests/
# Unset CI envvar to workaround a pymatgen issue for Python 3.9
# https://github.com/materialsproject/pymatgen/issues/4243
# TODO: Remove a workaround for VIRTUAL_ENV once the setup-uv action is updated
# https://github.com/astral-sh/setup-uv/issues/219
run: |
${{ matrix.python-version == '3.9' && 'unset CI' || '' }}
${{ matrix.python-version == '3.9' && 'VIRTUAL_ENV=$PWD/.venv' || '' }}
pytest -n auto --db-backend psql tests -m 'not nightly' tests/
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,13 @@ repos:
- id: check-uv-lock
name: Check uv lockfile up to date
# NOTE: This will not automatically update the lockfile
entry: uv lock --locked
entry: uv lock --check
language: system
pass_filenames: false
files: >-
(?x)^(
pyproject.toml|
uv.lock|
)$
- id: generate-conda-environment
Expand Down
Loading

0 comments on commit 1093026

Please sign in to comment.