API

scitex-events — general-purpose async event bus (standalone).

Emit events from CLI, HPC, or any process. Events are stored locally as state files and optionally forwarded to the cloud API via webhook.

Usage

>>> from scitex_events import emit, latest
>>> emit("test_complete", project="figrecipe", status="success",
...      payload={"exit_code": 0, "module": "stats"})
>>> latest("test_complete")
{"type": "test_complete", "project": "figrecipe", ...}
class scitex_events.Event(type, project, status='success', payload=<factory>, source='local', timestamp='')[source]

A single event in the SciTeX event bus.

Parameters:
  • type (str) – Event type (e.g., “test_complete”, “job_done”, “build_result”).

  • project (str) – Project name this event belongs to.

  • status (str) – Outcome: “success” or “failure”.

  • payload (dict) – Arbitrary data specific to the event type.

  • source (str) – Where the event originated: “local”, “hpc”, “ci”.

  • timestamp (str) – ISO-format timestamp, auto-generated if not provided.

type: str
project: str
status: str = 'success'
payload: dict[str, Any]
source: str = 'local'
timestamp: str = ''
to_dict()[source]

Convert to JSON-serializable dictionary.

Return type:

dict[str, Any]

classmethod from_dict(data)[source]

Create Event from dictionary.

Return type:

Event

scitex_events.emit(event_type, project, status='success', payload=None, source='local')[source]

Emit an event to state file and optional webhook.

Always writes to ~/.scitex/events/{type}_latest.json. Also appends to ~/.scitex/events/history.jsonl. If SCITEX_API_KEY is set, POSTs to the cloud API (best-effort).

Parameters:
  • event_type (str) – Event type (e.g., “test_complete”).

  • project (str) – Project name.

  • status (str) – “success” or “failure”.

  • payload (dict, optional) – Arbitrary event data.

  • source (str) – Origin: “local”, “hpc”, “ci”.

Returns:

The emitted event object.

Return type:

Event

scitex_events.latest(event_type=None)[source]

Read the latest event from state files.

Parameters:

event_type (str, optional) – If given, read the latest event of this type. If None, read the most recent event across all types.

Returns:

Event data, or None if no events found.

Return type:

dict or None

scitex_events.history(limit=20)[source]

Read recent events from history file.

Parameters:

limit (int) – Maximum number of events to return.

Returns:

Events in reverse chronological order.

Return type:

list of dict

scitex_events.list_types()[source]

Return list of known event type names.

Return type:

list[str]

scitex_events.get_type_info(event_type)[source]

Return metadata for an event type, or empty dict if unknown.

Return type:

dict[str, Any]