You can programmatically retrieve a slice’s data rows and all associated information via our Python SDK. From there, you can use Catalog to inspect the data rows you retrieved via the SDK visually.Retrieving a slice programmatically is a convenient way to curate a new batch or a model run dataset directly from a saved slice.
Obtain Data Row IDs and Data Row objects from the Catalog slice
Copy
Ask AI
# Get a data row idslice_data_rows_ids = catalog_slice.get_data_row_ids()# Get a data row objectsfor data_row_id in slice_data_rows_ids: print(client.get_data_row(data_row_id))
Data row identifiers are objects that contain both the data row ID(s) and global keys.
Copy
Ask AI
data_row_identifiers = catalog_slice.get_data_row_identifiers()drids = [dr for dr in data_row_identifiers]# get both global keys and data row ids# and utilize the hash method to combine both global keys and data row ids into a dictionaryfor dr in drids: print(f"Data row: {dr.id}, Global Key: {dr.global_key}, dr_gk: {dr.to_hash()}")
You can create a new batch from your slice or create a random sample from a slice using our Python SDK. See the Python example below to learn how to do this.
Copy
Ask AI
# Optional: sample Data rows from your Slicesampled_data_row_ids = random.sample(slice_data_rows_ids, 5)batch = project.create_batch( "test batch", # name of the batch sampled_data_row_ids, # list of Data Rows 1 # priority between 1-5)
You can append data rows to your model runs for inference from your slice. See the Python example below to learn how to do this.