Events#

An event marks a moment or interval in test data that someone should see, such as an engine start or an out-of-limit reading. Events can come from people reviewing data, from checklists or from your scripts.

Connect the client#

This guide assumes you have installed the client and setup your API keys.

from nominal.core import NominalClient

client = NominalClient.from_profile("default")

Create an event#

Create an event on an asset with create_event(). A zero duration, the default, marks a single moment.

from datetime import datetime, timedelta, timezone

from nominal.core import EventType

asset = client.get_asset("<ASSET_RID>")
event = asset.create_event(
    "Engine start",
    EventType.INFO,
    start=datetime.now(timezone.utc),
    duration=timedelta(seconds=10),
    properties={"test_phase": "burn"},
    labels=["critical"],
)

EventType is the event’s level: INFO, FLAG, ERROR or SUCCESS. To create an event on several assets, or on none, use create_event() with assets=[...]. create_event() creates one on a run.

Find events#

search_events() combines its filters with AND:

now = datetime.now(timezone.utc)
events = client.search_events(
    after=now - timedelta(days=1),  # ends after this time
    before=now,  # starts before this time
    assets=[asset],
    labels=["critical"],
)

after and before find events that overlap the window. The reference lists the other filters, such as event_type, created_by and workbook.

Retrieve events by RID with get_event(), which raises if the event doesn’t exist. get_events() takes several RIDs and leaves out any that don’t resolve. To copy an event’s RID in the UI, click the event in a workbook and select Copy RID.

Update or archive an event#

update() replaces each field you pass and leaves fields passed as None unchanged. Its type argument is required, so pass type=None to keep the type:

event.update(labels=[*event.labels, "reviewed"], type=None)

archive() hides the event:

event.archive()