Skip to main content

academy-diaspora-logger

Academy LogConfig that ships agent logs to a Diaspora Kafka topic, with built-in support for running agents on Globus Compute.

Also ships a diaspora CLI for managing credentials, fetching events, and clearing topics.

Installation

pip install academy-diaspora-logger

Globus Compute users: install this package on both your local machine and the remote endpoint so that dill can deserialize DiasporaLogConfig on the worker.


Topic names

Every Diaspora topic lives in a namespace tied to your Globus identity (e.g. ns-8fd0c242d30d). The fully-qualified Kafka topic is <namespace>.<topic>.

Anywhere this package takes a topic (DiasporaLogConfig, prefetch(), get_diaspora_events, diaspora context), you can pass either form:

  • Short name (lol1), which gets your default namespace added: ns-8fd0c242d30d.lol1.
  • Fully-qualified name (ns-8fd0c242d30d.lol1), which is used as-is.

So DiasporaLogConfig("lol1") and diaspora context --topic lol1 refer to the same topic. Because a . marks a qualified name, short names shouldn't contain one.

DiasporaLogConfig creates the topic if it doesn't exist yet. If it can't create the topic and the topic doesn't already exist, init_logging() / prefetch() raise DiasporaTopicError rather than silently sending logs nowhere. If diaspora context prints No partitions assigned for topic ..., that topic does not exist.


Python API

Local execution (threads / local processes)

from diaspora_logger import DiasporaLogConfig
from academy.manager import Manager
from academy.exchange import LocalExchangeFactory
from concurrent.futures import ThreadPoolExecutor

log_cfg = DiasporaLogConfig(kafka_topic)

async with await Manager.from_exchange_factory(
    factory=LocalExchangeFactory(),
    executors=ThreadPoolExecutor(max_workers=3),
    log_config=log_cfg,
) as manager:
    ...

Globus Compute (remote execution)

Call prefetch() on your local machine before launching agents. It uses your locally cached Globus credentials to fetch AWS IAM keys from the Diaspora service and embeds them in the config. The remote worker receives the keys via the pickled config and never needs Globus auth itself.

from diaspora_logger import DiasporaLogConfig
from academy.manager import Manager
from academy.exchange.cloud.client import HttpExchangeFactory
from globus_compute_sdk import Executor as GCExecutor

log_cfg = DiasporaLogConfig.prefetch(kafka_topic)

async with await Manager.from_exchange_factory(
    factory=HttpExchangeFactory(),
    executors=GCExecutor(endpoint_id),
    log_config=log_cfg,
) as manager:
    ...

Consuming events locally

from diaspora_context import get_diaspora_events

result = get_diaspora_events(
    topic_name=kafka_topic,
    time_horizon=time_before_ms,   # unix epoch milliseconds
)
for event in result["events"]:
    print(event)

CLI

After installation a diaspora command is available on your PATH.

diaspora setup

Register your Globus identity with Diaspora and create your IAM credentials.

diaspora setup

diaspora context

Fetch recent events from a topic and print them as JSON.

diaspora context --topic my-topic
diaspora context --topic ns-abc123.my-topic --lookback 7200   # last 2 hours
diaspora context --topic my-topic --time-horizon 1718000000000 --max-messages 500
Flag Default Description
--topic required Topic name (short or fully-qualified)
--lookback 3600 Seconds to look back from now
--time-horizon — Unix-epoch ms timestamp (overrides --lookback)
--timeout-ms 30000 Consumer poll timeout
--max-messages 10000 Maximum events to return

diaspora clear

Recreate (wipe) a topic.

diaspora clear my-topic

How it works

Scenario Auth How credentials reach Kafka
Local Globus tokens on disk KafkaProducer calls Client().create_key() automatically
Globus Compute prefetch() called locally once AWS IAM keys embedded in pickled config, used directly on worker

prefetch() calls Client().create_key() once on the local machine (where Globus tokens are cached) and stores the returned access_key, secret_key, and endpoint in the config object. When Academy pickles the config and ships it to the remote worker, those credentials travel with it. init_logging() on the remote then builds a raw kafka.KafkaProducer from those credentials — no Globus auth needed on the worker side.

Requirements

  • Python ≥ 3.10
  • academy-py >= 0.3.1
  • diaspora-event-sdk[kafka-python] >= 0.4.8 (older versions fail with No module named 'diaspora_event_sdk.sdk.auth')
  • kafka-python < 3
  • certifi (optional, recommended for macOS SSL)

Metadata

Release files for academy-diaspora-logger 1.0.3

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

Source distribution (sdist)

Source distribution for academy-diaspora-logger 1.0.3
File Size Uploaded Provenance Actions
academy_diaspora_logger-1.0.3.tar.gz 10.5 kB Without provenance Details for academy_diaspora_logger-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for academy-diaspora-logger 1.0.3
File Interpreter ABI Platform Actions
academy_diaspora_logger-1.0.3-py3-none-any.whl Python 3 none any Details for academy_diaspora_logger-1.0.3-py3-none-any.whl

Total release size: 22.4 kB

Release files / academy_diaspora_logger-1.0.3.tar.gz

Download URL academy_diaspora_logger-1.0.3.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
15c5627f80f1886799abab3a877d73e2c2c6e819da7ad245b01749e6f0f7043c
BLAKE2b-256 checksum
How to use checksums
cd4a957d6dfe575cd48d9650c3eb4d3d40ad54ece44c42950d7f4f216ba681b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / academy_diaspora_logger-1.0.3-py3-none-any.whl

Download URL academy_diaspora_logger-1.0.3-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
570882792d6af4c767182265f6b1e56c35128dd0335f7c99274f3ba3a9d0e0cd
BLAKE2b-256 checksum
How to use checksums
32f9b7075539a276fa00f6468c20a7b1a8cae39976f89957a5384e43d1f39b27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for academy-diaspora-logger 1.0.3

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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