Example
Segments are evaluated during data processing and can be used with any
monitoring metric. Complex segment definitions may impact performance,
so optimize for efficiency. Segments are particularly useful for fairness
monitoring and business-critical cohort analysis.
create()
Create a new Segment on the Fiddler platform. Registers this Segment with the Fiddler platform. The expression must have a name, model_id, and definition specified before calling create().Returns
The same Segment instance with updated server-side attributes
(id, created_at, etc.).
Raises
- ApiError – If there’s an error communicating with the Fiddler API.
- Conflict – If a Segment with the same name already exists for this model.
delete()
Delete this Segment from the Fiddler platform. Permanently removes the Segment. This action cannot be undone. Any alert rules or monitors using this Segment must be deleted first.Raises
- NotFound – If the Segment no longer exists.
- ApiError – If there’s an error communicating with the Fiddler API.
- Conflict – If the Segment is still being used by alert rules or monitors.
classmethod from_name()
Retrieve a Segment by name and model. Fetches a Segment from the Fiddler platform using its name and associated model ID.Parameters
The name of the Segment to retrieve.
UUID or string identifier of the associated Model.
Returns
The Segment instance for the provided parameters.
Raises
- NotFound – If no Segment exists with the specified name and model.
- ApiError – If there’s an error communicating with the Fiddler API.
classmethod get()
Retrieve a Segment by its unique identifier. Fetches a Segment from the Fiddler platform using its UUID.Parameters
The unique identifier (UUID) of the Segment to retrieve.
Can be provided as a UUID object or string representation.
Returns
The Segment instance with all its configuration and metadata.
Raises
- NotFound – If no Segment exists with the specified ID.
- ApiError – If there’s an error communicating with the Fiddler API.
classmethod get_organization_id()
Get the organization UUID from the global connection.Returns
Unique identifier of the organization associated with the current connection.
classmethod get_organization_name()
Get the organization name from the global connection.Returns
Name of the organization associated with the current connection.
classmethod list()
List all Segment instances for a model. Retrieves all Segment instances associated with a specific model.Parameters
UUID or string identifier of the Model.
Yields
Segment instances for each Segment in the model.Raises
ApiError – If there’s an error communicating with the Fiddler API.Returns
Iterator[Segment]