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

Modernize library and coding conventions #120

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 8 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
name: build

on: [ push, pull_request ]
on:
push:
branches:
- main
pull_request:

jobs:
build:

name: Conda Build with Python${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
defaults:
run:
shell: bash -l {0}
Expand All @@ -24,18 +27,12 @@ jobs:
with:
cache-downloads: true
cache-environment: true
environment-file: environment.yml
environment-file: environment-docs.yml
create-args: >-
conda
python=${{ matrix.python-version }}
- name: Conda and Mamba versions
run: |
conda --version
echo "micromamba: $(micromamba --version)"
- name: Install dependencies
run: |
python -m pip install --no-user --editable "."
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
python -m pip install --no-user --editable ".[dev]"
- name: Lint with flake8
run: make lint
if: matrix.python-version == 3.9
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,6 @@ ENV/

# mypy
.mypy_cache/

# JetBrains
.idea
Empty file removed .gitlab-ci.yml
Empty file.
49 changes: 33 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,49 @@ default_language_version:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: 'setup.cfg'
- id: end-of-file-fixer
exclude: 'setup.cfg'
- id: check-yaml
- id: debug-statements
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
hooks:
- id: pyupgrade
args: [ '--py39-plus' ]
- repo: https://github.com/psf/black
rev: 23.11.0
rev: 24.10.0
hooks:
- id: black
args: ["--target-version", "py37"]
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.0
hooks:
- id: flake8
args: ['--config=setup.cfg']
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.9.0
- id: ruff
args: [ '--fix', '--show-fixes' ]
exclude: 'tests|docs'
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: reorder-python-imports
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
# - id: python-check-blanket-noqa
# - id: python-check-blanket-type-ignore
- id: python-no-eval
- id: python-no-log-warn
- id: python-use-type-annotations
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
hooks:
- id: pyupgrade
- id: blackdoc
additional_dependencies: [ 'black==24.10.0' ]
- id: blackdoc-autoupdate-black
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.4
hooks:
- id: check-github-workflows
- id: check-readthedocs
- repo: meta
hooks:
- id: check-hooks-apply
Expand All @@ -42,5 +59,5 @@ ci:
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: []
skip: [ ]
submodules: false
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ build:
python: "mambaforge-22.9"

conda:
environment: environment.yml
environment: environment-docs.yml

# Optionally set the version of Python and requirements required to build your docs
python:
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Logging
.. code-block:: python

from loguru import logger

logger.warning("This a warning message!")

The mechanism for enabling log reporting in scripts/notebooks using ``loguru`` is as follows:
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##=================================================================================
##
## EXAMPLE USAGE
##
##
## $ docker build -t daops .
## $ mkdir ~/container-outputs
## $ docker run -it \
Expand Down Expand Up @@ -48,7 +48,7 @@ RUN apt-get update && \
ARG mconda=Miniconda3-py311_23.10.0-1-Linux-x86_64.sh
RUN wget https://repo.anaconda.com/miniconda/$mconda && \
bash ./$mconda -b -p $MINICONDA_PREFIX && \
apt-get clean autoremove --yes && \
apt-get clean autoremove --yes && \
rm -fr $MINICONDA_PREFIX/pkgs

# wget -qO- https://micromamba.snakepit.net/api/micromamba/linux-64/latest | tar -xvj bin/micromamba --strip-components=1 && \
Expand Down Expand Up @@ -115,5 +115,3 @@ RUN rm -fr /var/lib/{apt,dpkg,cache,log}
#RUN ROOCS_CONFIG=$config_file $MINICONDA_PREFIX/envs/daops/bin/daops subset --area 0,-10,120,40 \
# --time 2085-01-16/2120-12-16 --levels / --time-components year:2090,2091,2092 \
# --output-dir /tmp --file-namer simple cmip5.output1.MOHC.HadGEM2-ES.rcp85.mon.atmos.Amon.r1i1p1.latest.tas


9 changes: 0 additions & 9 deletions MANIFEST.in

This file was deleted.

5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ servedocs: docs ## compile the docs watching for changes
watchmedo shell-command -p '*.md' -c '$(MAKE) -C docs html' -R -D .

release: dist ## package and upload a release
twine upload dist/*
python -m flit publish

dist: clean ## builds source and wheel package
python setup.py sdist
python setup.py bdist_wheel
python -m flit build
ls -l dist

install: clean ## install the package to the active Python's site-packages
Expand Down
25 changes: 7 additions & 18 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@

daops - data-aware operations
=============================


.. image:: https://img.shields.io/pypi/v/daops.svg
:target: https://pypi.python.org/pypi/daops
:alt: Pypi


:target: https://pypi.python.org/pypi/daops
:alt: PyPI

.. image:: https://github.com/roocs/daops/workflows/build/badge.svg
:target: https://github.com/roocs/daops/actions
:alt: Build Status



.. image:: https://readthedocs.org/projects/daops/badge/?version=latest
:target: https://daops.readthedocs.io/en/latest/?badge=latest
:alt: Documentation
:target: https://daops.readthedocs.io/en/latest/?badge=latest
:alt: Documentation

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

The ``daops`` library (pronounced "day-ops") provides a python interface to a
set of operations suitable for working with climate simulation outputs. It is
Expand All @@ -32,7 +29,6 @@ The data will be loaded and *fixed* using the `xarray <http://xarray.pydata.org/
library before the any actual operations are sent to its sister library
`clisops <https://github.com/roocs/clisops>`_.


* Free software: BSD
* Documentation: https://daops.readthedocs.io

Expand All @@ -41,7 +37,6 @@ Features

The package has the following features:


* Ability to run *data-reduction* operations on large climate data sets.
* Knowledge of irregularities/anomalies in some climate data sets.
* Ability to apply *fixes* to those data sets before operating on them.
Expand All @@ -52,11 +47,5 @@ Credits

This package was created with ``Cookiecutter`` and the ``cedadev/cookiecutter-pypackage`` project template.


* Cookiecutter: https://github.com/audreyr/cookiecutter
* cookiecutter-pypackage: https://github.com/cedadev/cookiecutter-pypackage


.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/python/black
:alt: Python Black
4 changes: 2 additions & 2 deletions app-package.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ $graph:
collection: collection
file_namer: file_namer
output_dir: output_dir
out:
out:
- results

- class: CommandLineTool
id: clt
requirements:
InlineJavascriptRequirement: {}
EnvVarRequirement:
envDef:
envDef:
ROOCS_CONFIG: /root/roocs.ini
# PATH: /srv/conda/envs/env_crop/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# ResourceRequirement:
Expand Down
1 change: 0 additions & 1 deletion binder/postBuild

This file was deleted.

1 change: 0 additions & 1 deletion cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Console script for daops."""

__author__ = """Elle Smith"""
Expand Down
6 changes: 0 additions & 6 deletions daops/data_utils/__init__.py

This file was deleted.

Empty file removed daops/data_utils/array_utils.py
Empty file.
Empty file removed daops/ops/__init__.py
Empty file.
1 change: 0 additions & 1 deletion daops/utils/__init__.py

This file was deleted.

2 changes: 0 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import os
import sys

import sphinx_rtd_theme

sys.path.insert(0, os.path.abspath(".."))

# -- General configuration ---------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion eg-cli-params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ time: "2085-01-16/2188-12-16"
file_namer: "simple"
output_dir: "."
collection: "cmip5.output1.MOHC.HadGEM2-ES.rcp85.mon.atmos.Amon.r1i1p1.latest.tas"

18 changes: 9 additions & 9 deletions docs/environment.yml → environment-docs.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# conda env create -f environment.yml
# conda env create -f environment-docs.yml
name: daops-docs
channels:
- conda-forge
- defaults
dependencies:
- sphinx
- nbsphinx
- clisops>=0.6.1
- dask
- elasticsearch>=7.9.1
- ipython
- nbsphinx
- netcdf4
- numpy>=1.16
- pandoc
- pip
- numpy>=1.16
- xarray>=0.15
- dask
- netcdf4
- clisops>=0.6.1
- elasticsearch>=7.9.1
- roocs-utils>=0.2.1
- sphinx
- xarray>=0.15
# - pip:
# - roocs-utils @ git+https://github.com/roocs/roocs-utils.git@master#egg=roocs-utils
# - clisops @ git+https://github.com/roocs/clisops.git@master#egg=clisops
13 changes: 7 additions & 6 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# conda env create -f environment.yml
# conda env create -f environment-docs.yml
name: daops
channels:
- conda-forge
- defaults
dependencies:
- pip
- numpy >=1.16
- xarray >=0.21,<2023.3.0 # https://github.com/pydata/xarray/issues/7794
- cftime
- clisops >=0.14.0
- dask
- elasticsearch>=8.0.1
- netcdf4
- clisops >=0.12.1
- numpy >=1.23.0
- roocs-grids >=0.1.2
- roocs-utils >=0.6.4
- xarray >=0.21,<2023.3.0 # https://github.com/pydata/xarray/issues/7794
- xesmf >=0.8.2
- elasticsearch>=7.9.1
- roocs-utils>=0.6.2
# logging
- loguru >=0.5.3
# catalog
Expand Down
5 changes: 3 additions & 2 deletions notebooks/subset.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
"metadata": {},
"outputs": [],
"source": [
"from daops.ops.subset import subset\n",
"\n",
"# remove previosuly created example file\n",
"import os\n",
"\n",
"from daops.ops.subset import subset\n",
"\n",
"if os.path.exists(\"./output_001.nc\"):\n",
" os.remove(\"./output_001.nc\")"
]
Expand Down
Loading
Loading