Skip to main content

Simple reference implementation for VDV 736 subscriber and publisher written in Python

Project description

PyVDV736

Simple reference implementation for VDV736 subscriber and publisher written in Python. VDV736 is a data standard based on SIRI-SX for public transport situation exchange.

Situation Exchange in VDV736

Exchanging public transport situations works with a realtime capable setup using a publish/subscribe mechanism. To get this working, the publisher (in most cases called 'server') as well as the subscriber (in most cases called 'client') needs to be callable via an HTTP(S) interface.

A subscription then works as follows:

  • The subscriber registers at the publisher with its participant ID (aka 'Leitstellenkennung') and some basic subscription parameters
  • The publisher stores this subscription and every time a new public transport situation is published, the publisher calls the subscriber's endpoint with a body containing data
  • At the end, the subscribers terminates his subscription sending a request to the publisher again, stating that the existing subscription should be deleted

This way, data are only transferred, when they're updated in realtime without polling. Other well-known public transport protocols (like VDV453, VDV454, SIRI) work exactly the same. A digital data hub (aka 'Datendrehscheibe') combines the role of the publisher and subscriber.

Note: SIRI-SX offers also the option for fetching public transport situations using a simple GET request. VDV736 states that only publish/subscribe is supported. Hence, the request endpoint of the publisher is only experimental and not supported officially.

Configuration

There's a YAML file which contains basic configuration for all participants (subscriber as well as publisher). See following example for reference:

PY_TEST_PUBLISHER:
  host: "127.0.0.1"
  port: 9091
  protocol: http
  single_endpoint: null
  status_endpoint: /status
  subscribe_endpoint: /subscribe
  unsubscribe_endpoint: /unsubscribe
  request_endpoint: /request
  delivery_endpoint: null

The top level keys are the participant IDs, which must be agreed between the participants at first. Each participant system needs to have an IP address or hostname, a port and a protocol which should be used for access. You can also specify the endpoints for the different actions a participant is providing.

Note: There're some implementations which do not use special endpoints for each request type. To deal with them, set the property single_endpoint to a value other than null. This leads to the other endpoint configurations to become ignored and works for remote publishers as well as for the subscriber and publisher in this implementation.

Installation & Usage

Using this library is quite simple. Install it using

pip install pyvdv736

Then use a Subscriber or Publisher object to work with. See following example:

from vdv736.subscriber import Subscriber
from vdv736.delivery import SiriDelivery

def on_delivery(delivery: SiriDelivery) -> None:
    print('Delivery callback called...')

with Subscriber('PY_TEST_SUBSCRIBER', './participants.yaml') as subscriber:
    subscriber.set_callbacks(on_delivery)
    
    subscription_id = subscriber.subscribe('PY_TEST_PUBLISHER')
    ...
    subscriber.unsubscribe(subscription_id)

    while True:
        pass

See sample scripts in the demo folder.

License

This project is licensed under the Apache License. See LICENSE.md for more information.

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

pyvdv736-0.0.10.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

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

pyvdv736-0.0.10-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file pyvdv736-0.0.10.tar.gz.

File metadata

  • Download URL: pyvdv736-0.0.10.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyvdv736-0.0.10.tar.gz
Algorithm Hash digest
SHA256 99bfeb1563cf2af1bc7d2864be7e0b341e4cb0bfc393ee4fb4448d95212faf8d
MD5 c7cb73827cbd17db0d39f45bfb9ca9c2
BLAKE2b-256 b81f39c8c1976c27d1ac881e3a178678dba00002d4cd082156444f7c7db4c5ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvdv736-0.0.10.tar.gz:

Publisher: pypi-build-push-latest.yaml on sebastianknopf/pyvdv736

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyvdv736-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: pyvdv736-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyvdv736-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 23e4a8a76ad01fa2ba00ea236fbceca245993b717fcb2ff347f215d14fc1e8c0
MD5 e1dc3ad5db333430cb00ae60e5ba5e74
BLAKE2b-256 0980d32547b2d05638d379827b4f49da6e00f36a4fdfd93efb376121dbf34d5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvdv736-0.0.10-py3-none-any.whl:

Publisher: pypi-build-push-latest.yaml on sebastianknopf/pyvdv736

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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