Skip to main content

Academy LogConfig that ships agent logs to Diaspora/Kafka, with support for Globus Compute remote execution

Project description

academy-diaspora-logger

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

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.

Usage

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:
    ...

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 < 3
  • certifi (optional, recommended for macOS SSL)

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

academy_diaspora_logger-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

academy_diaspora_logger-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file academy_diaspora_logger-0.1.0.tar.gz.

File metadata

  • Download URL: academy_diaspora_logger-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for academy_diaspora_logger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 06a8fa0b47c3719497f142cf3e1da98f946bdc4cce18570f4ff766b914f4368e
MD5 99ace18a452476f6817f92468fdb8ab2
BLAKE2b-256 611b3dd9f4ec84dde433fa6e38b24182fa4829d35e39bd8b35f2e8cdb5aabc7b

See more details on using hashes here.

File details

Details for the file academy_diaspora_logger-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for academy_diaspora_logger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 07ce1533b4ffe2a4246ee32ed2960a2a2c623d408761153ff63d480ed43594ca
MD5 c31ac549f2bd8a6b20aba46b2add3549
BLAKE2b-256 d2866cd51b4947cd3f30da768fd76472e79c7dcf02a2687125d6a3ac0715ebcd

See more details on using hashes here.

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