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

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.

Installation

The MADSci event manager is available via the Python Package Index, and can be installed via:

pip install madsci.event_manager

This python package is also included as part of the madsci Docker image. You can see an example docker image in this example compose file.

Note that you will also need a MongoDB database (included in the example compose file)

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, define your event manager and mongodb services based on the example compose file.
# 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 OpenAPI docs served by your manager at the event server's /docs page.

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 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 EmailAlertConfig (madsci.common.types.event_types.EmailAlertConfig) in the email_alerts field of your EventManagerDefinition.

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.4.0.tar.gz (7.0 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.4.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: madsci_event_manager-0.4.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.24.2 CPython/3.9.22 Linux/6.11.0-1014-azure

File hashes

Hashes for madsci_event_manager-0.4.0.tar.gz
Algorithm Hash digest
SHA256 5829d4486c5d92cea261a3c2154a5e7596aff5bbb41b8994acaedb9bcd557267
MD5 399586b08ebfda2970a04a04f0d0bc2c
BLAKE2b-256 8846db839b1da036b71a825545cbfe465f87805174057707dec33a5c99fd562b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: madsci_event_manager-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.24.2 CPython/3.9.22 Linux/6.11.0-1014-azure

File hashes

Hashes for madsci_event_manager-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf1f20f8ccdcc94d237f8afa04f117698f281c7c61c66ac941e9f596b3a1e915
MD5 b8179301174bd0a5ff3dfd9fb54a6ab4
BLAKE2b-256 a6a8e86664a07ce8a7fd15ec4e6858915267acd8f1568c239ab138899288c9b8

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