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

Prepare release 0.9.0 #110

Merged
merged 20 commits into from
Nov 17, 2023
Merged
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
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9]
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v2
- name: Install packages
Expand All @@ -27,9 +27,9 @@ jobs:
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
# pip install the package, command-line unit tests work
pip install --no-deps -e .
# - name: Lint with flake8
# run: flake8 daops tests
# if: matrix.python-version == 3.8
- name: Lint with flake8
run: make lint
if: matrix.python-version == 3.8
# - name: Check formatting with black
# run: black --check --target-version py38 daops tests
# if: matrix.python-version == 3.8
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
exclude: 'setup.cfg'
Expand All @@ -12,21 +12,21 @@ repos:
- id: check-yaml
- id: debug-statements
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.11.0
hooks:
- id: black
args: ["--target-version", "py37"]
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
rev: 6.1.0
hooks:
- id: flake8
args: ['--config=setup.cfg']
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.0.1
rev: v3.9.0
hooks:
- id: reorder-python-imports
- repo: https://github.com/asottile/pyupgrade
rev: v2.32.0
rev: v3.15.0
hooks:
- id: pyupgrade
- repo: meta
Expand Down
24 changes: 10 additions & 14 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,22 @@ version: 2
sphinx:
configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all
# formats:
# - pdf

build:
os: ubuntu-22.04
tools:
python: "mambaforge-22.9"

conda:
environment: environment.yml

# Optionally set the version of Python and requirements required to build your docs
#python:
# version: 3.6
python:
version: 3.7
install:
- method: pip
path: .
extra_requirements:
- docs

#conda:
# environment: docs/environment.yml

build:
image: stable
3 changes: 3 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ Logging
``daops`` uses the `loguru <https://loguru.readthedocs.io/en/stable/index.html>`_ library as its primary logging engine. In order to integrate this kind of logging in processes, we can use their logger:

.. 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:

.. code-block:: python

import sys
from loguru import logger

Expand All @@ -139,6 +141,7 @@ The mechanism for enabling log reporting in scripts/notebooks using ``loguru`` i
For convenience, a preset logger configuration can be enabled via `daops.enable_logging()`.

.. code-block:: python

from daops import enable_logging

enable_logging()
Expand Down
25 changes: 20 additions & 5 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Version History
===============

v0.9.0 (2023-11-17)
-------------------

Breaking Changes
^^^^^^^^^^^^^^^^
* ``clisops``>=0.10.0 required.

Other Changes
^^^^^^^^^^^^^
* Updated requirements.
* Updated pre-commit.
* Support tests on Python 3.10 and 3.11.
* Enabled linting test.


v0.8.1 (2022-05-12)
-------------------

Expand Down Expand Up @@ -56,7 +71,7 @@ New Features
* ``intake_catalog_url`` has been added to ``etc/roocs.ini``

v0.5.0 (2021-02-26)
------------------
-------------------

New Features
^^^^^^^^^^^^
Expand All @@ -68,7 +83,7 @@ Other Changes


v0.4.0 (2021-02-23)
------------------
-------------------

Breaking Changes
^^^^^^^^^^^^^^^^
Expand All @@ -91,7 +106,7 @@ Other Changes


v0.3.0 (2020-11-19)
------------------
-------------------

Updating doc strings and documentation.

Expand Down Expand Up @@ -127,12 +142,12 @@ Other Changes
* Functions that take the ``data_ref`` parameter have been changed to use ``dset`` parameter instead.

v0.2.0 (2020-06-22)
------------------
-------------------

* Updated to use clisops v0.2.0 (#17)
* Added xarray aggregation tests (#16)

v0.1.0 (2020-04-27)
------------------
-------------------

* First release with clisops v0.1.0.
2 changes: 1 addition & 1 deletion daops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__contact__ = "[email protected]"
__copyright__ = "Copyright 2018 United Kingdom Research and Innovation"
__license__ = "BSD"
__version__ = "0.8.1"
__version__ = "0.9.0"

from loguru import logger

Expand Down
106 changes: 72 additions & 34 deletions daops/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Console script for daops."""

__author__ = """Alan Iwi"""
__contact__ = '[email protected]'
__contact__ = "[email protected]"
__copyright__ = "Copyright 2023 United Kingdom Research and Innovation"
__license__ = "BSD - see LICENSE file in top-level package directory"

Expand All @@ -14,47 +14,83 @@
from daops.ops.subset import subset
from roocs_utils.utils.file_utils import FileMapper

def parse_args():

def parse_args():
parser = argparse.ArgumentParser()
sub_parsers = parser.add_subparsers()
sub_parsers.required = True

parser_subset = sub_parsers.add_parser('subset', help='subset data')
parser_subset.add_argument('--area', '-a', type=str,
help=('area in format w,s,e,n. Hint: if w is negative, include an "=" sign '
'e.g. --area=-10,...'))
parser_subset.add_argument('--time', '-t', type=str, metavar='time_window',
help='time window e.g. 1999-01-01T00:00:00/2100-12-30T00:00:00')
parser_subset.add_argument('--time-components', '-c', type=str,
help="time components e.g. month:dec,jan,feb or 'year:1970,1980|month:01,02,03'")
parser_subset.add_argument('--levels', '-l', type=str,
help=('comma-separated list of levels (e.g. 500,1000,2000) '
'or slash-separated range (e.g. 50/2000 for 50 to 2000)'))
parser_subset.add_argument('--output-format', '-f', type=str, metavar='format',
choices=('netcdf', 'nc', 'zarr'), default='netcdf')
parser_subset.add_argument('--file-namer', '-F', type=str,
choices=('simple', 'standard'), default='standard')
parser_subset.add_argument('--output-dir', '-d', type=str, metavar='output_directory', required=True)
parser_subset.add_argument('collection', type=str, nargs='+', default=list)
parser_subset = sub_parsers.add_parser("subset", help="subset data")
parser_subset.add_argument(
"--area",
"-a",
type=str,
help=(
'area in format w,s,e,n. Hint: if w is negative, include an "=" sign '
"e.g. --area=-10,..."
),
)
parser_subset.add_argument(
"--time",
"-t",
type=str,
metavar="time_window",
help="time window e.g. 1999-01-01T00:00:00/2100-12-30T00:00:00",
)
parser_subset.add_argument(
"--time-components",
"-c",
type=str,
help="time components e.g. month:dec,jan,feb or 'year:1970,1980|month:01,02,03'",
)
parser_subset.add_argument(
"--levels",
"-l",
type=str,
help=(
"comma-separated list of levels (e.g. 500,1000,2000) "
"or slash-separated range (e.g. 50/2000 for 50 to 2000)"
),
)
parser_subset.add_argument(
"--output-format",
"-f",
type=str,
metavar="format",
choices=("netcdf", "nc", "zarr"),
default="netcdf",
)
parser_subset.add_argument(
"--file-namer",
"-F",
type=str,
choices=("simple", "standard"),
default="standard",
)
parser_subset.add_argument(
"--output-dir", "-d", type=str, metavar="output_directory", required=True
)
parser_subset.add_argument("collection", type=str, nargs="+", default=list)

return parser.parse_args()


def get_params(args):

collection = args.collection if len(args.collection) == 1 else FileMapper(args.collection)

return {'collection': collection,
'time': args.time,
'time_components': args.time_components,
'area': args.area,
'level': args.levels,
'output_type': args.output_format,
'output_dir': args.output_dir,
'file_namer': args.file_namer,
'apply_fixes': False
}
collection = (
args.collection if len(args.collection) == 1 else FileMapper(args.collection)
)

return {
"collection": collection,
"time": args.time,
"time_components": args.time_components,
"area": args.area,
"level": args.levels,
"output_type": args.output_format,
"output_dir": args.output_dir,
"file_namer": args.file_namer,
"apply_fixes": False,
}


def check_env():
Expand All @@ -64,14 +100,16 @@ def check_env():
so exit might not always be graceful in these cases).
Call this after get_params() so that 'help' still works even if this is not set.
"""
config_env_var = 'ROOCS_CONFIG'
config_env_var = "ROOCS_CONFIG"
c = configparser.ConfigParser()
try:
ret = c.read(os.environ[config_env_var])
except (KeyError, configparser.Error):
ret = None
if not ret:
print(f'Environment variable {config_env_var} must contain the path name of a config file in ini format')
print(
f"Environment variable {config_env_var} must contain the path name of a config file in ini format"
)
sys.exit(1)


Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
# the built documents.
#
# The short X.Y version.
version = "0.8.1"
version = "0.9.0"
# The full version, including alpha/beta/rc tags.
release = version

Expand All @@ -83,7 +83,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Welcome to daops's documentation!
installation
usage
api
notebooks/index
contributing
authors
history
Expand Down
1 change: 0 additions & 1 deletion docs/notebooks

This file was deleted.

2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- xarray>=0.15
- dask
- netcdf4
- clisops>=0.9.1
- clisops>=0.10.0
- elasticsearch>=7.9.1
- roocs-utils>=0.6.2
# logging
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ dask[complete]
cftime
netcdf4
elasticsearch>=8.0.1
clisops>=0.9.1
## clisops @ git+https://github.com/roocs/clisops.git@master#egg=clisops
clisops>=0.10.0
roocs-utils>=0.6.2
# logging
loguru>=0.5.3
Expand Down
8 changes: 4 additions & 4 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ bumpversion
wheel
watchdog
flake8
tox
tox>=4.0
coverage
Sphinx
sphinx-rtd-theme
Expand All @@ -14,6 +14,6 @@ twine
pytest>=6.0
pytest-loguru
pytest-runner
pre-commit>=2.9.0
black>=22.3.0
GitPython==3.1.37
pre-commit>=3.0.0
black>=23.7.0
GitPython>=3.1.37
Loading