Add Logs to a Run

To use this guide, install the Nominal Python library with pip3 install nominal.

See Quickstart for more details.

Please contact us if you’re not sure whether your organization has access to Nominal.

Log files are a standard output from aircraft, land vehicles, manufacturing equipment, and practically any present-day machine with an on-board computer.

Nominal makes it simple to upload log files to a Nominal Run for collaborative inspection, root-cause analysis, and automated alerting.

In Nominal, Runs are containers of multimodal test data - including Datasets, Videos, Logs, and database connections.

To see your organization’s latest Runs, head over to the Runs page

Connect to Nominal

Get your Nominal API token from your User settings page.

See the Quickstart for more details on connecting to Nominal from Python.

1import nominal.nominal as nm
2
3nm.set_token(
4 base_url = 'https://api.gov.nominal.io/api',
5 token = '* * *' # Replace with your Access Token from
6 # https://app.gov.nominal.io/settings/user?tab=tokens
7)
If you’re not sure whether your company has a Nominal tenant, please reach out to us.

Create a Run

First, we’ll create an empty run to upload our log file:

1import polars as pl
2import nominal as nm
3
4df = pl.read_csv('hf://datasets/nominal-io/frosty-flight/frosty_flight_1k_rows.csv')
5df.write_csv('frosty_flight_1k_rows.csv')
6
7flight_simulator_run = nm.create_run_csv(
8 'frosty_flight_1k_rows.csv',
9 name = 'Frosty Flight',
10 timestamp_column = 'source_time',
11 timestamp_type = 'iso_8601'
12)
13
14print(flight_simulator_run.rid)

If you navigate to your organization’s Runs page, you’ll see a Run at the top called “‘Frosty Flight.”

Generate a log file

We’ll generate a demo log file to add to our Run.

To make the demo log file visually interesting and distinct, we’ll add a random sparkline chart to each log file line:

1import random
2
3def generate_sparkline(length=10):
4 """Generate a random sparkline in ASCII."""
5 data = [random.randint(1, 10) for _ in range(length)]
6 chars = "▁▂▃▄▅▆▇█"
7 max_value = max(data)
8 min_value = min(data)
9
10 def normalize(value):
11 if max_value == min_value:
12 return 0
13 return int((value - min_value) / (max_value - min_value) * (len(chars) - 1))
14
15 sparkline = ''.join(chars[normalize(value)] for value in data)
16 return sparkline

Nominal log files are defined in Python as a list of tuples:

1logs = [
2 (df['source_time'][i], f"Log message {i} {generate_sparkline(random.randint(15, 40))}")
3 for i in range(len(df['source_time']))
4]
5
6for row in logs[:5]:
7 print(row)
('2024-06-08T05:58:42.000Z', 'Log message 0 ▅▅▅▂▅█▆▆▁▅▆▅▇███▆▅▄█')
('2024-06-08T05:58:51.000Z', 'Log message 1 ▆▃▃▃▅▃▄▃▅▁▁▂▁▄▄█▄▇▂▇▆▁▇█▃▁▅▆▃▁█▆')
('2024-06-08T05:58:52.000Z', 'Log message 2 ▁▂▄▃▄▄▂▄▃▆▁▇▁▄▅▄▄▄▄█▁▄▇▂▂▁')
('2024-06-08T05:58:52.000Z', 'Log message 3 ▁█▅▅▆▃▇▂█▂▇▃▄▂▇▆▁▁▄▃▄▁█▄█▂')
('2024-06-08T05:58:52.000Z', 'Log message 4 ▄██▁▄▆▃▁█▄▃▂▄▁▇▄')

Finally, add the log file to flight_simulator_run:

1import nominal.nominal as nm
2
3log_set = nm.create_log_set(
4 logs=logs,
5 name="Sparkline Logs",
6 description="description"
7)
8
9run = nm.get_run(run_rid)
10ref_name = "fun_with_logs"
11
12run.add_log_set(ref_name, log_set)

If you visit the Datasets tab of the ‘Frosty Flight’ Runs page, you’ll see “Sparkline Logs” in the datasets table.

To inspect “Sparkline Logs”, open the Run in an empty Workbook and click on the “Logs” pane at the bottom of the window.

Retrieve log files

🚧 This will be included in an upcoming release. Check back soon!