Skip to main content

pywis-pubsub provides subscription and download capability of WMO data from WIS 2.0 infrastructure services

Project description

flake8 test-publish-subscribe-download

pywis-pubsub

Overview

pywis-pubsub provides subscription and download capability of WMO data from WIS 2.0 infrastructure services.

Installation

The easiest way to install pywis-pubsub is via the Python pip utility:

pip3 install pywis-pubsub

Requirements

Dependencies

Dependencies are listed in requirements.txt. Dependencies are automatically installed during pywis-pubsub installation.

Windows installations

Note that you will need Cython and Shapely Windows wheels for windows for your architecture prior to installing pywis-pubsub.

Installing pywis-pubsub

# setup virtualenv
python3 -m venv --system-site-packages pywis-pubsub
cd pywis-pubsub
source bin/activate

# clone codebase and install
git clone https://github.com/wmo-im/pywis-pubsub.git
cd pywis-pubsub
python3 setup.py install

Running

First check pywis-pubsub was correctly installed

pywis-pubsub --version

Subscribing

cp pywis-pubsub-config-example.yml local.yml
vim local.yml # update accordingly to configure subscribe-options

pywis-pubsub --version

# sync WIS2 notification schema
pywis-pubsub schema sync

# connect, and simply echo messages
pywis-pubsub subscribe --config local.yml

# subscribe, and download data from message
pywis-pubsub subscribe --config local.yml --download

# subscribe, and filter messages by geometry
pywis-pubsub subscribe --config local.yml --bbox=-142,42,-52,84

# subscribe, and filter messages by geometry, increase debugging verbosity
pywis-pubsub subscribe --config local.yml --bbox=-142,42,-52,84 --verbosity=DEBUG

# validate a message
pywis-pubsub message validate /path/to/message1.json

Publishing

cp pub-config-example.yml pub-local.yml
vim pub-local.yml # update accordingly to configure publish-options

# example publishing a WIS2-message with attributes: 
# unique-id=stationXYZ-20221111085500 
# data-url=http://www.meteo.xx/stationXYZ-20221111085500.bufr4 
# lon,lat,elevation=33.8,11.8,112
# wigos_station_identifier=0-20000-12345
pywis-pubsub publish --config pub-local.yml -i stationXYZ-20221111085500 -u http://www.meteo.xx/stationXYZ-20221111085500.bufr4 -g 33.8,-11.8,8.112 -w 0-20000-12345

Using the API

Python examples:

# subscriber example
from pywis_pubsub.mqtt import MQTTPubSubClient

options = {
    'storage': {
        'type': 'fs',
        'path': '/tmp'
    },
    'bbox': [-90, -180, 90, 180]
}
topics = [
    'topic1',
    'topic2'
]

m = MQTTPubSubClient('mqtt://localhost:1883', options)
m.sub(topics)
# publish example
from pywis_pubsub.mqtt import MQTTPubSubClient
from pywis_pubsub.publish import create_message

message = create_message(
        topic='foo/bar',
        content_type='application/x-bufr',
        url='http://www.meteo.xx/stationXYZ-20221111085500.bufr4', 
        identifier='stationXYZ-20221111085500', 
        geometry=[33.8, -11.8, 123],
        wigos_station_identifier='0-20000-12345'
)

m = MQTTPubSubClient('mqtt://localhost:1883')
client.pub(topic, json.dumps(message))

Development

Running Tests

# install dev requirements
pip3 install -r requirements-dev.txt

# run tests like this:
python3 tests/run_tests.py

# or this:
python3 setup.py test

Releasing

rm -fr build dist *.egg-info
python3 setup.py sdist bdist_wheel --universal
twine upload dist/*

Code Conventions

Bugs and Issues

All bugs, enhancements and issues are managed on GitHub.

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

pywis-pubsub-0.2.1.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

pywis_pubsub-0.2.1-py2.py3-none-any.whl (22.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pywis-pubsub-0.2.1.tar.gz.

File metadata

  • Download URL: pywis-pubsub-0.2.1.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.4

File hashes

Hashes for pywis-pubsub-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b48bee52157dba1c8db8c04c6eace7e1d9c4b4b6b5eec6f69b415677e4e58089
MD5 d9d00841c97ba0803905967c1cd4e6fc
BLAKE2b-256 1e533f9df633a9d07daa12d84f00578c86b12050abbc8158c2c6070c28f69675

See more details on using hashes here.

File details

Details for the file pywis_pubsub-0.2.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pywis_pubsub-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 63d4041b25d6c15295680de280e4a17dafe2f7763474dccde8a528522749d675
MD5 5c070c206ddceb3e79d0e85f5eab34f3
BLAKE2b-256 f89c0934d8675acdeb680289e91db8bbceca7baff2586150d84b5718477ec1b0

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