Skip to main content

Diaspora Event Fabric SDK

pre-commit.ci status Tests Release GitHub Release PyPI Version License Python Versions

Installation

pip install "diaspora-event-sdk[kafka-python]"

The kafka-python extra installs kafka-python, which the SDK's KafkaProducer and KafkaConsumer need. It accepts kafka-python>=2.1,<3: release 2.1 or a later 2.x. With kafka-python 3 installed, the SDK still imports, and KafkaProducer, KafkaConsumer and reliable_client_creation raise ImportError when called. kafka-python 3 (checked on 3.0.11) does not apply allow_auto_create_topics=False, skips a consumer's auto-commit on unsubscribe(), and leaves a producer using a full CPU core once a topic it wrote to is deleted.

To use only the web service, including producing and consuming over REST, install the SDK without the extra:

pip install diaspora-event-sdk

Produce and consume over REST

The web service produces and consumes records over HTTPS with your Globus login, so a client needs no Kafka client and no access key. Client.produce and Client.produce_batch send records to the produce routes, which take the request bodies of Confluent's REST API v3. RESTConsumer wraps the consumer routes, which take the paths and bodies of Confluent REST Proxy v2 under /api/v2/consumers. Name topics and consumer groups without your namespace (Client().namespace): the service adds it, so the group my-group is the Kafka consumer group <namespace>.my-group.

from diaspora_event_sdk import Client, RESTConsumer

c = Client()
c.create_topic("my-topic")
c.produce("my-topic", {"step": 1, "loss": 0.52}, key="job-42")
c.produce_batch("my-topic", [{"value": {"step": 2}}, {"value": "done"}])

with RESTConsumer("my-group", client=c, format="json", auto_offset_reset="earliest") as consumer:
    consumer.subscribe(["my-topic"])
    for record in consumer.fetch(timeout_ms=5000):
        print(record["offset"], record["key"], record["value"])
    consumer.commit()

Client.produce writes a value of bytes as BINARY, and anything else, a str included, as JSON, which json.loads reads back the same as the SDK's KafkaProducer output: produce(topic, "done") writes the JSON string "done". The bytes differ, since the service writes compact JSON and KafkaProducer's default serializer adds spaces after , and :. That serializer also refuses bytes, which produce sends as BINARY. A key of bytes is sent as BINARY, a str as STRING (plain text), and anything else as JSON. The value_type and key_type arguments ("BINARY", "JSON" or "STRING") choose the type instead. Each record of Client.produce_batch is a dict of the same arguments (value, key, headers, timestamp, value_type and key_type) with an optional id.

A produce request is retried only when the service refuses it before sending the record (429 or 503) or when no connection was made. Any other error raises, since the record may have been written.

A consumer's format is binary, the default, or json. A binary consumer returns keys and values as bytes. A json consumer returns a key or value that is one JSON value as that value, and other text as str: a STRING key "42" comes back as the number 42. Header values are bytes in both formats.

The service drops consumer instances when it is deployed or restarted, and closes an instance idle for 5 minutes, which includes the time your code spends processing a fetch's records. RESTConsumer then creates the instance again with the same name and settings, subscribes or assigns as before, and retries the request once. The new instance starts from the group's committed offsets, so records fetched since the last commit can be fetched again. A commit() without offsets would commit the new instance's positions, which hold nothing fetched. So when the records fetched since the last commit came from an instance that is gone, whichever request found it gone, commit() sends nothing and raises CommitLostError, and the next fetch resumes at the group's last commit. A commit() with offsets on a new subscribed instance raises CommitLostError too: that instance gets its partitions at its first fetch, so commit the offsets again after a fetch.

RESTConsumer needs version 0.7.0 or later of the web service. The service's API reference gives every route, limit and error code.

Examples

  • DiasporaDemo.ipynb — Authentication, user/key/topic management, and Kafka produce/consume
  • ConsumerRESTDemo.ipynb — Produce and consume over REST, first with raw HTTP requests and then with the SDK

Acknowledgment

We thank the entire team of the Diaspora Project for their helpful comments and feedback. This material is based upon work supported by the U.S. Department of Energy (DOE), Office of Science, Office of Advanced Scientific Computing Research, under Contract DE-AC02-06CH11357.

License

This project is licensed under the Apache License 2.0.

Metadata

Release files for diaspora-event-sdk 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for diaspora-event-sdk 0.5.1
File Size Uploaded Provenance Actions
diaspora_event_sdk-0.5.1.tar.gz 63.3 kB With provenance Details for diaspora_event_sdk-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for diaspora-event-sdk 0.5.1
File Interpreter ABI Platform Actions
diaspora_event_sdk-0.5.1-py3-none-any.whl Python 3 none any Details for diaspora_event_sdk-0.5.1-py3-none-any.whl

Total release size: 123.2 kB

Release files / diaspora_event_sdk-0.5.1.tar.gz

Download URL diaspora_event_sdk-0.5.1.tar.gz
Size 63.3 kB
Tags Source
SHA-256 checksum
How to use checksums
557f0f8e81d54423a49d3e46c13e4c2039711326a00c64f7eb92a546f074eed0
BLAKE2b-256 checksum
How to use checksums
fce06b601a44496e3518e92aa7b2b34612424820ece00495bb20f77c883fdbfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / diaspora_event_sdk-0.5.1-py3-none-any.whl

Download URL diaspora_event_sdk-0.5.1-py3-none-any.whl
Size 59.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f377a0abf703ce8f88a6d1d9fdcd1af03cc23ce8cb643214479af1abe934cc2
BLAKE2b-256 checksum
How to use checksums
bbb2da107f381195229d2b6522fd728da20a8bf0cdeff5598b3cec80d34d19d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for diaspora-event-sdk 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for diaspora_event_sdk-0.5.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page