Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b7d5594
Add pyproject.toml for use of uv
izzyknmi Nov 3, 2026
3099e97
Update .pre-commit-config.yaml to use bandit and ruff
izzyknmi Nov 3, 2026
a005416
Add pre-commit and apply the rules
izzyknmi Nov 3, 2026
a4b236e
Add ruff check to sort imports
izzyknmi Nov 3, 2026
476d234
Sort imports on all files
izzyknmi Nov 3, 2026
e837697
Rename workflow
izzyknmi Nov 3, 2026
52332a3
Update workflow
izzyknmi Nov 3, 2026
c44c517
Fix dev dependencies
izzyknmi Nov 3, 2026
c4f1b52
Update uv lock
izzyknmi Nov 3, 2026
87c2d9f
Change black to bandit
izzyknmi Nov 3, 2026
e251d2f
Move what can be moved from setup.py to pyproject.toml
izzyknmi Nov 3, 2026
d98272b
Update readme to mention uv
izzyknmi Nov 3, 2026
c06a2e6
Update readme and contributing files with uv
izzyknmi Nov 3, 2026
5ff1154
Update tests with uv
izzyknmi Nov 3, 2026
1fe364d
Update tests with uv, try 2
izzyknmi Nov 3, 2026
7661b45
Update tests with uv, try 3
izzyknmi Nov 3, 2026
c75872b
Update tests with uv, try 4
izzyknmi Nov 3, 2026
7390cac
Update tests with uv, try 5
izzyknmi Nov 3, 2026
8645d1f
Update tests with uv: try 7, gdal installed after numpy
izzyknmi Nov 4, 2026
4d09a79
Merge branch 'main' into update-to-uv
izzyknmi Nov 4, 2026
012ae58
Format after merge
izzyknmi Nov 4, 2026
8e062f8
Get the testing to trigger
izzyknmi Nov 4, 2026
ad631fc
Update gitignore with test files
izzyknmi Nov 4, 2026
341f9ef
Update bandit to work with pyproject
izzyknmi Nov 4, 2026
2b55918
Add separate GDAL installer that checks local install and adds it to …
izzyknmi Nov 4, 2026
8cfff6a
Add uv run back around bandit in the tests!
izzyknmi Nov 4, 2026
bd6914a
Update GDAL installation for MacOS
izzyknmi Nov 4, 2026
5b91ef8
Lower tolerance on tests. Remove GDAL version from pyproject (oops)
izzyknmi Nov 4, 2026
267e316
Update CONTRIBUTING.rst
izzyknmi Nov 5, 2026
56c255f
Update pyproject.toml
izzyknmi Nov 5, 2026
0cab3dd
Update .github/workflows/test_pysteps.yml
izzyknmi Nov 5, 2026
65fd323
Update test names
izzyknmi Nov 5, 2026
df8a57a
Remove uv.lock from the repo and add it to gitignore
izzyknmi Nov 5, 2026
120a0e2
Revert "Remove uv.lock from the repo and add it to gitignore"
izzyknmi Nov 5, 2026
dc78d90
Merge tests into one workflow
izzyknmi Nov 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions .github/workflows/check_black.yml

This file was deleted.

109 changes: 62 additions & 47 deletions .github/workflows/test_pysteps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,38 @@ on:
# Triggers the workflow on push or pull request events to the master branch
push:
branches:
- v1.x
- main
pull_request:
branches:
- v1.x
- main
branches:
- main

jobs:

formatting_checks:
name: Check formatting
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v7
- name: Install uv
uses: astral-sh/setup-uv@v10.3.3
- name: Sync uv
working-directory: ${{github.workspace}}
run: uv sync --only-dev --frozen
- name: Run bandit
working-directory: ${{github.workspace}}
run: uv run bandit -c pyproject.toml -r .
- name: Run import sorter
working-directory: ${{github.workspace}}
run: uv run --no-sync ruff check
- name: Run ruff
working-directory: ${{github.workspace}}
run: uv run --no-sync ruff format --check

unit_tests:
name: Unit Tests (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: formatting_checks

strategy:
fail-fast: false
Expand All @@ -29,39 +50,18 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

# need headless opencv on Linux, see https://github.com/conda-forge/opencv-feedstock/issues/401
- name: Install mamba and create environment for Linux
if: matrix.os == 'ubuntu-latest'
uses: mamba-org/setup-micromamba@v1
with:
# https://github.com/mamba-org/setup-micromamba/issues/225
micromamba-version: 1.5.10-0
environment-file: ci/ci_test_env.yml
environment-name: test_environment
generate-run-shell: false
create-args: >-
python=${{ matrix.python-version }}
libopencv=*=headless*

- name: Install mamba and create environment (not Linux)
if: matrix.os != 'ubuntu-latest'
uses: mamba-org/setup-micromamba@v1
with:
# https://github.com/mamba-org/setup-micromamba/issues/225
micromamba-version: 1.5.10-0
environment-file: ci/ci_test_env.yml
environment-name: test_environment
generate-run-shell: false
create-args: python=${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v10.3.3

- name: Install pygrib
run: mamba install --quiet pygrib
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
working-directory: ${{github.workspace}}
run: |
sudo apt update
sudo apt install libgdal-dev libproj-dev libhdf5-dev libopencv-dev libeccodes-dev

- name: Install pysteps for MacOS
- name: Install pysteps (MacOS)
if: matrix.os == 'macos-latest'
working-directory: ${{github.workspace}}
env:
Expand All @@ -73,36 +73,51 @@ jobs:
brew update-reset
brew update
gcc-13 --version || brew install gcc@13
pip install .
brew install gdal
uv python install ${{ matrix.python-version }}
uv sync --python ${{ matrix.python-version }} --frozen
bash add_gdal_brew.sh
uv sync --python ${{ matrix.python-version }} --all-extras --frozen

- name: Install pysteps
if: matrix.os != 'macos-latest'
- name: Install pysteps (Linux)
if: matrix.os == 'ubuntu-latest'
working-directory: ${{github.workspace}}
run: pip install .
run: |
uv python install ${{ matrix.python-version }}
uv sync --python ${{ matrix.python-version }} --frozen
bash add_gdal.sh
uv sync --python ${{ matrix.python-version }} --all-extras --frozen

- name: Install pysteps (Windows)
if: matrix.os == 'windows-latest'
working-directory: ${{github.workspace}}
run: |
uv python install ${{ matrix.python-version }}
uv sync --python ${{ matrix.python-version }} --frozen
uv sync --python ${{ matrix.python-version }} --extra optional --extra gdal --frozen

- name: Download pysteps data
env:
PYSTEPS_DATA_PATH: ${{github.workspace}}/pysteps_data
working-directory: ${{github.workspace}}/ci
run: python fetch_pysteps_data.py
run: uv run fetch_pysteps_data.py

- name: Check imports
working-directory: ${{github.workspace}}/pysteps_data
run: |
python --version
python -c "import pysteps; print(pysteps.__file__)"
python -c "from pysteps import motion"
python -c "from pysteps.motion import vet"
python -c "from pysteps.motion import proesmans"
uv run python --version
uv run python -c "import pysteps; print(pysteps.__file__)"
uv run python -c "from pysteps import motion"
uv run python -c "from pysteps.motion import vet"
uv run python -c "from pysteps.motion import proesmans"

- name: Run tests and coverage report
working-directory: ${{github.workspace}}/pysteps_data
env:
PYSTEPSRC: ${{github.workspace}}/pysteps_data/pystepsrc
PYSTEPS_REPO_ROOT: ${{github.workspace}}
run: pytest --pyargs pysteps --cov=pysteps --cov-report=xml --cov-report=term -ra
run: uv run pytest --pyargs pysteps --cov=pysteps --cov-report=xml --cov-report=term -ra

- name: Upload coverage to Codecov (Linux only)
- name: Upload coverage to Codecov (Linux)
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v4
env:
Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ doc/_build/
# pyenv
.python-version


# Environments
.env
.venv
Expand Down Expand Up @@ -95,3 +94,11 @@ venv.bak/
# Running local tests
/tmp
/pysteps/tests/tmp/
/aux
/mrms
/nwp
/radar
/saf
pystepsrc
pystepsrc.1
filename
35 changes: 25 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
repos:
- repo: https://github.com/psf/black
rev: 26.1.0
- repo: local
hooks:
- id: black
language_version: python3

- repo: https://github.com/PyCQA/bandit
rev: 1.9.4
- id: run-bandit
name: run-bandit
entry: bandit -c pyproject.toml -r .
language: system
verbose: true
pass_filenames: false
stages: [ pre-commit ]
- repo: local
hooks:
- id: bandit
args: ["-c", "bandit.yaml"]
additional_dependencies: ["bandit[yaml]"]
- id: sort-imports
name: sort-imports
entry: uv run ruff check --fix
language: system
verbose: true
pass_filenames: false
stages: [ pre-commit ]
- repo: local
hooks:
- id: run-ruff
name: run-ruff
entry: uv run ruff format
language: system
verbose: true
pass_filenames: false
stages: [ pre-commit ]
74 changes: 18 additions & 56 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Workflow for code contributions
-------------------------------

We welcome all kinds of contributions, like documentation updates, bug fixes, or new features.
The workflow for the contibutions uses the usual
The workflow for the contributions uses the usual
`GitHub pull-request flow <https://help.github.com/en/articles/github-flow>`_.

If you have ideas for new contributions to the project, feel free to get in touch with the pysteps community on our
Expand Down Expand Up @@ -50,33 +50,20 @@ In a nutshell, the main steps to follow for contributing to pysteps are:
Setting up the Development environment
--------------------------------------

The recommended way to setup up the developer environment is the Anaconda
(commonly referred to as Conda).
Conda quickly installs, runs, and updates packages and their dependencies.
The recommended way to set up the developer environment is with :code:`uv`.
uv quickly installs, runs, and updates packages and their dependencies.
It also allows you to create, save, load, and switch between different environments on your local computer.

Before continuing, Mac OSX users also need to install a more recent compiler.
See instructions `here <https://pysteps.readthedocs.io/en/latest/user_guide/install_pysteps.html#install-osx-users>`__.

The developer environment can be created from the file
`environment_dev.yml <https://github.com/pySTEPS/pysteps/blob/master/environment_dev.yml>`_
in the project's root directory by running the command::
The developer environment can be created by syncing the optional and dev dependencies::

conda env create -f environment_dev.yml

This will create the **pysteps_dev** environment that can be activated using::

conda activate pysteps_dev

Once the environment is activated, the latest version of pysteps can be installed
in development mode, in such a way that the project appears to be installed,
but yet is still editable from the source tree::

pip install -e <path to local pysteps repo>
uv sync --extra optional
Comment thread
kmuehlbauer marked this conversation as resolved.
Resolved

To test if the installation went fine, you can try importing pysteps from the python interpreter by running::

python -c "import pysteps"
uv run python -c "import pysteps"


Fork the repository
Expand Down Expand Up @@ -108,17 +95,15 @@ root::

The pre-commit hooks are scripts executed automatically in every commit to identify simple issues with the code.
When an issue is identified (the pre-commit script exits with non-zero status), the hook aborts the commit and prints the error.
Currently, pysteps only tests that the code to be committed complies with black's format style.
In case that the commit is aborted, you only need to run black in the entire source code.
This can be done by running :code:`black .` or :code:`pre-commit run --all-files`.
The latter is recommended since it indicates if the commit contained any formatting errors (that are automatically corrected).
Black's configuration is stored in the `pyproject.toml` file to ensure that the same configuration is used in every development environment.
This configuration is automatically loaded when black is run from any directory in the
pysteps project.
Currently, PySTEPS only tests that the code to be committed complies with :code:`bandit`, :code:`ruff format` and :code:`ruff`'s import sorter.
In case that the commit is aborted, can run these to try to find the issues::

IMPORTANT: Periodically update the black version used in the pre-commit hook by running::
uv run bandit -c bandit.yaml .
uv run ruff check
uv run ruff format --check

pre-commit autoupdate
This can also be done by running :code:`pre-commit run --all-files`. The latter is recommended since it indicates if the
commit contained any formatting errors (that are automatically corrected).

For more information about git hooks and the pre-commit package, see:

Expand Down Expand Up @@ -146,12 +131,12 @@ We strongly suggest following the
Since PEP8 is a set of recommendations, these are the most important good coding practices for the pysteps project:

* Always use four spaces for indentation (don’t use tabs).
* Max line-length: 88 characters (note that we don't use the PEP8's 79 value). Enforced by `black`.
* Always indent wrapped code for readability. Enforced by `black`.
* Avoid extraneous whitespace. Enforced by `black`.
* Don’t use whitespace to line up assignment operators (=, :). Enforced by `black`.
* Max line-length: 88 characters (note that we don't use the PEP8's 79 value). Enforced by `ruff`.
* Always indent wrapped code for readability. Enforced by `ruff`.
* Avoid extraneous whitespace. Enforced by `ruff`.
* Don’t use whitespace to line up assignment operators (=, :). Enforced by `ruff`.
* Avoid writing multiple statements in the same line.
* Naming conventions should follow the recomendations from
* Naming conventions should follow the recommendations from
the `Google's python style guide <http://google.github.io/styleguide/pyguide.html>`__, summarized as follows:

.. raw:: html
Expand Down Expand Up @@ -273,26 +258,6 @@ For more suggestions on good coding practices for python, check these guidelines
- `Google's python style guide <http://google.github.io/styleguide/pyguide.html>`__
- `PEP8 <https://www.python.org/dev/peps/pep-0008/>`__


**Using Black auto-formatter**

To ensure a minimal style consistency, we use
`black <https://black.readthedocs.io/en/stable/>`__ to auto-format to the source code.
The black configuration used in the pysteps project is defined in the pyproject.toml,
and it is automatically detected by black.

Black can be installed using any of the following::

conda install black

#For the latest version:
conda install -c conda-forge black

pip install black

Check the `official documentation <https://black.readthedocs.io/en/stable/the_black_code_style.html>`__
for more information.

**Docstrings**

Every module, function, or class must have a docstring that describe its
Expand Down Expand Up @@ -450,9 +415,6 @@ Core developers should follow the steps to prepare a new release (version):
the `Python Package Index <https://pypi.org/>`_ (PyPI).
See `Packaging the pysteps project <https://pysteps.readthedocs.io/en/latest/developer_guide/pypi.html#pypi-relase>`__
for a detailed description of this process.
#. Update the conda-forge pysteps-feedstock following this guidelines:
`Updating the conda-forge pysteps-feedstock <https://pysteps.readthedocs.io/en/latest/developer_guide/update_conda_forge.html#update-conda-feedstock>`__


Credits
-------
Expand Down
Loading
Loading