Assets in Nominal with Python
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.
Assets organize test data around physical systems, rather than around individual test events. For example, an Asset might be an airplane or a satellite. Each Asset can connect to runs, workbooks, and checklists.
Connect to Nominal
To add an Asset, first connect to your Nominal platform tenant.
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.
Storing credentials to disk
Run the following in a terminal and follow on-screen prompts to set up a connection profile:
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:
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:
Directly using credentials in your scripts
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.
Create an Asset
To create an Asset, use create_asset()
.
You can, optionally, add a description, properties, and labels:
Add data to an asset
To add a Dataset to an Asset, use Asset.add_dataset()
:
Datasets are the file representation of Nominal’s Data Source primitive. Most often, Datasets are tabular files with at least one time dimension. Datasets can also be video files.
Head over to the Datasets page to see your organization’s most recently uploaded Datasets.
Asset data with data scope names
To add a Dataset with a data scope name to an Asset, set the data_scope_name
parameter in Asset.add_dataset()
.
Data scope names are a namespace for data sources that share common channels, but do not necessarily belong to the same Asset. They allow data sources with similar schema to be referenced as a group. For example, data sources with the same data scope name can share Workbook templates and Checklists.
Check if an Asset exists
You can check for a Asset’s existence with nm.search_assets().
Update an Asset
Asset metadata can be updated with Asset.update()
:
For example, to set an Asset’s title:
Please see Asset.update()
for all updatable metadata.
Asset attachments
File attachments such as PDF reports or PowerPoints can be added to Assets:
Retrieve an Asset
Like Datasets, Assets can be retrieved by their resource ID (“RID”):
To retrieve an Asset’s RID, visit its detail page and click on the clipboard icon next to “ID” in the right-hand drawer:
All Nominal primitives (eg Datasets, Runs, Workbooks, and Checks) have a unique identifier called a “Resource ID”.
Resource IDs may be referred to as “RIDs”, or simply “IDs”, throughout the platform. They can be obtained from
a primitive’s detail page (or URL) and have a format that looks like ri.catalog.cerulean-staging.dataset.e5ede17b-05f9-404d-aaf5-ba85c99761a2
.
Query Assets
Assets can be queried with nm.search_assets().
For example, to retrieve all assets with the label “NEW-MOTOR-VENDOR”:
See nm.search_assets() for all Assets search parameters.
Remove Asset Data Sources
The list data_sources
can contain Connection, Dataset, Video instances, or rids as string.
Archive an Asset
Once an Asset is no longer needed, it can be archived.
This does not delete the Asset, but makes it invisible on the web.
If you save the rid
of the Asset, you can retrieve and unarchive it at a later date.