Skip to content

Commit

Permalink
Simplify conda environments and move configs to pyproject.toml (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder committed Jun 22, 2023
1 parent 792cdbd commit 8f46b30
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 139 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
shell: bash -l {0}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11"]
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
Expand Down Expand Up @@ -98,7 +98,10 @@ jobs:

- if: $${{ steps.skip_check.outputs.should_skip != 'true' || steps.cache.outputs.cache-hit != 'true' }}
name: Update environment
run: mamba env update -n xcdat_ci -f conda-env/ci.yml
run: |
mamba env update -n xcdat_ci -f conda-env/ci.yml
# Make sure the Python version in the env matches the current matrix version.
mamba install -c conda-forge python=${{ matrix.python-version }}
- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Install xcdat
Expand Down
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
- id: check-yaml

- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.3.0
hooks:
- id: black

Expand All @@ -30,15 +30,15 @@ repos:
additional_dependencies: [flake8-isort]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.1.1
rev: v1.4.0
hooks:
- id: mypy
args: ["--config=setup.cfg"]
args: ["--config=pyproject.toml"]
additional_dependencies:
[
dask==2023.3.2,
numpy==1.23.5,
pandas==1.5.3,
xarray==2023.3.0,
types-python-dateutil==2.8.19,
dask,
numpy>=1.23.0,
pandas,
xarray>=2023.2.0,
types-python-dateutil,
]
8 changes: 4 additions & 4 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
version: 2

build:
os: "ubuntu-20.04"
tools:
python: "mambaforge-4.10"
os: "ubuntu-20.04"
tools:
python: "mambaforge-4.10"

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand All @@ -19,4 +19,4 @@ formats:
- pdf

conda:
environment: conda-env/readthedocs.yml
environment: conda-env/dev.yml
21 changes: 9 additions & 12 deletions conda-env/ci.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
# Conda xcdat CI/CD environment (used in GH Actions)
# Conda xcdat CI/CD environment (used in GH Actions).
name: xcdat_ci
channels:
- conda-forge
- defaults
dependencies:
# ==================
# Base
# ==================
- python >=3.8
- pip
# Base - required for building the package.
# =========================================
- python >=3.9
- cf_xarray
- cftime
- dask
- esmpy
- lxml
- netcdf4
- numpy
- numpy >=1.23.0 # This version of numpy includes support for Python 3.11.
- pandas
- python-dateutil
- xarray
# Constrained because 0.6.3 breaks with import ESMF
# Source: https://github.com/pangeo-data/xESMF/issues/212
- xesmf >0.6.3
- xarray >=2022.02.0 # This version of Xarray drops support for Python 3.9.
- xgcm
# Optional - enables additional features.
# =========================================
- xesmf >=0.7.0 # Constrained because https://github.com/pangeo-data/xESMF/issues/212.
# Quality Assurance
# ==================
- types-python-dateutil
Expand Down
58 changes: 25 additions & 33 deletions conda-env/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,24 @@ channels:
- conda-forge
- defaults
dependencies:
# ==================
# Base
# ==================
# NOTE: If versions are updated, also `additional_dependencies` list for mypy in `.pre-commit-config.yaml`
- python=3.10.10
- pip=23.0.1
- cf_xarray=0.8.0
- cftime=1.6.2
- dask=2023.3.2
- lxml=4.9.2
- netcdf4=1.6.3
- numpy=1.23.5
- pandas=1.5.3
- python-dateutil=2.8.2
- xarray=2023.4.2
- xgcm=0.8.0
# ==================
# Optional
# ==================
- xesmf=0.7.0
- matplotlib-base=3.7.1
# Base - required for building the package.
# =========================================
- python >=3.9
- cf_xarray
- cftime
- dask
- lxml
- netcdf4
- numpy >=1.23.0 # This version of numpy includes support for Python 3.11.
- pandas
- python-dateutil
- xarray >=2022.02.0 # This version of Xarray drops support for Python 3.9.
- xgcm
# Optional - enables additional features.
# =========================================
- xesmf >=0.7.0 # Constrained because https://github.com/pangeo-data/xESMF/issues/212.
- matplotlib-base >=3.7.0
- nc-time-axis=1.4.1
# ==================
# Documentation
# ==================
- sphinx=5.3.0
Expand All @@ -37,25 +32,22 @@ dependencies:
- pandoc=3.1.1
- ipython=8.11.0 # Required for nbsphinx syntax highlighting
- gsw-xarray=0.3.0 # Required for vertical regridding example
# ==================
# Quality Assurance
# ==================
# NOTE: If versions are updated, also update 'rev' in `.pre-commit.config.yaml`
- black=23.1.0
- types-python-dateutil
# NOTE: If the tools below are updated, also update their 'rev' in `.pre-commit.config.yaml`
- black=23.3.0
- flake8=6.0.0
- flake8-isort=6.0.0
- isort=5.12.0
- mypy=1.1.1
- mypy=1.4.0
- pre-commit=3.2.0
- types-python-dateutil=2.8.19
# ==================
# Testing
# ==================
- pytest=7.2.2
- pytest-cov=4.0.0
# ==================
- pytest
- pytest-cov
# Developer Tools
# ==================
- jupyterlab=3.6.2
- tbump=6.9.0
- jupyterlab
- tbump
prefix: /opt/miniconda3/envs/xcdat_dev
41 changes: 0 additions & 41 deletions conda-env/readthedocs.yml

This file was deleted.

25 changes: 25 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,28 @@ exclude = '''
)/
)
'''

[tool.isort]
# Docs: https://pycqa.github.io/isort/docs/configuration/options.html#example-pyprojecttoml_4
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
line_length = 88

[tool.pytest.ini_options]
# Docs: https://docs.pytest.org/en/7.2.x/reference/customize.html#configuration
junit_family = "xunit2"
addopts = "--cov=xcdat --cov-report term --cov-report html:tests_coverage_reports/htmlcov --cov-report xml:tests_coverage_reports/coverage.xml -s"
python_files = ["tests.py", "test_*.py"]
# These markers are defined in `xarray.tests` and must be included to avoid warnings when importing from this module.
markers = ["flaky", "network"]

[tool.mypy]
# Docs: https://mypy.readthedocs.io/en/stable/config_file.html
python_version = 3.10
check_untyped_defs = true
ignore_missing_imports = true
warn_unused_ignores = true
warn_redundant_casts = true
warn_unused_configs = true
40 changes: 1 addition & 39 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[flake8]
# https://pep8.readthedocs.io/en/latest/intro.html#error-codes
# flake8 dooes not support pyproject.toml yet: https://github.com/PyCQA/flake8/issues/234
ignore =
# whitespace before ‘:’
E203
Expand All @@ -23,45 +24,6 @@ exclude =
*__init__.py
venv

[isort]
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88

[pycodestyle]
max-line-length = 119
exclude =
.tox
.git
*/migrations/*
*/static/CACHE/*
docs
node_modules
.idea
.mypy_cache
.pytest_cache
*__init__.py
venv

[mypy]
python_version = 3.10
check_untyped_defs = True
ignore_missing_imports = True
warn_unused_ignores = True
warn_redundant_casts = True
warn_unused_configs = True

[aliases]
# Define setup.py command aliases here
test = pytest

[tool:pytest]
junit_family=xunit2
addopts = --cov=xcdat --cov-report term --cov-report html:tests_coverage_reports/htmlcov --cov-report xml:tests_coverage_reports/coverage.xml -s
python_files = tests.py test_*.py
# These markers are defined in `xarray.tests` and must be included to avoid warnings when importing from this module.
markers =
flaky
network

0 comments on commit 8f46b30

Please sign in to comment.