Code Monkey home page Code Monkey logo

pywcmp's Introduction

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

PEP8

Issues

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

Contact

pywcmp's People

Contributors

tomkralidis avatar josusky avatar antje-s avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.