Segments
How to interact with segments through the SDK
Overview
Within Aquarium's SDK, all types of segments are represented by an object called Issue.
When it comes to working with segments, the key to working with them will be through the IssueManager. This is an object we have created to make it easy and accessible to access data surrounding your issues. The following guides will showcase some common operations surrounding segments that leverage our client APIs.
Prerequisites
Installed
aquariumlearninglibraryPython >= 3.7
Aquarium API Key - follow this guide to access it
Usually best to store this as an environment variable, you can find instructions on how to do this in the Working With The SDK section
Accessing Segment Information
Getting a List of All Segments
#!/usr/bin/env python3
import os
import aquariumlearning as al
AQUARIUM_API_KEY = os.environ['AQUARIUM_API_KEY']
al_client = al.Client()
al_client.set_credentials(api_key=AQUARIUM_API_KEY)
issue_manager = al_client.get_issue_manager('Rareplanes_Wingtype_Project')
# you are returned a list of issue objects
issues = issue_manager.list_issues()Getting a Segment ID
When working with Aquarium's client, you can usually pass in references to a Project or Dataset by their name. For example:
However when working with Segments, you will often need to refer to it by its uuid. Here is the easiest way to pull the ID of a specific segment:
Getting a Specific Segment
If you have the issue ID you can also use .get_issue() to retrieve the Issue object
Creating Segments
When creating a segment, the main effort involved is creating your IssueElement objects. An IssueElement is a frame or a crop that belongs to a Segment! Here we give you the skeleton of the steps you'll need to take, you can look at the next section, Copy Existing Segment to New Segment to view an example, however in that case it is a copy function.
Copying Existing Segment To New Segment
Use this example if you have a segment of say type "Model Performance" and you want to move the elements to a Bucket type segment.
At the moment, you are only able to create copied segments of type Bucket.
Deleting Segments
Use this example if you would like to programmatically delete a segment through the API. You need access to the issue_id instead of issue name in order to delete it.
Collection Campaign Segments
Creating a Crop Level Collection Campaign Segment
Last updated
Was this helpful?