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/World-Meteorological-Organization/pywcmp.git
cd pywcmp
pip3 install -r requirements.txt
pip3 install .

Running

From command line:

# fetch version
pywcmp --version

# sync supporting configuration bundle (schemas, topics, etc.)
pywcmp bundle sync

# abstract test suite

# validate WCMP2 metadata against abstract test suite (file on disk)
pywcmp ets validate /path/to/file.json

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

# validate WCMP2 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.wcmp2.ets import WMOCoreMetadataProfileTestSuite2
>>> from pywcmp.errors import TestSuiteError
>>> with open('/path/to/file.json') as fh:
...     data = json.load(fh)
>>> # test ETS
>>> ts = WMOCoreMetadataProfileTestSuite2(datal)
>>> ts.run_tests()
>>> ts.raise_for_status()  # raises pywcmp.errors.TestSuiteError on exception with list of errors captured in .errors property
>>> # test a URL
>>> from urllib2 import urlopen
>>> from StringIO import StringIO
>>> content = StringIO(urlopen('https://....').read())
>>> data = json.loads(content)
>>> ts = WMOCoreMetadataProfileTestSuite2(data)
>>> ts.run_tests()
>>> ts.raise_for_status()  # raises pywcmp.errors.TestSuiteError on exception with list of errors captured in .errors property
>>> # test KPI
>>> from pywcmp.wcmp2.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/World-Meteorological-Organization/pywcmp.git
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt
python3 setup.py install

Running tests

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/World-Meteorological-Organization/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

PEP8

Issues

Issues are managed at https://github.com/World-Meteorological-Organization/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.13.2.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pywcmp-0.13.2-py2.py3-none-any.whl (29.0 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: pywcmp-0.13.2.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for pywcmp-0.13.2.tar.gz
Algorithm Hash digest
SHA256 338e1924a2b4704bac555b9499b3de76d0ebe22148e0bf1ba3f64c18d007eaa1
MD5 0dfc05d168d69f72fb8656bdc757f356
BLAKE2b-256 9f2f636dfd5ae2e38d7e6b5779cc095fad5911de205afcdd91171199d071e2e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pywcmp-0.13.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 29.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for pywcmp-0.13.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6425b15d58707d28f75decfd6144be5bd71ab046f8fcc21cfd4442d09662f78e
MD5 be0ed9b81e7209d1218a4171bca58333
BLAKE2b-256 51396443f0e3c0068f4d7dcb425b07446eac7e7dd0c95ca8353c007fa2e188a1

See more details on using hashes here.

Supported by

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