Skip to main content

A Python implementation of the test suite for WMO Core Metadata Profile

Project description

pywcmp

Build Status

WMO Core Metadata Profile Test Suite

pywcmp provides validation and quality assessment capabilities for the WMO WIS Core Metadata Profile (WCMP).

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 1.3 metadata against abstract test suite (file on disk)
pywcmp ets validate /path/to/file.xml

# validate WCMP 1.3 metadata against abstract test suite (URL)
pywcmp ets validate https://example.org/path/to/file.xml

# 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.xml --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 # note: running KPIs automatically runs the ets
pywcmp kpi validate https://example.org/path/to/file.xml --verbosity DEBUG

# all key performance indicators at once, in summary
pywcmp kpi validate https://example.org/path/to/file.xml --verbosity DEBUG --summary

# all key performance indicators at once, with scoring rubric grouping
pywcmp kpi validate https://example.org/path/to/file.xml --verbosity DEBUG --group

# selected key performance indicator
pywcmp kpi validate --kpi 4 /path/to/file.xml -v INFO

# WIS2 topic hierarchies

# validate a WIS2 topic hierarchy
pywcmp topics validate origin.a.wis2.can

# validate a partial WIS2 topic hierarchy
pywcmp topics validate wis2.can --fuzzy

# list children of a given WIS2 topic hierarchy level
pywcmp topics list wis2.a

Using the API

>>> # test a file on disk
>>> from lxml import etree
>>> from pywcmp.ets import ets
>>> exml = etree.parse('/path/to/file.xml')
>>> # test ETS
>>> ts = ets.WMOCoreMetadataProfileTestSuite13(exml)
>>> 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())
>>> exml = etree.parse(content)
>>> ts = ets.WMOCoreMetadataProfileTestSuite13(exml)
>>> 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(exml)
>>> results = kpis.evaluate()
>>> results['summary']
>>> # scoring rubric
>>> grouped = group_kpi_results(results)

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 main
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
python 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 main

Code Conventions

PEP8

Issues

Issues are managed at https://github.com/wmo-im/pywcmp/issues

Contact

Project details


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.5.0.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

pywcmp-0.5.0-py2.py3-none-any.whl (40.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pywcmp-0.5.0.tar.gz.

File metadata

  • Download URL: pywcmp-0.5.0.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.4

File hashes

Hashes for pywcmp-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b479a8b39e5240571921c656cd7e57c63d7ed9f3d5cbaade091a778abf4f504c
MD5 33ed47d95db081841937036a4152114a
BLAKE2b-256 5664ecce1ce53282b6cb351e5fc2b202f352c47bb67679bbd56917ff7f7b78e6

See more details on using hashes here.

File details

Details for the file pywcmp-0.5.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pywcmp-0.5.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 40.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.4

File hashes

Hashes for pywcmp-0.5.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1f4224044582846425467736a0457ad3306b8795a76d2a273d3954550a8f4719
MD5 3660be4247ada99973ae9f154c9376bb
BLAKE2b-256 fd041c94ba0fda036fcf1e6a735f73c9b1ff32211418ec90defb186f0436c69c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page