Skip to content

Commit

Permalink
Improve tooling for maintenance (#79)
Browse files Browse the repository at this point in the history
* Fix for issue with new pandas version  (#77)

* new version of pandas has new option which contains max_rows, need to specify full option path to make sure no ambivalence is possible

* Version to 0.10.2-alpha

Co-authored-by: Ashley Smith <ashley.smith@magneticearth.org>

* Move source file locations

* Move to flit build system

* Fix docs build

* Configure linting with pre-commit

* Apply linting

* Configure linting & tests in GitHub Actions

Co-authored-by: Daniel Santillan <daniel.santillan@eox.at>
  • Loading branch information
smithara and santilland committed Apr 28, 2022
1 parent c96cca8 commit fca309f
Show file tree
Hide file tree
Showing 61 changed files with 1,896 additions and 1,388 deletions.
7 changes: 7 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8]
extend-ignore = E203, E501, E722, B950, T001
select = C,E,F,W,T,B,B9,I
per-file-ignores =
tests/*: T
noxfile.py: T
__init__.py:F401
46 changes: 31 additions & 15 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
name: CI


on:
push:
branches: [ staging ]
workflow_dispatch:
pull_request:
push:
branches: [ staging ]
workflow_dispatch:

jobs:
run-tests:
runs-on: ${{ matrix.operating-system }}
pre-commit:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v2
- uses: pre-commit/action@v2.0.3
with:
extra_args: --hook-stage manual --all-files

checks:
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
operating-system:
- ubuntu-latest
- windows-latest
- macOS-latest
python-version: ["3.6", "3.10"]
runs-on: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Nox
uses: excitedleigh/setup-nox@v2.0.0
- name: Run Nox
run: nox
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: python -m pip install .[test]
- name: Configure token access
run: |
viresclient set_token "https://vires.services/ows" ${{ secrets.VIRES_TOKEN_SWARM }}
viresclient set_default_server https://vires.services/ows
- name: Test package
run: python -m pytest -ra
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ MANIFEST
docs/_build/

# nox
.nox
.nox
94 changes: 94 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black-jupyter

- repo: https://github.com/kynan/nbstripout
rev: "0.5.0"
hooks:
- id: nbstripout

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-blanket-noqa
# - id: python-check-blanket-type-ignore
- id: python-no-eval
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
# args: ["-a", "from __future__ import annotations"] # Python 3.7+

- repo: https://github.com/asottile/pyupgrade
rev: v2.31.1
hooks:
- id: pyupgrade
args: ["--py37-plus"]

# - repo: https://github.com/hadialqattan/pycln
# rev: v1.1.0
# hooks:
# - id: pycln
# args: [--config=pyproject.toml]

- repo: https://github.com/asottile/yesqa
rev: v1.3.0
hooks:
- id: yesqa
exclude: docs/conf.py
additional_dependencies: &flake8_dependencies
- flake8-bugbear
- flake8-print

- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
exclude: docs/conf.py
additional_dependencies: *flake8_dependencies

# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.930
# hooks:
# - id: mypy
# files: src
# args: [--show-error-codes]

# - repo: https://github.com/codespell-project/codespell
# rev: v2.1.0
# hooks:
# - id: codespell

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.8.0.4
hooks:
- id: shellcheck

- repo: local
hooks:
- id: disallow-caps
name: Disallow improper capitalization
language: pygrep
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
exclude: .pre-commit-config.yaml
21 changes: 21 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Include PDF and ePub
formats: all

python:
version: 3.8
install:
- method: pip
path: .
extra_requirements:
- docs
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ You can reference *viresclient* directly using the DOI of our zenodo_ record. Vi

.. _zenodo: https://doi.org/10.5281/zenodo.2554162

| "We use the Python package, viresclient [1], to access [...] from ESA's VirES for Swarm service [2]"
| [1] https://doi.org/10.5281/zenodo.2554162
| "We use the Python package, viresclient [1], to access [...] from ESA's VirES for Swarm service [2]"
| [1] https://doi.org/10.5281/zenodo.2554162
| [2] https://vires.services
7 changes: 3 additions & 4 deletions docs/access_token.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ The tokens are managed via the web user interface.

Assuming you have an existing VirES account and you can access
the VirES web client (https://vires.services or https://aeolus.services),
you get to token manager via `Manage access tokens` item in your account menu
you get to token manager via *Manage access tokens* item in your account menu
(displaying your username)

.. image:: images/vires_token_manager_menu.png
:align: center

The token manager user interface allows creation of new tokens by pressing the
`Create New Access Token` button
*Create New Access Token* button

.. image:: images/vires_token_manager_create_blank.png
:align: center
Expand All @@ -24,7 +24,7 @@ brief label indicating its purpose
.. image:: images/vires_token_manager_create_filled.png
:align: center

Once the `Create New Access Token` button has been pressed, a new token is
Once the *Create New Access Token* button has been pressed, a new token is
generated and displayed to the user

.. image:: images/vires_token_manager_new_token.png
Expand All @@ -42,4 +42,3 @@ The token manager list the active access tokens and allows their revocation
*The tokens are secret.* Therefore, do not keep thier copies or share them
with others. When a token is needed generate new one. When a token is no
longer needed revoke it.

11 changes: 5 additions & 6 deletions docs/available_parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ SW_OPER_MITx_LP_2F MIT_LP Minima of the Midlatitude Ionospheric Tr
SW_OPER_MITx_LP_2F:ID MIT_LP:ID -> Boundaries of the MIT - derived from the LP
SW_OPER_MITxTEC_2F MIT_TEC Minima of the MIT - derived from Total Electron Content (TEC)
SW_OPER_MITxTEC_2F:ID MIT_TEC:ID -> Boundaries of the MIT - derived from TEC
SW_OPER_PPIxFAC_2F PPI_FAC Midnight Plasmapause Index (PPI)
SW_OPER_PPIxFAC_2F PPI_FAC Midnight Plasmapause Index (PPI)
SW_OPER_PPIxFAC_2F:ID PPI_FAC:ID -> Boundaries of the Small-Scale Field Aligned Currents (SSFAC)
====================== ================ ===================================================================================================

Expand Down Expand Up @@ -125,7 +125,7 @@ The ``measurements``, ``models``, and ``auxiliaries`` chosen will match the cade
----

``measurements``
----------------
----------------

Choose combinations of measurements from one of the following sets, corresponding to the collection chosen above. The collection full name or collection type can be given to :py:meth:`viresclient.SwarmRequest.available_measurements` to retrieve the list of available measurements for a given collection (e.g. ``request.available_measurements("SW_OPER_MAGA_LR_1B")``)

Expand Down Expand Up @@ -184,7 +184,7 @@ AUX_OBSH contains a special variable, ``ObsIndex``, which is set to 0, 1, 2 ...

VOBS products:

==================================== ===========================================
==================================== ===========================================
Collection full name Available measurement names
==================================== ===========================================
SW_OPER_VOBS_1M_2\_ ``SiteCode,B_CF,B_OB,sigma_CF,sigma_OB``
Expand All @@ -205,7 +205,7 @@ Models are evaluated along the satellite track at the positions of the time seri
For a good estimate of the ionospheric field measured by a Swarm satellite (with the core, crust and magnetosphere effects removed) use a composed model defined as:
``models=["'CHAOS-full' = 'CHAOS-Core' + 'CHAOS-Static' + 'CHAOS-MMA-Primary' + 'CHAOS-MMA-Secondary'"]``
`(click for more info) <https://github.com/klaundal/notebooks/blob/master/get_external_field.ipynb>`_

This composed model can also be accessed by an alias: ``models=["CHAOS"]`` which represents the full CHAOS model

See `Magnetic Earth <https://magneticearth.org/pages/models.html>`_ for an introduction to geomagnetic models.
Expand Down Expand Up @@ -292,8 +292,7 @@ NB: When using model names containing a hyphen (``-``) then extra single (``'``)
.. note::

Check other packages such as `hapiclient`_ and others from `PyHC`_ for data from other sources.

.. _`hapiclient`: https://github.com/hapi-server/client-python

.. _`PyHC`: http://heliopython.org/projects/

2 changes: 1 addition & 1 deletion docs/available_parameters_aeolus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Available parameters for Aeolus
===============================

.. note::
Details to follow. See https://notebooks.aeolus.services for examples.
Details to follow. See https://notebooks.aeolus.services for examples.
2 changes: 1 addition & 1 deletion docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Setting extra constant parameters::
Timestamp

Removing constant parameters::

$ viresclient clear_upload_parameters https://staging.vires.services/ows
eff3bd47-0098-45d3-ba9e-158bea0fae12: parameters removed

Expand Down

0 comments on commit fca309f

Please sign in to comment.