Skip to content

Commit

Permalink
Merge pull request #287 from cerfacs-globc/enh/setup-cleanup
Browse files Browse the repository at this point in the history
Enh/setup cleanup
  • Loading branch information
bzah authored Dec 21, 2023
2 parents a539e0b + ce669c7 commit aff2858
Show file tree
Hide file tree
Showing 70 changed files with 2,471 additions and 2,133 deletions.
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

0 comments on commit aff2858

Please sign in to comment.