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.

MADSci Event Manager Architecture Diagram

Features

  • Centralized logging from distributed lab components
  • Event querying with structured filtering
  • Arbitrary event data support with standard schema
  • Python logging-style log levels
  • Alert notifications (email, etc.)

Installation

See the main README for installation options. This package is available as:

Dependencies: MongoDB database (see the example_lab)

Usage

Quick Start

Use the example_lab as a starting point:

# Start with working example
docker compose up  # From repo root
# Event Manager available at http://localhost:8001/docs

# Or run standalone
python -m madsci.event_manager.event_server

Manager Setup

For custom deployments, create an Event Manager definition:

madsci manager add -t event_manager

See example_event.manager.yaml for configuration options.

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_client.info("This does the same thing")
event = Event(
    event_type="NODE_CREATE",
    log_level=EventLogLevel.DEBUG,
    event_data="This logs a 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 the 50 most recent events
event_client.get_events(number=50)
# Get all events from a specific node
event_client.query_events({"source": {"node_id": "01JJ4S0WNGEF5FQAZG5KDGJRBV"}})

event_client.alert(event) # Will force firing any configured alert notifiers on this event

Alerts

The Event Manager provides some native alerting functionality. A default alert level can be set in the event manager definition's alert_level, which will determine the minimum log level at which to send an alert. Calls directly to the EventClient.alert method will send alerts regardless of the alert_level.

You can configure Email Alerts by setting up an EmailAlertsConfig (madsci.common.types.event_types.EmailAlertsConfig) in the email_alerts field of your EventManagerSettings.

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.5.1.tar.gz (42.1 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.5.1-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: madsci_event_manager-0.5.1.tar.gz
  • Upload date:
  • Size: 42.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.26.1 CPython/3.9.24 Linux/6.11.0-1018-azure

File hashes

Hashes for madsci_event_manager-0.5.1.tar.gz
Algorithm Hash digest
SHA256 f89e548c2b94c576729b9551f7762ae29acb94a21135421c5d09ad52897f746c
MD5 02cc194c1375f71693f777bc7ac250bd
BLAKE2b-256 fdf46a67a1b9122214c113e88e56815cdf6d43f67569ea9cffe30de389ede440

See more details on using hashes here.

File details

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

File metadata

  • Download URL: madsci_event_manager-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 41.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.26.1 CPython/3.9.24 Linux/6.11.0-1018-azure

File hashes

Hashes for madsci_event_manager-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4afa520480b327fed1e1623aa95da2ff62dd74ce4fdca6ba7618e52f66769cde
MD5 286fdb104037c35f44fa13421ad24c63
BLAKE2b-256 aad1a3ce4c07beecdda77f047a11bdd947ae5433410bd25f3834a5647374c650

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