Skip to content

Commit

Permalink
Merge in CF 1.8 implementation (#892)
Browse files Browse the repository at this point in the history
* add bio_taxa CDL example

* Adds handling for taxon names and identifiers

Adds support for CF 1.8 Section 6.1.2: Taxon Names and Identifiers

Fetches LSID for appropriate "biological_taxon_lsid" from
http://www.lsid.info after some basic validation.  If the LSID refers to
a WoRMS or ITIS database entry, validates against those databases,
otherwise skips validation for other data sources.

* Adds tests for well-formed WoRMS data

Adds unit tests for well-formed WoRMS data by mocking the HTTP response.
Updates test requirements file due to mocked requests.

* Handle unset standard_name, fix standard_name search

Properly handle no standard name when attempting to look for taxonomy
related variables.  Changes "biological_taxon_identifier" to
"biological_taxon_lsid" for purposes of excluding coordinate variables
for taxonomy.  The former term was not a valid CF standard name.

* Add skip condition, tests for nodata/fillvalue LSID variable

* Add passing example for ITIS.gov TSN data sources

* Remove unused import, comments, and fix typos

* Add tests for ITIS failure case from non-matching taxon name vs TSN reference

* Remove pyworms dependency and refactor WoRMS calls

* Remove bad import

* Fix test netCDF file name/references

* Revert "Fix test netCDF file name/references"

This reverts commit 8ff9e92.

* Add taxonomy_example.cdl to test data

* Fix message append, message return, remove unused LSID class

* Tests for invalid and malformed LSIDs

* Fix status code handling, error message formatting

* Add warnings import

* test on py3k

* fix typo

* Add .coveragerc, coverage files added to .gitignore

* Add coverage/codecov GitHub Action workflow

* Add codecov to test requirements

* pytest-cov to requirements

* Set continue-on-error to true to pass along coverage to codecov

* Update README to include codecov badge

* re-enable flake8

* Apply black code formatting

* Remove extraneous code

* Undefined variable/function fixes

* Use continue to avoid fall through if taxa not found

* Remove dead variables and code sections

* Fix util date test to use previously unused variable for testing

* Add test for climatology invalid bounds size

* Add simple test for IOOS 1.2 point featureType

* Add Dataset import for type hint in cf/util.py

* Fix tests for CF 1.8

* (Re?) add shapely to requirements

* Fix various accident reverts to CF 1.8 tests

* Add setitem/getitem methods to MockVariable

* Fix messages/tests for polygon geometry

* Unpin NetCDF version in GitHub Actions default test CI steps

* Restore ncgen -4 call

* Add pyrightconfig.json to .gitignore

* Use ncgen -4 in resources.py for CDL generation in unit tests

* Refactor to split CF version checks into separate modules

Refactors CF checker classes to reside in separate modules for test
coverage and organization purposes.  Updates other modules such as tests
to use these new module paths.  `cf.py` is now used for importing the
various versions of the checkers, whereas the versioned modules are not
imported directly.  Also created a new module `cf_base` to avoid
circular import issues in `cf.py`.

* Add CF 1.8 to supported standards in README.md table

* Add CF 1.8 checker to setup.py

* Fix unbound exception variables, index var

Co-authored-by: Ben Hall <ben.hall@rpsgroup.com>
Co-authored-by: Filipe Fernandes <ocefpaf@gmail.com>
  • Loading branch information
3 people authored Jan 25, 2022
1 parent b9f7186 commit f60d88d
Show file tree
Hide file tree
Showing 32 changed files with 6,978 additions and 5,406 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[run]
source=compliance_checker
branch=True
omit=compliance_checker/tests/*
55 changes: 55 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Code coverage report

on:
pull_request:
push:
branches:
- master
- develop

jobs:
run:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.10"]
os: [ubuntu-latest]
fail-fast: false

steps:
- uses: actions/checkout@v2

- name: Setup Conda
uses: s-weigand/setup-conda@v1
with:
activate-conda: false
conda-channels: conda-forge

- name: Python ${{ matrix.python-version }}
shell: bash -l {0}
run: |
conda create --name TEST python=${{ matrix.python-version }} pip --file requirements.txt --file test_requirements.txt --strict-channel-priority
source activate TEST
pip install -e . --no-deps --force-reinstall
- name: Conda Info
shell: bash -l {0}
run: |
source activate TEST
conda info --all
conda list
- name: Run tests with coverage
shell: bash -l {0}
run: |
source activate TEST
pytest --cov=compliance_checker --cov-report=xml compliance_checker/tests
# pass this step even if there are individual test failures, we are
# interested in the overall level of coverage and other checks can
# report on test failures.
continue-on-error: true

- name: Upload to codecov
uses: codecov/codecov-action@v2
with:
files: coverage.xml
4 changes: 2 additions & 2 deletions .github/workflows/default-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9"]
python-version: ["3.7", "3.8", "3.9", "3.10"]
os: [windows-latest, ubuntu-latest, macos-latest]
fail-fast: false

Expand All @@ -26,7 +26,7 @@ jobs:
- name: Python ${{ matrix.python-version }}
shell: bash -l {0}
run: |
conda create --name TEST python=${{ matrix.python-version }} pip "libnetcdf<4.8.0" --file requirements.txt --file test_requirements.txt --strict-channel-priority
conda create --name TEST python=${{ matrix.python-version }} pip --file requirements.txt --file test_requirements.txt --strict-channel-priority
source activate TEST
pip install -e . --no-deps --force-reinstall
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ ENV/
# IDE project settings
.spyderproject
.vscode
pyrightconfig.json

# Rope project settings
.ropeproject
Expand All @@ -104,3 +105,9 @@ ENV/
conda-requirements.txt

compliance_checker/_version.py
.venv
activate

# coverage output
coverage/
coverage.xml
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.1.0
hooks:
- id: trailing-whitespace
exclude: compliance_checker/tests/data
Expand All @@ -14,15 +14,15 @@ repos:
- id: file-contents-sorter
files: test_requirements.txt

# - repo: https://gitlab.com/pycqa/flake8
# rev: 3.9.2
# hooks:
# - id: flake8
# exclude: docs/source/conf.py
# args: [--max-line-length=200, "--ignore=E203,E501,W503", "--select=select=C,E,F,W,B,B950"]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
exclude: docs/source/conf.py
args: [--max-line-length=200, "--ignore=E203,E501,W503", "--select=select=C,E,F,W,B,B950"]

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.9.3
rev: v5.10.1
hooks:
- id: isort
additional_dependencies: [toml]
Expand All @@ -34,7 +34,7 @@ repos:
- id: seed-isort-config

- repo: https://github.com/psf/black
rev: 21.9b0
rev: 21.12b0
hooks:
- id: black
language_version: python3
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Build Status](https://travis-ci.org/ioos/compliance-checker.svg)](https://travis-ci.org/ioos/compliance-checker)
[![Build status](https://ci.appveyor.com/api/projects/status/lcc9co38pi6o45ho/branch/master?svg=true)](https://ci.appveyor.com/project/ocefpaf/compliance-checker/branch/master)
[![codecov](https://codecov.io/gh/ioos/compliance-checker/branch/master/graph/badge.svg)](https://codecov.io/gh/ioos/compliance-checker)

The IOOS Compliance Checker is a python based tool for data providers to check
for completeness and community standard compliance of local or remote
Expand All @@ -22,6 +23,7 @@ It currently supports the following sources and standards:
| Standard | Source | .nc/OPeNDAP/.cdl | SOS |
| ---------------------------------------------------------------------------------------------------- | ----------- | ------ | ------------------------------- |
| [ACDD (1.1, 1.3)](http://wiki.esipfed.org/index.php/Attribute_Convention_for_Data_Discovery_1-3) | Built-in | X | - |
| [CF (1.8)](http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html) | Built-in | X | - |
| [CF (1.7)](http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/cf-conventions.html) | Built-in | X | - |
| [CF (1.6)](http://cfconventions.org/cf-conventions/v1.6.0/cf-conventions.html) | Built-in | X | - |
| IOOS SOS | Built-in | - | GetCapabilities, DescribeSensor |
Expand Down
14 changes: 14 additions & 0 deletions compliance_checker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,20 @@ def assert_true(self, test, message):

return test

def add_failure(self, message):
"""
Adds a failure along with a message
:rtype: None
"""
self.assert_true(False, message)

def add_pass(self):
"""
Adds a pass condition
:rtype: None
"""
self.assert_true(True, None)


def std_check_in(base_context, name, allowed_vals):
"""
Expand Down
Loading

0 comments on commit f60d88d

Please sign in to comment.