Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enh/setup cleanup #287

Merged
merged 32 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
852381f
MAINT: Update requirements
Dec 15, 2023
c6987c4
MAINT: Update project structure
Dec 15, 2023
2920ac3
MAINT: Update CI
Dec 18, 2023
738e29e
FIX: doc dependencies
Dec 18, 2023
75d20dc
MAINT: Simplify version number
Dec 18, 2023
06f9917
MAINT: migrate config to ruff
Dec 18, 2023
038aa46
MAINT: Apply ruff format
Dec 18, 2023
fce319c
MAINT: Apply ruff lint autofix
Dec 18, 2023
8f9d58f
MAINT: Fix some lint issues
Dec 18, 2023
587d127
MAINT: More auto fixes
Dec 18, 2023
e9a8a65
MAINT: ruff everywhere
Dec 18, 2023
5bfdda5
MAINT: Lint TODO comments
Dec 19, 2023
b0f3537
MAINT: Fix some more lint issues
Dec 19, 2023
83abd6a
MAINT: Force xarray to read dataset sequentially
Dec 19, 2023
a15a5a9
Merge remote-tracking branch 'origin/master' into enh/setup-cleanup
Dec 19, 2023
0a15df9
[skip ci] DOC: Update coverage
Dec 19, 2023
cf17422
Fix: generated api docstring
Dec 20, 2023
d208da1
MAINT: Fix a few more lint issues
Dec 20, 2023
6c12c67
MAINT: fix lint issues with generated API
Dec 20, 2023
515efcc
MAINT: Lint root __init__
Dec 20, 2023
3e5e7fd
MAINT: more lint fixes
Dec 20, 2023
34c65dc
MAINT: more lint fixes
Dec 20, 2023
6ca2191
MAINT: Lint remaining files
Dec 21, 2023
68e5e2b
Fix: api generation
Dec 21, 2023
fa83249
Fix: logo generation
Dec 21, 2023
8463a89
MAINT: Update ignored lint rules
Dec 21, 2023
bfaea28
MAINT: fix sphinx warnings
Dec 21, 2023
b7971b0
DOC: document changes
Dec 21, 2023
a36584d
MAINT: clean install steps
Dec 21, 2023
88b8e1a
MAINT: Bumpt to 6.6.0
Dec 21, 2023
10fde8c
MAINT: Update raised exception style
Dec 21, 2023
ce669c7
MAINT: Update build script for generated api
Dec 21, 2023
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
47 changes: 23 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ jobs:
# lint is handled by pre-commit ci conf
generate-api:
runs-on: ubuntu-latest
env:
FLIT_ROOT_INSTALL: 1
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install requirements
run: pip install -r requirements.txt
- name: Install icclim
run: python -m pip install -e .
- name: install black
run: pip install black
- name: Install build tools
run: pip install --upgrade pip flit
- name: Install icclim and dev requirements (dev, test and doc)
run: flit install --deps develop
- name: call fun extractor
run: python ./tools/extract-icclim-funs.py icclim/_generated_api.py
- name: run black on generated module
run: black icclim/_generated_api.py
run: python ./tools/extract_icclim_funs.py src/icclim/_generated_api.py
- name: run ruff format on generated module
run: ruff format src/icclim/_generated_api.py
- name: create local ref
run: |
git fetch origin ${{ github.head_ref }}
Expand All @@ -37,29 +37,28 @@ jobs:
- name: commit
run: |
# Stage the file, commit and push
git add icclim/_generated_api.py
git add src/icclim/_generated_api.py
# Ignore error cases
git commit -m "MAINT: Update generated API" || true
git push origin ${{ github.head_ref }}

test:
runs-on: ubuntu-latest
env:
FLIT_ROOT_INSTALL: 1
steps:
# actions/checkout@v2 checkouts to a new merge commit
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install requirements
run: pip install -r requirements.txt
- name: Install pytest-cov
run: pip install pytest-cov
- name: Install icclim
run: python -m pip install -e .
- name: Install build tools
run: pip install --upgrade pip flit
- name: Install icclim and dev requirements (dev, test and doc)
run: flit install --deps develop
- name: Build coverage file
run: |
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=icclim icclim/tests | tee pytest-coverage.txt; ( exit ${PIPESTATUS[0]} )
run: pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=icclim tests/ | tee pytest-coverage.txt; ( exit ${PIPESTATUS[0]} )
- name: Pytest coverage comment
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
Expand Down Expand Up @@ -96,6 +95,8 @@ jobs:

logo-update:
runs-on: ubuntu-latest
env:
FLIT_ROOT_INSTALL: 1
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -104,12 +105,10 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install requirements
run: pip install -r requirements.txt
- name: Install pytest-cov
run: pip install pytest-cov
- name: Install icclim
run: python -m pip install -e .
- name: Install build tools
run: pip install --upgrade pip flit
- name: Install icclim and dev requirements (dev, test and doc)
run: flit install --deps develop
- name: Generate logos
run: |
python ./tools/update_logo_version.py ./doc/source/_static/logo_icclim_colored__base.svg ./doc/source/_static/logo_icclim_colored__displayed.svg
Expand Down
59 changes: 8 additions & 51 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ repos:
hooks:
- id: absolufy-imports
name: absolufy-imports
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
Expand All @@ -20,61 +15,23 @@ repos:
- id: end-of-file-fixer
language_version: python3
- id: check-yaml
- id: check-toml
language_version: python3
- id: debug-statements
language_version: python3
- id: requirements-txt-fixer
language_version: python3
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
language_version: python3
args: ["--target-version", "py37"]
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
hooks:
- id: flake8
language_version: python3
additional_dependencies: ['flake8-rst-docstrings']
args: ['--config=setup.cfg']
- repo: https://github.com/PyCQA/isort
rev: 5.13.0
hooks:
- id: isort
language_version: python3
args: ['--profile', 'black']
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
- id: toml-sort-fix
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.8
hooks:
- id: pydocstyle
language_version: python3
args: ['--convention=numpy', '--match="(?!test_).*\.py"']
- id: ruff
- id: ruff-format
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
hooks:
- id: blackdoc
additional_dependencies: [ 'black==22.3.0' ]
#- repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.910
# hooks:
# - id: mypy
# additional_dependencies: [
# # Type stubs
# types-python-dateutil,
# types-pkg_resources,
# types-PyYAML,
# types-pytz,
# # Dependencies that are typed
# numpy,
# xarray,
# xclim,
# typing-extensions==3.10.0.0,
# ]

ci:
autofix_commit_msg: |
Expand Down
10 changes: 7 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ version: 2

sphinx:
configuration: doc/source/conf.py
fail_on_warning: true

build:
os: "ubuntu-20.04"
os: "ubuntu-22.04"
tools:
python: "3.9"

python:
install:
- requirements: requirements_dev.txt
install:
- method: pip
path: .
extra_requirements:
- "doc"
14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
|logo|
======

|build| |pypi| |black| |docs| |conda| |coverage| |doi|
|build| |pypi| |ruff| |docs| |conda| |coverage| |doi|

icclim is a Python library to compute climate indices.
icclim name stands for index, calculation, climate.
Expand All @@ -15,7 +15,7 @@ From conda-forge: ``conda install -c conda-forge icclim``.

From sources:
- Clone the repository ``git clone https://github.com/cerfacs-globc/icclim.git``
- Install icclim ``python -m setup install``
- Install icclim ``pip install .``

How to use icclim
-----------------
Expand Down Expand Up @@ -68,7 +68,7 @@ For a detailed description of each ECA&D index, please visit: https://www.ecad.e
..
Pytest Coverage Comment:Begin

.. |coverage| image:: https://img.shields.io/badge/Coverage-91%25-brightgreen.svg
.. |coverage| image:: https://img.shields.io/badge/Coverage-86%25-green.svg
:target: https://github.com/cerfacs-globc/icclim/blob/master/README.rst#code-coverage
:alt: Code coverage

Expand All @@ -80,10 +80,6 @@ For a detailed description of each ECA&D index, please visit: https://www.ecad.e
:target: https://icclim.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/python/black
:alt: Python Black

.. |pypi| image:: https://img.shields.io/pypi/v/icclim.svg
:target: https://pypi.python.org/pypi/icclim
:alt: Python Package Index Build
Expand All @@ -104,3 +100,7 @@ For a detailed description of each ECA&D index, please visit: https://www.ecad.e
:target: https://github.com/cerfacs-globc/icclim
:alt: icclim
:width: 200px

.. |ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff
:alt: Ruff
9 changes: 5 additions & 4 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# noqa: INP001
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
Expand All @@ -10,15 +11,15 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
from pathlib import Path

sys.path.insert(0, os.path.abspath("../.."))
import icclim
sys.path.insert(0, Path("../..").resolve())
import icclim # noqa: E402 (import need to be after path update)

# -- Project information -----------------------------------------------------
project = "icclim"
copyright = "2021, CERFACS"
copyright = "2021, CERFACS" # noqa: A001
author = "Christian P."
version = icclim.__version__
release = icclim.__version__
Expand Down
37 changes: 6 additions & 31 deletions doc/source/dev/release_process.rst
Original file line number Diff line number Diff line change
@@ -1,49 +1,24 @@
Release process
===============


#. Make sure all tests pass.
#. Create and checkout a release branch.
#. Update version number of ICCLIM_VERSION in ``icclim/models/constants.py`` and in ``setup.py``.
#. Update version number of icclim in ``src/icclim/__init__.py``.
#. Update release notes in ``doc/source/references/release_notes.rst``.
#. Merge release branch to master with a PR.
#. Clean dist directory content.
#. Create wheel file on master.

.. code-block:: sh

python3 -m setup bdist_wheel

#. Create source archive.

.. code-block:: sh

python3 -m setup sdist

#. Try to upload on testpypi first. ``twine`` must be installed in your env beforehand.

.. code-block:: sh

python3 -m twine upload --repository testpypi dist/*

#. Try to install testpypi version on a clean virtual environment.
#. Create wheel file on master and source archive.

.. code-block:: sh

python3 -m pip install --index-url https://test.pypi.org/simple/ icclim

.. note::

It may fail due to missing dependencies in test.pypi.
In that case, create the environment from icclim environment.yml file to
pull all needed dependencies from conda.

#. Test basic index such as `icclim.su("simple-tasmax-data.nc")`
python3 -m build

#. Upload to pypi for real.
#. Upload to pypi.

.. code-block:: sh

python3 -m twine upload dist/*
flit publish

#. Update conda-forge feedstock at https://github.com/conda-forge/icclim-feedstock

Expand Down
5 changes: 3 additions & 2 deletions doc/source/references/ecad_functions_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ For example to use this new API with the index `su` you can do:

summer_days = icclim.su(in_files=glob.glob("netcdf_files/tasmax*.nc"))

Generated API
-------------
ECAD Generated Functions
------------------------

.. automodule:: icclim._generated_api
:members:
:no-index:

.. rubric:: Functions

Expand Down
2 changes: 1 addition & 1 deletion doc/source/references/generic_functions_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Generic indices/indicators
==========================

icclim 6.0 introduced the concept of generic indices.
This document present the auto-generated functions that were built base on :ref:`GenericIndicatorRegistry`.
This document present the auto-generated functions that were built base on :py:class:`icclim.generic_indices.GenericIndicatorRegistry`.
The are accessible directly from `icclim` namespace.

As an example, you can compute the number of days where a threshold is reached with:
Expand Down
17 changes: 16 additions & 1 deletion doc/source/references/release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Release history
===============

6.6.0 (unreleased)
------------------

* [maint] Migrate from [black, blackdoc, flake8, isort, pyupgrade, pydocstyle] to ruff
* [maint] Migrate from setup.py to pyproject.toml
* [maint] Make readthedocs build fail when there are warnings
* [maint] Fix warnings in doc build
* [maint] Update architecture to have a `src/` and a `tests/` directory at root level
* [maint] Migrate build toolchain from setuptools to flit
* [maint] Remove version number from `constants` module as it was causing the build process to import icclim.
The version number is now statically set in src/icclim/__init__.py
* [maint] Lint code using the more restrictive rules from ruff
* [fix] Force xarray to read dataset sequentially to avoid a netcdf-c threading issue causing seg faults.


6.5.0
-----

Expand Down Expand Up @@ -259,7 +274,7 @@ Release candidates for 5.0 change logs
* [maint] Refactored ecad_functions (removed duplicated code, simplified function signatures...)
* [maint] Refactored IndexConfig to hide some technical knowledge which was leaked to other modules.
* [enh] Made a basic integration of clix-meta yaml to populate the generated docstring for c3s.
* [maint] This makes pyyaml an required dependency of icclim.
* [maint] This makes pyyaml a required dependency of icclim.
* [fix] Fixed an issue with aliasing of "icclim" module and "icclim" package
* [maint] Added some metadata to qualify the ecad_indices and recognize the arguments necessary to compute them.
* [maint] Added readthedocs CI configuration. This is necessary to use python 3.8.
Expand Down
Loading
Loading