events
Event types and reader for Snakemake logger plugin integration.
This module provides types and utilities for reading real-time events from the snakemake-logger-plugin-snakesee plugin. Events provide more accurate and timely job status information than log parsing.
Classes¶
EventReader ¶
Streaming reader for snakesee event files.
Reads events incrementally from a JSONL file, tracking the current position to only return new events on subsequent calls.
Attributes:
| Name | Type | Description |
|---|---|---|
event_file |
Path to the event file. |
Source code in snakesee/events.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
Attributes¶
has_events
property
¶
Check if the event file exists and has content.
Returns:
| Type | Description |
|---|---|
bool
|
True if event file exists and is non-empty. |
Functions¶
__init__ ¶
Initialize the event reader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_file
|
Path
|
Path to the event file. |
required |
read_new_events ¶
read_new_events() -> list[SnakeseeEvent]
Read events added since last call.
Returns:
| Type | Description |
|---|---|
list[SnakeseeEvent]
|
List of new events. Empty list if no new events or file doesn't exist. |
Source code in snakesee/events.py
reset ¶
EventType ¶
Bases: str, Enum
Event types from the snakesee logger plugin.
These mirror the event types defined in the logger plugin.
Source code in snakesee/events.py
SnakeseeEvent
dataclass
¶
A single event from the logger plugin.
This is a frozen dataclass to ensure events are immutable once parsed.
Attributes:
| Name | Type | Description |
|---|---|---|
event_type |
EventType
|
Type of the event. |
timestamp |
float
|
Unix timestamp when the event occurred. |
job_id |
int | None
|
Snakemake job ID (for job events). |
rule_name |
str | None
|
Name of the rule (for job events). |
wildcards |
tuple[tuple[str, str], ...] | None
|
Wildcard values for the job. |
threads |
int | None
|
Number of threads allocated to the job. |
resources |
tuple[tuple[str, Any], ...] | None
|
Resource requirements for the job. |
input_files |
tuple[str, ...] | None
|
Tuple of input file paths. |
output_files |
tuple[str, ...] | None
|
Tuple of output file paths. |
duration |
float | None
|
Job duration in seconds (for finished/error events). |
error_message |
str | None
|
Error message (for error events). |
completed_jobs |
int | None
|
Number of completed jobs (for progress events). |
total_jobs |
int | None
|
Total number of jobs (for progress events). |
workflow_id |
str | None
|
Unique workflow identifier. |
Source code in snakesee/events.py
Attributes¶
wildcards_dict
property
¶
Get wildcards as a dictionary.
Returns:
| Type | Description |
|---|---|
dict[str, str] | None
|
Wildcards as a dict, or None if not set. |
Functions¶
from_json
classmethod
¶
from_json(json_str: str | bytes) -> SnakeseeEvent
Parse from JSON line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_str
|
str | bytes
|
JSON string or bytes to parse. |
required |
Returns:
| Type | Description |
|---|---|
SnakeseeEvent
|
Parsed SnakeseeEvent instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the JSON is invalid or has an unknown event type. |
JSONDecodeError
|
If the JSON cannot be parsed. |
Source code in snakesee/events.py
Functions¶
get_event_file_path ¶
Get the path to the event file for a workflow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workflow_dir
|
Path
|
Path to the workflow directory. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the event file. |