Skip to main content

The Modular Autonomous Discovery for Science (MADSci) Event and Logging Manager.

Project description

MADSci Event Manager

Handles distributed logging and events throughout a MADSci-powered Lab.

Notable Features

  • Collects logs from distributed components of the lab and centralizes them
  • Allows for querying of events
  • Can accept arbitrary event data
  • Enforces a standard Event schema, allowing for structured querying and filtering of logs.
  • Supports python logging-style log levels.

Usage

Manager

To create and run a new MADSci Event Manager, do the following in your MADSci lab directory:

  • If you're not using docker compose, provision and configure a MongoDB instance.
  • If you're using docker compose, create or add the following to your Lab's compose.yaml, defining your docker compose services for the EventManager and a MongoDB database to store events.
name: madsci_example_lab
services:
  mongodb:
    container_name: mongodb
    image: mongodb/mongodb-community-server:latest
    ports:
      - 27017:27017
  event_manager:
    container_name: event_manager
    image: madsci:latest
    build:
      context: ..
      dockerfile: Dockerfile
    environment:
      - USER_ID=1000
      - GROUP_ID=1000
    network_mode: host
    volumes:
      - /path/to/your/lab/direcotry:/home/madsci/lab/
      - .madsci:/home/madsci/.madsci/
    command: python -m madsci.event_manager.event_server
    depends_on:
      - mongodb
# Create an Event Manager Definition
madsci manager add -t event_manager
# Start the database and Event Manager Server
docker compose up
# OR
python -m madsci.event_manager.event_server

You should see a REST server started on the configured host and port. Navigate in your browser to the URL you configured (default: http://localhost:8001/) to see if it's working.

You can see up-to-date documentation on the endpoints provided by your event manager, and try them out, via the swagger page served at http://your-event-manager-url-here/docs.

Client

You can use MADSci's EventClient (madsci.client.event_client.EventClient) in your python code to log new events to the event manager, or fetch/query existing events.

from madsci.client.event_client import EventClient
from madsci.common.types.event_types import Event, EventLogLevel, EventType

event_client = EventClient(
    event_server="https://127.0.0.1:8001", # Update with the host/port you configured for your EventManager server
)

event_client.log_info("This logs a simple string at the INFO level, with event_type LOG_INFO")
event = Event(
    event_type="NODE_CREATE",
    log_level=EventLogLevel.DEBUG,
    event_data="This logs a more complex NODE_CREATE event at the DEBUG level. The event_data field should contain relevant data about the event (in this case, something like the NodeDefinition, for instance)"
)
event_client.log(event)
event_client.log_warning(event) # Log the same event, but override the log level.

# Get recent events
event_client.get_events(number=50)
# Get all events from a specific node
event_client.query_events({"source": {"node_id": "01JJ4S0WNGEF5FQAZG5KDGJRBV"}})

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

madsci_event_manager-0.0.3.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

madsci_event_manager-0.0.3-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

Details for the file madsci_event_manager-0.0.3.tar.gz.

File metadata

  • Download URL: madsci_event_manager-0.0.3.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.22.3 CPython/3.9.2 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for madsci_event_manager-0.0.3.tar.gz
Algorithm Hash digest
SHA256 39920893bc46fb1d8fee118bb3a462eb3f9e7922396e5b87b72b523ecc3afefd
MD5 c0596ffdf62969a0cb42b113862914a9
BLAKE2b-256 bedc18a8c3f3d97922f8ab72e54158a587af45b59ba0ae4e3ec25198c7af8341

See more details on using hashes here.

File details

Details for the file madsci_event_manager-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: madsci_event_manager-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 2.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.22.3 CPython/3.9.2 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for madsci_event_manager-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8a6a8858f5e7fff9f591c0c703420a2ac4ea2427a09f9110fe433144b6d9e194
MD5 3a445e37c6b400814b6b2b909f0afdab
BLAKE2b-256 56ae968f1d559479c0b9d0d200ba8480d0864d0e71841f5279bf0e017a4482ac

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