A Python implementation of the test suite for WMO Core Metadata Profile
Project description
pywcmp
WMO Core Metadata Profile Test Suite
pywcmp provides validation and quality assessment capabilities for the WMO WIS Core Metadata Profile (WCMP).
- validation against WCMP 2 (draft), specifically Annex A: Conformance Class Abstract Test Suite, implementing an executable test suite against the ATS
- quality assessement against the WCMP Key Performance Indicators
Installation
pip
Install latest stable version from PyPI.
pip3 install pywcmp
From source
Install latest development version.
python3 -m venv pywcmp
cd pywcmp
. bin/activate
git clone https://github.com/wmo-im/pywcmp.git
cd pywcmp
pip3 install -r requirements.txt
python3 setup.py install
Running
From command line:
# fetch version
pywcmp --version
# sync supporting configuration bundle (schemas, topics, etc.)
pywcmp bundle sync
# abstract test suite
# validate WCMP 2 metadata against abstract test suite (file on disk)
pywcmp ets validate /path/to/file.json
# validate WCMP 2 metadata against abstract test suite (URL)
pywcmp ets validate https://example.org/path/to/file.json
# validate WCMP 2 metadata against abstract test suite (URL), but turn JSON Schema validation off
pywcmp ets validate https://example.org/path/to/file.json --no-fail-on-schema-validation
# adjust debugging messages (CRITICAL, ERROR, WARNING, INFO, DEBUG) to stdout
pywcmp ets validate https://example.org/path/to/file.json --verbosity DEBUG
# write results to logfile
pywcmp ets validate https://example.org/path/to/file.json --verbosity DEBUG --logfile /tmp/foo.txt
# key performance indicators
# all key performance indicators at once
pywcmp kpi validate https://example.org/path/to/file.json --verbosity DEBUG
# all key performance indicators at once, but turn ETS validation off
pywcmp kpi validate https://example.org/path/to/file.json --no-fail-on-ets --verbosity DEBUG
# all key performance indicators at once, in summary
pywcmp kpi validate https://example.org/path/to/file.json --verbosity DEBUG --summary
# selected key performance indicator
pywcmp kpi validate --kpi title /path/to/file.json -v INFO
Using the API
>>> # test a file on disk
>>> import json
>>> from pywcmp.ets import ets
>>>
>>> with open('/path/to/file.json')) as fh:
... data = json.load(fh)
>>> # test ETS
>>> ts = ets.WMOCoreMetadataProfileTestSuite2(datal)
>>> ts.run_tests() # raises ValueError error stack on exception
>>> # test a URL
>>> from urllib2 import urlopen
>>> from StringIO import StringIO
>>> content = StringIO(urlopen('https://....').read())
>>> data = json.loads(content)
>>> ts = ets.WMOCoreMetadataProfileTestSuite2(data)
>>> ts.run_tests() # raises ValueError error stack on exception
>>> # handle pywcmp.errors.TestSuiteError
>>> # pywcmp.errors.TestSuiteError.errors is a list of errors
>>> try:
... ts.run_tests()
... except pywcmp.errors.TestSuiteError as err:
... print('\n'.join(err.errors))
>>> ...
>>> # test KPI
>>> from pywcmp.kpi import WMOCoreMetadataProfileKeyPerformanceIndicators
>>> kpis = WMOCoreMetadataProfileKeyPerformanceIndicators(data)
>>> results = kpis.evaluate()
>>> results['summary']
Development
python3 -m venv pywcmp
cd pywcmp
source bin/activate
git clone https://github.com/wmo-im/pywcmp.git
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt
python3 setup.py install
Running tests
# via setuptools
python3 setup.py test
# manually
python3 tests/run_tests.py
Releasing
# create release (x.y.z is the release version)
vi pywcmp/__init__.py # update __version__
git commit -am 'update release version x.y.z'
git push origin master
git tag -a x.y.z -m 'tagging release version x.y.z'
git push --tags
# upload to PyPI
rm -fr build dist *.egg-info
python3 setup.py sdist bdist_wheel --universal
twine upload dist/*
# publish release on GitHub (https://github.com/wmo-im/pywcmp/releases/new)
# bump version back to dev
vi pywcmp/__init__.py # update __version__
git commit -am 'back to dev'
git push origin master
Code Conventions
Issues
Issues are managed at https://github.com/wmo-im/pywcmp/issues
Contact
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pywcmp-0.7.1.tar.gz
(17.2 kB
view details)
Built Distribution
File details
Details for the file pywcmp-0.7.1.tar.gz
.
File metadata
- Download URL: pywcmp-0.7.1.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba6fab2540232b5ca9ffe5c9fa71ca86c9a8d7e7569b0f77f02e238cf9e95b55 |
|
MD5 | 9a799088fd0ecea6264589c209f57b88 |
|
BLAKE2b-256 | 1f193cff742ef7cbac121192b91ee6e68ef4a81ca88252f2cb1a19b64f6ddfd6 |
File details
Details for the file pywcmp-0.7.1-py2.py3-none-any.whl
.
File metadata
- Download URL: pywcmp-0.7.1-py2.py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1306ea3f8cb4d69c70867f5bc3492608050839771412275e1dba5cb4f50799a1 |
|
MD5 | 4823956954f993e647afe7238e7f037a |
|
BLAKE2b-256 | ed527b6355e6876b6f2f67ba51d1184ef1a32461304a347b77822b3971cb6ef9 |