Skip to content

Commit

Permalink
chore: switch to pixi and install all deps except for gdal from pypi.
Browse files Browse the repository at this point in the history
  • Loading branch information
Taher Chegini committed Jan 9, 2025
1 parent 3e10a9c commit 8b09750
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 183 deletions.
40 changes: 9 additions & 31 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,23 @@ concurrency:

jobs:
test:
name: python ${{ matrix.python-version }}, ${{ matrix.os }}
name: python ${{ matrix.environment }}, ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
REPO_NAME: ${{ github.event.repository.name }}
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
python-version: [3.9, '3.12']
os: [ubuntu-latest, macos-latest, windows-latest]
environment: [test39, test313]

steps:
- uses: actions/checkout@v4
- name: Set environment variables
run: |-
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
- name: Setup micromamba
uses: mamba-org/setup-micromamba@v2
env:
DATE: ${{ steps.date.outputs.time }}
- uses: prefix-dev/[email protected]
with:
environment-file: ci/requirements/environment.yml
environment-name: ${{ env.REPO_NAME }}-tests
create-args: >-
python=${{ matrix.python-version }}
post-cleanup: all
cache-environment: true
cache-environment-key: ${{runner.os}}-${{runner.arch}}-py${{matrix.python-version}}-${{env.DATE}}
- name: Install error reporter
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
run: |
python -m pip install pytest-github-actions-annotate-failures
- name: Install the package
run: |-
python -m pip install --no-deps .
- name: Run pytest
run: |-
pytest --cov --cov-append --cov-branch --cov-report=xml --junitxml=junit.xml
pixi-version: v0.39.5
environments: ${{ matrix.environment }}
activate-environment: ${{ matrix.environment }}
- name: Run pixi
run: pixi r test

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repos:
name: Sort top level statements with ssort

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.0
hooks:
- id: ruff
name: Linting with Ruff
Expand Down
48 changes: 18 additions & 30 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,11 @@ Ready to contribute? Here's how to set up Seamless3DEP for local development.
git remote add upstream [email protected]:hyriver/seamless-3dep.git
```

1. Install your local copy into a virtualenv. Assuming you have `micromamba` installed,
this is how you can set up your fork for local development:
1. Install [Pixi](https://pixi.sh/latest/) then install the development environments:

```console
cd seamless-3dep/
mamba env create -f ci/requirements/environment-dev.yml
mamba activate seamless-3dep-dev
python -m pip install . --no-deps
pixi install -e dev
```

1. Create a branch for local development:
Expand All @@ -136,7 +133,12 @@ Ready to contribute? Here's how to set up Seamless3DEP for local development.
git push
```

1. Now you can make your changes locally, make sure to add a description of the changes to `HISTORY.rst` file and add extra tests, if applicable, to `tests` folder. Also, make sure to give yourself credit by adding your name at the end of the item(s) that you add in the history like this `By Taher Chegini <https://github.com/hyriver>`. Then, fetch the latest updates from the remote and resolve any merge conflicts:
1. Now you can make your changes locally, make sure to add a description of the changes
to `CHANGELOG.md` file based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
and add extra tests, if applicable, to `tests` folder. Also,
make sure to give yourself credit by adding your name at the end of the item(s)
that you add in the history like this `by [Your Name](https://github.com/your_handle)`.
Then, fetch the latest updates from the remote and resolve any merge conflicts:

```console
git fetch upstream
Expand All @@ -146,41 +148,27 @@ Ready to contribute? Here's how to set up Seamless3DEP for local development.
1. Then create a new environment for linting and another for testing:

```console
mamba create -n py11 python=3.11 nox tomli pre-commit codespell gdal
mamba activate py11
nox -s pre-commit
nox -s type-check
mamba create -n py38 python=3.8 nox tomli pre-commit codespell gdal
mamba activate py38
nox -s tests
pixi r lint
pixi r typecheck
pixi r -e test39 test
pixi r -e test313 test
```

Note that if Python 3.11 is already installed on your system, you can skip creating the `py11` environment and just use your system's Python 3.11 to run the linting and type-checking tests, like this:
1. If you are making breaking changes make sure to reflect them in the
documentation, `README.md`, and tests if necessary.

```console
mamba create -n py38 python=3.8 nox tomli pre-commit codespell gdal
mamba activate py38
nox
```

1. If you are making breaking changes make sure to reflect them in the documentation, `README.rst`, and tests if necessary.

1. Commit your changes and push your branch to GitHub. Start the commit message with `ENH:`, `BUG:`, `DOC:` to indicate whether the commit is a new feature, documentation related, or a bug fix. For example:
1. Commit your changes and push your branch to GitHub following
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
specification. For example:

```console
git add .
git commit -m "ENH: A detailed description of your changes."
git commit -m "feat: a detailed description of your changes."
git push origin name-of-your-branch
```

1. Submit a pull request through the GitHub website.

Note that to run a subset of tests you can use:

```console
nox -s tests -- -n=1 -k "test_name1 or test_name2"
```

### Improving The Documentation

Seamless3DEP could always use more documentation, whether as part of the
Expand Down
20 changes: 0 additions & 20 deletions ci/requirements/environment-dev.yml

This file was deleted.

15 changes: 0 additions & 15 deletions ci/requirements/environment.yml

This file was deleted.

32 changes: 23 additions & 9 deletions docs/examples/dem.ipynb

Large diffs are not rendered by default.

73 changes: 0 additions & 73 deletions noxfile.py

This file was deleted.

75 changes: 71 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,35 @@ dynamic = [
dependencies = [
"rasterio",
]

optional-dependencies.dev = [
"geopandas>=1",
"ipykernel",
"ipywidgets",
"pytest",
"pywbt>=0.2.8",
"rasterio>=1.4.3",
"rioxarray",
]
optional-dependencies.docs = [
"black",
"mdx-truly-sane-lists",
"mkdocs",
"mkdocs-jupyter",
"mkdocs-material",
"mkdocstrings-python",
]
optional-dependencies.lint = [
"codespell",
"pre-commit",
]
optional-dependencies.test = [
"coverage[toml]",
"pytest",
"pytest-cov",
"pytest-sugar",
]
optional-dependencies.typecheck = [
"pyright",
]
urls.Changelog = "https://seamless-3dep.readthedocs.io/latest/CHANGELOG"
urls.CI = "https://github.com/hyriver/seamless-3dep/actions"
urls.Homepage = "https://seamless-3dep.readthedocs.io"
Expand All @@ -69,7 +83,7 @@ packages = [
target-version = "py39"
line-length = 100

exclude = [ "__pycache__", "benchmarks" ]
exclude = [ ".pixi", "__pycache__" ]

lint.select = [
# flake8-bugbear
Expand Down Expand Up @@ -185,7 +199,16 @@ skip = "__pycache__,_build,.mypy_cache,.git,./htmlcov,.pixi,pixi.lock,**.ipynb"
ignore-words-list = "gage,gages"

[tool.pytest.ini_options]
addopts = "-v --cov-branch --cov-report=xml --durations=5"
addopts = [
"--import-mode=importlib",
"-v",
"--cov",
"--cov-append",
"--cov-branch",
"--cov-report=xml",
"--junitxml=junit.xml",
"--durations=5",
]
doctest_optionflags = 'NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL NUMBER'
testpaths = [
"tests",
Expand Down Expand Up @@ -231,3 +254,47 @@ reportUntypedFunctionDecorator = false
reportAttributeAccessIssue = false
reportInvalidTypeForm = false
typeCheckingMode = "strict"

[tool.pixi.feature.docs.tasks]
build-docs = "mkdocs build --strict"
docs = "mkdocs serve"

[tool.pixi.project]
channels = [ "conda-forge" ]
platforms = [ "linux-64", "osx-64", "osx-arm64", "win-64" ]

[tool.pixi.pypi-dependencies]
seamless_3dep = { path = ".", editable = true }

[tool.pixi.feature.dev.dependencies]
gdal = "*"

[tool.pixi.feature.test.dependencies]
gdal = "*"

[tool.pixi.feature.py39.dependencies]
python = "~=3.9.0"

[tool.pixi.feature.py313.dependencies]
python = "~=3.13.0"

[tool.pixi.environments]
dev = { features = [ "dev", "py313" ] }
test39 = { features = [ "test", "py39" ] }
test313 = { features = [ "test", "py313" ] }
typecheck = { features = [ "typecheck", "py313" ] }
lint = { features = [ "lint", "py313" ], no-default-feature = true }
docs = { features = [ "docs", "dev", "py313" ] }

[tool.pixi.feature.test.tasks]
test = "pytest"
report = { cmd = [ "coverage", "report" ], depends-on = [ "test" ] }
html = { cmd = [ "coverage", "html" ], depends-on = [ "report" ] }

[tool.pixi.feature.lint.tasks]
lint = "pre-commit run --all-files"
pcupdate = "pre-commit autoupdate"
spell = "codespell -w"

[tool.pixi.feature.typecheck.tasks]
typecheck = "pyright"

0 comments on commit 8b09750

Please sign in to comment.