Skip to content

Commit

Permalink
Merge pull request #13 from Jhsmit/uv_actions
Browse files Browse the repository at this point in the history
use uv for testing and requirements pinning
  • Loading branch information
Jhsmit authored Nov 27, 2024
2 parents 4eb8949 + 87bd05f commit f38e793
Show file tree
Hide file tree
Showing 20 changed files with 5,574 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
- uses: astral-sh/ruff-action@v1
29 changes: 18 additions & 11 deletions .github/workflows/pin_requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,31 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: ["3.9", "3.10"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install pip-tools
run: pip install pip-tools
# Install a specific version of uv.
version: "0.5.4"

- name: Generate requirements file
run: pip-compile --output-file requirements-${{ matrix.os }}-${{ matrix.python-version }}.txt pyproject.toml
run: uv pip compile --all-extras pyproject.toml -o requirements-${{ matrix.os }}-${{ matrix.python-version }}.txt

- name: Upload requirements file
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: req-artifact-${{ matrix.os }}-${{ matrix.python-version }}
path: requirements-${{ matrix.os }}-${{ matrix.python-version }}.txt
merge:
runs-on: ubuntu-latest
needs: generate-requirements
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: requirements
path: requirements-${{ matrix.os }}-${{ matrix.python-version }}.txt
name: all-requirements
pattern: req-artifact-*
35 changes: 16 additions & 19 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,28 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest", "macos-latest" , "windows-latest"]
python-version: ["3.9", "3.10" ]
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
python-version: ["3.10", "3.11", "3.12", "3.13"]
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Set up python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: requirements/requirements-${{ matrix.os }}-${{ matrix.python-version }}.txt

- name: Install pinned requirements
# Install a specific version of uv.
version: "0.5.4"
enable-cache: true
cache-dependency-glob: requirements/requirements-ubuntu-latest-${{ matrix.python-version }}.txt

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/requirements-${{ matrix.os }}-${{ matrix.python-version }}.txt --prefer-binary
- name: Install test requirements
run: pip install .[test]
python -m pip install uv
uv venv -p ${{ matrix.python-version }}
. .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
uv pip install -r requirements/requirements-ubuntu-latest-${{ matrix.python-version }}.txt
uv pip install -e .
- name: Run tests
run: |
Expand Down
4 changes: 2 additions & 2 deletions hdxms_datasets/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ def describe(

output_dict[state] = state_desc

if return_type == str:
if return_type is str:
return yaml.dump(output_dict, sort_keys=False)
elif return_type == dict:
elif return_type is dict:
return output_dict
else:
raise TypeError(f"Invalid return type {return_type!r}")
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ authors = [
]
readme = "README.md"
license = "MIT"
requires-python = ">=3.9"
requires-python = ">=3.10"
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Intended Audience :: Science/Research",
]

Expand Down
Loading

0 comments on commit f38e793

Please sign in to comment.