Assets#
An asset is a system you test, such as a vehicle or a test stand. It helps organize and label the data and videos you add to Nominal.
The examples on this page use a quadcopter as an example, but the asset can represent any physical or conceptual device. To decide what an asset represents in your tests, see Organize and view your data.
To use this page, first make sure you can Connect to Nominal and obtain a client.
Create an asset#
use nominal::core::AssetCreate;
let asset = client
.assets()
.create(
AssetCreate::new("Quadcopter 456")
.description("Airborne observation platform")
.properties([("serial", "QC-456")]) // identify the physical system
.labels(["camera", "airborne"]), // group assets for searching
)
.await?;
println!("{}", asset.nominal_url());
create always makes a new asset even if another asset has the same name. Fetch the asset if you know the RID or search first if you want to re-use an existing asset but don’t have the RID saved.
Fetch assets#
If the RID of an asset is known, you can fetch that asset directly without needing to search.
let asset = client.assets().get("<ri.scout.instance.asset.identifier>").await?;
Find assets#
search finds assets by label, property or name. Combine filters with and and or:
use nominal::core::AssetQuery;
// Every asset, newest first
let assets = client.assets().list().await?;
// Names that contain "quadcopter", in any case
let assets = client.assets().search(AssetQuery::substring_match("quadcopter")).await?;
// The "airborne" label and the serial QC-456, both
let assets = client
.assets()
.search(AssetQuery::and([AssetQuery::label("airborne"), AssetQuery::property("serial", "QC-456")]))
.await?;
Attach data to the asset#
A data scope adds a dataset to an asset under a ref name, such as default.
client.assets().add_dataset(asset.rid(), "default", "<ri.catalog.instance.dataset.identifier>").await?;
When using the tagged approach, filter a single shared dataset using the tags unique to your asset with add_dataset_with_tags
// the example asset is uniquely identified by the tag vehicle=QC-456
client
.assets()
.add_dataset_with_tags(asset.rid(), "default", "<ri.catalog.instance.dataset.identifier>", [("vehicle", "QC-456")])
.await?;
add_data_sources adds several datasets and videos at once.
use nominal::core::DataSource;
client
.assets()
.add_data_sources(
asset.rid(),
[
("default", DataSource::dataset("<ri.catalog.instance.dataset.identifier>")),
("nose-camera", DataSource::video("<ri.video.instance.video.identifier>")),
],
)
.await?;
Update an asset#
update changes the fields you include in the asset update request by overwriting those fields. That is, update(labels) will not touch properties, but it will overwrite the current set of labels with the ones you provide.
use nominal::core::AssetUpdate;
// The labels you set replace the asset's labels, so start from its current ones
let mut labels = asset.labels().to_vec();
labels.push("new-motor-vendor".to_string());
let asset = client.assets().update(asset.rid(), AssetUpdate::new().labels(labels)).await?;
Archive an asset#
archive hides an asset from the UI and from searches, without deleting it. unarchive brings it back.
client.assets().archive(asset.rid()).await?;