Skip to content

Commit

Permalink
Merge pull request #57 from climate-resource/run-drop-out-half-degree
Browse files Browse the repository at this point in the history
Run: drop out half degree resolution
  • Loading branch information
znichollscr authored Aug 8, 2024
2 parents 51e4d99 + 5af7635 commit dfab00f
Show file tree
Hide file tree
Showing 101 changed files with 39,182 additions and 7,277 deletions.
59 changes: 11 additions & 48 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,20 @@
name: "Setup Python and Poetry"
description: "setup Python and Poetry with caches"
name: "Setup Python and pixi"
description: "setup Python and pixi with caches"

inputs:
python-version:
description: "Python version to use"
pixi-environments:
description: "Pixi environment(s) to install (use a space to separate multiple environments)"
required: true
venv-id:
description: "ID to identify cached environment (should be unique from other steps)"
required: true
poetry-dependency-install-flags:
description: "Flags to pass to poetry when running `poetry install --no-interaction --no-root`"
required: true
run-poetry-install:
description: "Should we run the poetry install steps"
required: false
default: true


runs:
using: "composite"
steps:
- name: Set up Python ${{ inputs.python-version }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v3
with:
path: ~/.local # the path depends on the OS
key: poetry-2 # increment to reset cache
- name: Install Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
- name: Load cached venv
if: ${{ inputs.run-poetry-install == 'true' }}
id: cached-poetry-dependencies
uses: actions/cache@v3
- name: Install pixi # also includes auto-caching
uses: prefix-dev/[email protected]
with:
path: .venv
key: "venv-${{ inputs.venv-id }}-${{ inputs.python-version }}-${{ hashFiles('**/poetry.lock') }}"
# Install dependencies first so that our package doesn't appear in the cache by accident
- name: Install dependencies
if: ${{ inputs.run-poetry-install == 'true' }}
shell: bash
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry env use ${{ inputs.python-version }}
poetry install --no-interaction --no-root ${{ inputs.poetry-dependency-install-flags }}
# Now run same command but let the package install too
- name: Install package
if: ${{ inputs.run-poetry-install == 'true' }}
shell: bash
run: poetry install --no-interaction ${{ inputs.poetry-dependency-install-flags }}
cache: true
environments: ${{ inputs.pixi-environments }}
# Enforce consistency between the lock file and pyproject.toml
# because this is an application.
locked: true
21 changes: 9 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
python-version: "3.11"
venv-id: "docs"
poetry-dependency-install-flags: "--all-extras --only 'main,dev'"
pixi-environments: "all-dev"
- name: mypy
run: MYPYPATH=stubs poetry run mypy src
run: MYPYPATH=stubs pixi run --frozen -e all-dev mypy src


# Can add non-regression tests in here somewhere too if needed.
# Run those even if the pull request is a draft.
Expand All @@ -37,18 +36,16 @@ jobs:
uses: actions/checkout@v3
- uses: ./.github/actions/setup
with:
python-version: "${{ matrix.python-version }}"
venv-id: "tests-${{ runner.os }}"
poetry-dependency-install-flags: "--all-extras --only 'main,tests,coverage'"
pixi-environments: "tests"
- name: Run regression tests relevant for coverage
run: |
poetry run python scripts/write-config.py
poetry run pytest -s -r a -v src tests --doctest-modules -m "not coverage_breaker" --cov=src --cov-report=term-missing --cov-report=xml
poetry run coverage report
pixi run -e tests python scripts/write-config.py
pixi run -e tests pytest -s -r a -v src tests --doctest-modules -m "not coverage_breaker" --cov=src --cov-report=term-missing --cov-report=xml
pixi run -e tests coverage report
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Run tests that break coverage
run: |
poetry run pytest -s -r a -v tests -m coverage_breaker
pixi run -e tests pytest -s -r a -v tests -m coverage_breaker
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ output-bundles*
# the output bundle anyway)
data

# Pixi stuff
.pixi

# Notebooks (save in .py format for easier tracking, let jupytext do the rest)
*.ipynb

Expand Down
23 changes: 20 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ ci:
autofix_prs: false
autoupdate_schedule: quarterly
autoupdate_branch: pre-commit-autoupdate
# Skip steps that won't run on pre-commit CI for various reasons,
# mostly because they rely on local things.
skip: [
pixi-install,
]

# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.4.0'
hooks:
- id: check-added-large-files
exclude: pixi.lock
- id: check-ast
- id: check-case-conflict
- id: check-json
Expand Down Expand Up @@ -44,7 +50,18 @@ repos:
rev: v0.3.8
hooks:
- id: blackdoc
- repo: https://github.com/python-poetry/poetry
rev: '1.4.2'
- repo: local
hooks:
- id: poetry-check
# pixi doesn't have a lock/check command yet,
# so we just have to run install each time.
# Ok for now
- id: pixi-install
name: pixi-install
entry: pixi install
# Don't use this, we want pixi to run
# and update pixi.lock automatically if it is not up to date,
# rather than just failing and exiting.
# args: ["--locked"]
language: system
require_serial: true
pass_filenames: false
Loading

0 comments on commit dfab00f

Please sign in to comment.