WMO核心元数据配置文件测试套件的Python实现
项目描述
pywcmp
WMO核心元数据配置文件测试套件
pywcmp为WMO WIS核心元数据配置文件(WCMP)提供验证和质量评估功能。
- 针对WCMP2(草案)进行验证,特别是附件A:一致性类抽象测试套件,实现针对ATS的可执行测试套件
- 针对WCMP关键性能指标进行质量评估
安装
pip
从PyPI安装最新稳定版本。
pip3 install pywcmp
从源代码
安装最新开发版本。
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
运行
从命令行
# 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
使用API
>>> # test a file on disk
>>> import json
>>> from pywcmp.wcmp2.ets import WMOCoreMetadataProfileTestSuite2
>>> with open('/path/to/file.json') as fh:
... data = json.load(fh)
>>> # test ETS
>>> ts = 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 = 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']
开发
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
运行测试
# via setuptools
python3 setup.py test
# manually
python3 tests/run_tests.py
发布
# 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
代码约定
问题
问题由https://github.com/wmo-im/pywcmp/issues管理
联系
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码分发
pywcmp-0.10.1.tar.gz (18.5 kB 查看哈希值)
构建分发
pywcmp-0.10.1-py2.py3-none-any.whl (24.2 kB 查看哈希值)
关闭
pywcmp-0.10.1.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e2c36bf949b334574b7709791afbb17f07803c9fc9e015f15dad1c11c5375615 |
|
MD5 | 12b61005a37f77e3f21d307e503565fa |
|
BLAKE2b-256 | c575628d452191501bb5fa01a73e813d66f5e6fb5ee0df383a5231c8829d2e5e |
关闭
pywcmp-0.10.1-py2.py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 72ddad48327b961c13a782e9faabaa0cb94e9626848c80e5bb034b8cccbe22fa |
|
MD5 | 81804c136baef8b18fc1bda486b9a874 |
|
BLAKE2b-256 | 2f37facbdeb175efdcc471c195b780c92c749605d7d7e0be611f35fadbb93d55 |