Dataset
API reference for Dataset
Dataset
Represents a Dataset container for organizing evaluation test cases.
A Dataset is a logical container within an Application that stores structured test cases with inputs and expected outputs for GenAI evaluation. Datasets provide organized storage, metadata management, and tagging capabilities for systematic testing and validation of GenAI applications.
Key Features:
Test Case Storage: Container for structured evaluation test cases
Application Context: Datasets are scoped within applications for isolation
Metadata Management: Custom metadata and tagging for organization
Evaluation Foundation: Structured data for GenAI application testing
Lifecycle Management: Coordinated creation, updates, and deletion of datasets
Dataset Lifecycle:
Creation: Create dataset with unique name within an application
Configuration: Add test cases and metadata
Evaluation: Use dataset for testing GenAI applications
Maintenance: Update test cases and metadata as needed
Cleanup: Delete dataset when no longer needed
Example
active : bool = True
description : str | None = None
classmethod get_by_id(id_)
Retrieve a dataset by its unique identifier.
Fetches a dataset from the Fiddler platform using its UUID. This is the most direct way to retrieve a dataset when you know its ID.
Parameters
id – The unique identifier (UUID) of the dataset to retrieve. Can be provided as a UUID object or string representation.
id_ (UUID | str)
Returns
The dataset instance with all metadata and configuration. Return type: Dataset
Raises
NotFound – If no dataset exists with the specified ID.
ApiError – If there’s an error communicating with the Fiddler API.
Example
classmethod get_by_name(name, application_id)
Retrieve a dataset by name within an application.
Finds and returns a dataset using its name within the specified application. This is useful when you know the dataset name and application but not its UUID. Dataset names are unique within an application, making this a reliable lookup method.
Parameters
name
str
✗
None
The name of the dataset to retrieve. Dataset names are unique within an application and are case-sensitive.
application_id
UUID | str
✗
None
The UUID of the application containing the dataset. Can be provided as a UUID object or string representation.
Returns
The dataset instance matching the specified name. Return type: Dataset
Raises
NotFound – If no dataset exists with the specified name in the application.
ApiError – If there’s an error communicating with the Fiddler API.
Example
classmethod list(application_id)
List all datasets in an application.
Retrieves all datasets that the current user has access to within the specified application. Returns an iterator for memory efficiency when dealing with many datasets.
Parameters
application_id
UUID | str
✗
None
The UUID of the application to list datasets from. Can be provided as a UUID object or string representation.
Yields
Dataset – Dataset instances for all accessible datasets in the application.
Raises
ApiError – If there’s an error communicating with the Fiddler API. Return type: Iterator[Dataset]
Example
classmethod create(name, application_id, description=None, metadata=None, active=True)
Create a new dataset in an application.
Creates a new dataset within the specified application on the Fiddler platform. The dataset must have a unique name within the application.
Parameters
name
str
✗
None
Dataset name, must be unique within the application.
application_id
UUID | str
✗
None
The UUID of the application to create the dataset in. Can be provided as a UUID object or string representation.
description
str | None
✗
None
Optional human-readable description of the dataset.
metadata
dict | None
✗
None
Optional custom metadata dictionary for additional dataset information.
active
bool
✗
None
Optional boolean flag to indicate if the dataset is active.
Returns
The newly created dataset instance with server-assigned fields. Return type: Dataset
Raises
Conflict – If a dataset with the same name already exists in the application.
ValidationError – If the dataset configuration is invalid (e.g., invalid name format).
ApiError – If there’s an error communicating with the Fiddler API.
Example
classmethod get_or_create(name, application_id, description=None, metadata=None, active=True)
Get an existing dataset by name or create a new one if it doesn’t exist.
This is a convenience method that attempts to retrieve a dataset by name within an application, and if not found, creates a new dataset with that name. Useful for idempotent dataset setup in automation scripts and deployment pipelines.
Parameters
name
str
✗
None
The name of the dataset to retrieve or create.
application_id
UUID | str
✗
None
The UUID of the application to search/create the dataset in. Can be provided as a UUID object or string representation.
description
str | None
✗
None
Optional human-readable description of the dataset.
metadata
dict | None
✗
None
Optional custom metadata dictionary for additional dataset information.
active
bool
✗
None
Optional boolean flag to indicate if the dataset is active.
Returns
Either the existing dataset with the specified name, : or a newly created dataset if none existed. Return type: Dataset
Raises
ValidationError – If the dataset name format is invalid.
ApiError – If there’s an error communicating with the Fiddler API.
Example
update()
Update dataset description, metadata.
Parameters
description
str | None
✗
None
Optional new description for the dataset. If provided, replaces the existing description. Set to empty string to clear.
metadata
dict | None
✗
None
Optional new metadata dictionary for the dataset. If provided, replaces the existing metadata completely. Use empty dict to clear.
active
bool | None
✗
None
Optional boolean flag to indicate if the dataset is active.
Returns
The updated dataset instance with new metadata and configuration. Return type: Dataset
Raises
ValueError – If no update parameters are provided (all are None).
ValidationError – If the update data is invalid (e.g., invalid metadata format).
ApiError – If there’s an error communicating with the Fiddler API.
Example
delete()
Delete the dataset permanently from the Fiddler platform.
Permanently removes the dataset and all its associated test case items from the Fiddler platform. This operation cannot be undone.
The method performs safety checks before deletion:
Verifies that no experiments are currently associated with the dataset
Prevents deletion if any experiments reference this dataset
Only proceeds with deletion if the dataset is safe to remove
Parameters
None – This method takes no parameters.
Returns
This method does not return a value. Return type: None
Raises
ApiError – If there’s an error communicating with the Fiddler API.
ApiError – If the dataset cannot be deleted due to existing experiments.
NotFound – If the dataset no longer exists.
Example
insert()
Add multiple test case items to the dataset.
Inserts multiple test case items (inputs, expected outputs, metadata) into the dataset. Each item represents a single test case for evaluation purposes. Items can be provided as dictionaries or NewDatasetItem objects.
Parameters
items
list[dict] | list[NewDatasetItem]
✗
None
List of test case items to add to the dataset. Each item can be: A dictionary containing test case data with keys: - inputs: Dictionary containing input data for the test case; - expected_outputs: Dictionary containing expected output data; - metadata: Optional dictionary with additional test case metadata; - extras: Optional dictionary for additional custom data; - source_name: Optional string identifying the source of the test case; - source_id: Optional string identifier for the source; A NewDatasetItem object with the same structure
Returns
List of UUIDs for the newly created dataset items. Return type: builtins.list[UUID]
Raises
ValueError – If the items list is empty.
ValidationError – If any item data is invalid (e.g., missing required fields).
ApiError – If there’s an error communicating with the Fiddler API.
Example
insert_from_pandas()
Insert test case items from a pandas DataFrame into the dataset.
Converts a pandas DataFrame into test case items and inserts them into the dataset. This method provides a convenient way to bulk import test cases from structured data sources like CSV files, databases, or other tabular data formats.
The method intelligently maps DataFrame columns to different test case components:
Input columns: Data that will be used as inputs for evaluation
Expected output columns: Expected results or answers for the test cases
Metadata columns: Additional metadata associated with each test case
Extras columns: Custom data fields for additional test case information
Source columns: Information about the origin of each test case
Column Mapping Logic:
If input_columns is specified, those columns become inputs
If input_columns is None, all unmapped columns become inputs
Remaining unmapped columns are automatically assigned to extras
Source columns are always mapped to source_name and source_id
Parameters
df
pd.DataFrame
✗
None
The pandas DataFrame containing test case data. Must not be empty and must have at least one column.
input_columns
builtins.list[str] | None
✗
None
Optional list of column names to use as input data. If None, all unmapped columns become inputs.
expected_output_columns
builtins.list[str] | None
✗
None
Optional list of column names containing expected outputs or answers for the test cases.
metadata_columns
builtins.list[str] | None
✗
None
Optional list of column names to use as metadata. These columns will be stored as test case metadata.
extras_columns
builtins.list[str] | None
✗
None
Optional list of column names for additional custom data. Unmapped columns are automatically added to extras.
id_column
str
✗
“id”
Column name containing the ID for each test case.
source_name_column
str
✗
“source_name”
Column name containing the source identifier for each test case.
source_id_column
str
✗
“source_id”
Column name containing the source ID for each test case.
Returns
List of UUIDs for the newly created dataset items. Return type: builtins.list[UUID]
Raises
ValueError – If the DataFrame is empty or has no columns.
ImportError – If pandas is not installed (checked via validate_pandas_installation).
ValidationError – If any generated test case data is invalid.
ApiError – If there’s an error communicating with the Fiddler API.
Example
insert_from_csv_file()
Insert test case items from a CSV file into the dataset.
Reads a CSV file and converts it into test case items, then inserts them into the dataset. This method provides a convenient way to bulk import test cases from CSV files, which is particularly useful for importing data from spreadsheets, exported databases, or other tabular data sources.
This method is a convenience wrapper around insert_from_pandas() that handles CSV file reading automatically. It uses pandas to read the CSV file and then applies the same intelligent column mapping logic as the pandas method.
Column Mapping Logic:
If input_columns is specified, those columns become inputs
If input_columns is None, all unmapped columns become inputs
Remaining unmapped columns are automatically assigned to extras
Source columns are always mapped to source_name and source_id
Parameters
file_path
str | Path
✗
None
Path to the CSV file to read. Can be a string or Path object. Supports both relative and absolute paths.
input_columns
list[str] | None
✗
None
Optional list of column names to use as input data. If None, all unmapped columns become inputs.
expected_output_columns
list[str] | None
✗
None
Optional list of column names containing expected outputs or answers for the test cases.
metadata_columns
list[str] | None
✗
None
Optional list of column names to use as metadata. These columns will be stored as test case metadata.
extras_columns
list[str] | None
✗
None
Optional list of column names for additional custom data. Unmapped columns are automatically added to extras.
id_column
str
✗
“id”
Column name containing the ID for each test case.
source_name_column
str
✗
“source_name”
Column name containing the source identifier for each test case.
source_id_column
str
✗
“source_id”
Column name containing the source ID for each test case.
Returns
List of UUIDs for the newly created dataset items. Return type: builtins.list[UUID]
Raises
FileNotFoundError – If the CSV file does not exist at the specified path.
ValueError – If the CSV file is empty or has no columns.
ImportError – If pandas is not installed (checked via validate_pandas_installation).
ValidationError – If any generated test case data is invalid.
ApiError – If there’s an error communicating with the Fiddler API.
Example
insert_from_jsonl_file()
Insert test case items from a JSONL (JSON Lines) file into the dataset.
Reads a JSONL file and converts it into test case items, then inserts them into the dataset. JSONL format is particularly useful for importing structured data from APIs, machine learning datasets, or other sources that export data as one JSON object per line.
JSONL Format: : Each line in the file must be a valid JSON object. Empty lines are skipped. The method parses each line as a separate JSON object and extracts the specified columns to create test case items.
Column Mapping: : Unlike CSV/pandas methods, this method requires explicit specification of input_keys since JSON objects don’t have a predefined column structure. All other key/column mappings work the same way as other insert methods.
Parameters
file_path
str | Path
✗
None
Path to the JSONL file to read. Can be a string or Path object. Supports both relative and absolute paths.
input_keys
list[str]
✗
None
Required list of key names to use as input data. These must correspond to keys in the JSON objects.
expected_output_keys
list[str] | None
✗
None
Optional list of key names containing expected outputs or answers for the test cases.
metadata_keys
list[str] | None
✗
None
Optional list of key names to use as metadata. These keys will be stored as test case metadata.
extras_keys
list[str] | None
✗
None
Optional list of key names for additional custom data. Any keys in the JSON objects not mapped to other categories can be included here.
id_key
str
✗
“id”
Key name containing the ID for each test case.
source_name_key
str
✗
“source_name”
Key name containing the source identifier for each test case.
source_id_key
str
✗
“source_id”
Key name containing the source ID for each test case.
Returns
List of UUIDs for the newly created dataset items. Return type: builtins.list[UUID]
Raises
FileNotFoundError – If the JSONL file does not exist at the specified path.
ValueError – If the JSONL file is empty or has no valid JSON objects.
json.JSONDecodeError – If any line in the file contains invalid JSON.
ValidationError – If any generated test case data is invalid.
ApiError – If there’s an error communicating with the Fiddler API.
Example
add_testcases()
Add multiple test case items to the dataset.
Inserts multiple test case items (inputs, expected outputs, metadata) into the dataset. Each item represents a single test case for evaluation purposes. Items can be provided as dictionaries or NewDatasetItem objects.
Parameters
items
list[dict] | list[NewDatasetItem]
✗
None
List of test case items to add to the dataset. Each item can be: A dictionary containing test case data with keys: - inputs: Dictionary containing input data for the test case; - expected_outputs: Dictionary containing expected output data; - metadata: Optional dictionary with additional test case metadata; - extras: Optional dictionary for additional custom data; - source_name: Optional string identifying the source of the test case; - source_id: Optional string identifier for the source; A NewDatasetItem object with the same structure
Returns
List of UUIDs for the newly created dataset items. Return type: builtins.list[UUID]
Raises
ValueError – If the items list is empty.
ValidationError – If any item data is invalid (e.g., missing required fields).
ApiError – If there’s an error communicating with the Fiddler API.
Example
add_items()
Add multiple test case items to the dataset.
Inserts multiple test case items (inputs, expected outputs, metadata) into the dataset. Each item represents a single test case for evaluation purposes. Items can be provided as dictionaries or NewDatasetItem objects.
Parameters
items
list[dict] | list[NewDatasetItem]
✗
None
List of test case items to add to the dataset. Each item can be: A dictionary containing test case data with keys: - inputs: Dictionary containing input data for the test case; - expected_outputs: Dictionary containing expected output data; - metadata: Optional dictionary with additional test case metadata; - extras: Optional dictionary for additional custom data; - source_name: Optional string identifying the source of the test case; - source_id: Optional string identifier for the source; A NewDatasetItem object with the same structure
Returns
List of UUIDs for the newly created dataset items. Return type: builtins.list[UUID]
Raises
ValueError – If the items list is empty.
ValidationError – If any item data is invalid (e.g., missing required fields).
ApiError – If there’s an error communicating with the Fiddler API.
Example
get_testcases()
Retrieve all test case items in the dataset.
Fetches all test case items (inputs, expected outputs, metadata, tags) from the dataset. Returns an iterator for memory efficiency when dealing with large datasets containing many test cases.
Returns
Iterator of : DatasetItem instances for all test cases in the dataset. Return type: Iterator[DatasetItem]
Raises
ApiError – If there’s an error communicating with the Fiddler API.
Example
get_items()
Retrieve all test case items in the dataset.
Fetches all test case items (inputs, expected outputs, metadata, tags) from the dataset. Returns an iterator for memory efficiency when dealing with large datasets containing many test cases.
Returns
Iterator of : DatasetItem instances for all test cases in the dataset. Return type: Iterator[DatasetItem]
Raises
ApiError – If there’s an error communicating with the Fiddler API.
Example
Last updated
Was this helpful?