logging.EventLogger
logging.EventLogger(self, event_model=BaseEvent, env=None, run_number=None)Methods
| Name | Description |
|---|---|
| get_events_by_entity | Return all events associated with a specific entity_id. |
| get_events_by_event_name | Return all events of a specific event_type. |
| get_events_by_event_type | Return all events of a specific event_type. |
| get_events_by_run | Return all events associated with a specific entity_id. |
| log_arrival | Helper to log an arrival event with the correct event_type and event fields. |
| log_custom_event | Log a custom event. The ‘event’ here can be any string describing the queue event. |
| log_departure | Helper to log a departure event with the correct event_type and event fields. |
| log_queue | Log a queue event. The ‘event’ here can be any string describing the queue event. |
| log_resource_use_end | Log the end of resource use. Requires resource_id. |
| log_resource_use_start | Log the start of resource use. Requires resource_id. |
| plot_entity_timeline | Plot a timeline of events for a given entity. |
| to_csv | Write the log to a CSV file. |
| to_dataframe | Convert the event log to a pandas DataFrame. |
| to_json | Write the event log to a JSON file or file-like buffer. |
| to_json_string | Return the event log as a pretty JSON string. |
get_events_by_entity
logging.EventLogger.get_events_by_entity(entity_id, as_dataframe=True)Return all events associated with a specific entity_id.
get_events_by_event_name
logging.EventLogger.get_events_by_event_name(event_name, as_dataframe=True)Return all events of a specific event_type.
get_events_by_event_type
logging.EventLogger.get_events_by_event_type(event_type, as_dataframe=True)Return all events of a specific event_type.
get_events_by_run
logging.EventLogger.get_events_by_run(run_number, as_dataframe=True)Return all events associated with a specific entity_id.
log_arrival
logging.EventLogger.log_arrival(
entity_id,
time=None,
pathway=None,
run_number=None,
**extra_fields,
)Helper to log an arrival event with the correct event_type and event fields.
log_custom_event
logging.EventLogger.log_custom_event(
entity_id,
event_type,
event,
time=None,
pathway=None,
run_number=None,
**extra_fields,
)Log a custom event. The ‘event’ here can be any string describing the queue event. An ‘event_type’ must also be passed, but can be any string of the user’s choosing.
log_departure
logging.EventLogger.log_departure(
entity_id,
time=None,
pathway=None,
run_number=None,
**extra_fields,
)Helper to log a departure event with the correct event_type and event fields.
log_queue
logging.EventLogger.log_queue(
entity_id,
event,
time=None,
pathway=None,
run_number=None,
**extra_fields,
)Log a queue event. The ‘event’ here can be any string describing the queue event.
log_resource_use_end
logging.EventLogger.log_resource_use_end(
entity_id,
resource_id,
time=None,
pathway=None,
run_number=None,
**extra_fields,
)Log the end of resource use. Requires resource_id.
log_resource_use_start
logging.EventLogger.log_resource_use_start(
entity_id,
resource_id,
time=None,
pathway=None,
run_number=None,
**extra_fields,
)Log the start of resource use. Requires resource_id.
plot_entity_timeline
logging.EventLogger.plot_entity_timeline(
entity_id,
split_by_entity_type=False,
show_labels=False,
)Plot a timeline of events for a given entity.
This method visualizes the sequence of events for a specified entity from the event log as a scatter plot. The timeline is plotted using Plotly, with events displayed along the time axis. Events can be split vertically by their type or shown by event labels. Optionally, labels can be displayed directly on the plot.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| entity_id | any | Identifier of the entity whose events should be plotted. | required |
| split_by_entity_type | bool | If True, the y-axis shows event types to separate events vertically. If False, the y-axis shows the event labels. | False |
| show_labels | bool | If True, the event labels are displayed as text on the plot. If False, no labels are shown. | False |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If the event log is empty. | |
| ValueError | If no events are found for the given entity_id. |
See Also
to_dataframe : Convert the event log into a DataFrame for analysis.
Notes
- The plot is displayed using
plotly.express.scatter. - The y-axis is treated as categorical to improve readability.
- Marker styling includes a fixed size and outline color for clarity.
to_csv
logging.EventLogger.to_csv(path_or_buffer)Write the log to a CSV file.
to_dataframe
logging.EventLogger.to_dataframe()Convert the event log to a pandas DataFrame.
to_json
logging.EventLogger.to_json(path_or_buffer, indent=2)Write the event log to a JSON file or file-like buffer.
to_json_string
logging.EventLogger.to_json_string(indent=2)Return the event log as a pretty JSON string.