Quickstart

The official Nominal Python client.

Nominal is the leading platform for operationalizing test data.

Installation

If you don’t have Python installed, you can download it for free from the Python Software Foundation. We support versions 3.9 through 3.12.

To check whether Python is installed, open your shell (the Terminal application on Mac, and Command Prompt on Windows), and type python⏎. If you receive an error, you likely do not have Python installed on your machine.

The Nominal Python Client can be installed with pip:

$$ pip install nominal
Installing with Extras

The nominal client contains several opt-in features that come with their own additional, heavier dependencies. Today, these include:

  • hdf5: ingesting / working with HDF5 files
  • protos: directly streaming data to Nominal using protobuf

You may install these using, for example, pip install nominal[hdf5], or pip install nominal[hdf5,protos] for the latest version of the client. See here for more information.

Version

We use semantic versioning for the Nominal Python Client. To see the client version, run the following from within Python:

1import nominal
2
3print(nominal.__version__)
Upgrading `nominal` version

To update the version of the client installed with pip, run:

$$ pip install --upgrade nominal

As a best practice, we recommend regularly updating your client to ensure that you receive bugfixes and other improvements in a timely fashion.

Connect to Nominal

Concepts
  • Base URL: The URL through which the Nominal API is accessed (typically https://api.gov.nominal.io/api; shown under Settings → API keys).
  • Workspace: A mechanism by which to isolate datasets; each user has one or more workspace, and data in one cannot be seen from another. Note that a token / API key is attached to a user, and may access multiple workspaces.
  • Profile: A combination of base URL, API key, and workspace.

There are two primary ways of authenticating the Nominal Client. The first is to use a profile stored on disk, and the second is to use a token directly.

Run the following in a terminal and follow on-screen prompts to set up a connection profile:

$$ nom config profile add default
>
># Alternatively, if `nom` is missing from the path:
>$ python -m nominal config profile add default

Here, “default” can be any name chosen to represent this profile (reminder: a profile represents a base URL, API key, and workspace).

The profile will be stored in ~/.config/nominal/config.yml, and can then be used to create a client:

1from nominal.core import NominalClient
2
3client = NominalClient.from_profile("default")
4
5# Get details about the currently logged-in user to validate authentication
6# Will display an object like: `User(display_name='your_email@your_company.com', ...)`
7print(client.get_user())

If you have previously used nom to store credentials, prior to the availability of profiles, you will need to migrate your old configuration file (~/.nominal.yml) to the new format (~/.config/nominal/config.yml).

You can do this with the following command:

$nom config migrate
>
># Or, if `nom` is missing from your path:
>python -m nominal config migrate
1from nominal.core import NominalClient
2
3# Get an instance of the client using provided credentials
4client = NominalClient.from_token("<insert api key>")
5
6# Get details about the currently logged-in user to validate authentication
7# Will display an object like: `User(display_name='your_email@your_company.com', ...)`
8print(client.get_user())

NOTE: you should never share your Nominal API key with anyone. We therefore recommend that you not save it in your code and/or scripts.

  • If you trust the computer you are on, use nom to store the credential to disk.
  • Otherwise, use a password manager such as 1password or bitwarden to keep your token safe.
If you’re not sure whether your company has a Nominal tenant, please reach out to us.

Usage examples

Upload a Dataset

Download this example CSV to your local computer:

1import pandas
2
3df = pandas.read_csv('hf://datasets/nominal-io/frosty-flight/frosty_flight_1k_rows.csv')
4df.to_csv('frosty_flight_1k_rows.csv', index=False)

Then upload the CSV file to Nominal:

1from nominal.core import NominalClient
2
3client = NominalClient.from_profile("default") # replace with your profile name
4
5dataset = client.create_dataset('Frosty Flight')
6dataset.add_tabular_data_to_dataset(
7 'frosty_flight_1k_rows.csv',
8 timestamp_column = 'source_time',
9 timestamp_type = 'iso_8601',
10)
11
12print('Uploaded dataset:', dataset.rid)

See client.create_dataset()

Create a Run

In Nominal, Runs are time bounded views onto multimodal test data - including Datasets, Videos, Logs, and database connections.

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

1from nominal.core import NominalClient
2
3client = NominalClient.from_profile("default") # replace with your profile name
4
5flight_simulator_run = client.create_run(
6 name = 'High precipitation flight',
7 start = '2024-09-09T12:35:00Z',
8 end = '2024-09-09T13:18:00Z',
9)
10
11print("Created run:", flight_simulator_run.rid)

See client.create_run()

Add Data to a Run

(Scroll up to Upload a dataset to see how the csv_dataset was created.)

1flight_simulator_run.add_dataset(
2 dataset = csv_dataset,
3 ref_name = 'high-precipitation-flight'
4)

See Run.add_dataset()

Create a Run with Data

Create a Run and add a Dataset to it in one swoop.

1from nominal.core import NominalClient
2
3client = NominalClient.from_profile("default") # replace with your profile name
4
5dataset = client.create_dataset("my_dataset", "description")
6dataset.add_tabular_data('frosty_flight_1k_rows.csv', timestamp_column = 'source_time', timestamp_type = 'iso_8601')
7dataset.poll_until_ingestion_completed()
8
9run = client.create_run("my_run", dataset.bounds.start, dataset.bounds.end, "description")
10run.add_dataset(dataset)

Update Run metadata

1run = client.get_run('ri.scout.gov-staging.run.ce205f7e-9ef1-4a8b-92ae-11edc77441c6')
2run.update(name = 'New Run Title')

See Run.update()

Please refer to the Function Reference and guides on the left-hand sidebar for more extensive examples.

Appendix

Tips & tricks for test engineers getting started with Python.

Python is the fastest growing language in STEM for data analytics. It’s free and functionally equivalent to MATLAB in many respects.

Python IDEs

If you’re new to scripting in Python, below are a few recommendations for Python IDEs (integrated development environments).

Jupyter

The guides on this website are styled after Jupyter notebook, a free and beginner-friendly analysis environment for Python. If you’re creating a lot of charts, or enjoy narrating your analysis code with text, you may find Jupyter productive.

VSCode

VSCode is a more minimalist, equally popular development environment for Python. If you’re creating automation scripts in Python that do not involve charts or analysis, the streamlined UX of VSCode may be appealing.