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:

  1. Creation: Create dataset with unique name within an application

  2. Configuration: Add test cases and metadata

  3. Evaluation: Use dataset for testing GenAI applications

  4. Maintenance: Update test cases and metadata as needed

  5. Cleanup: Delete dataset when no longer needed

Example

Datasets are permanent containers - once created, the name cannot be changed. Deleting a dataset removes all contained test cases and metadata. Consider the organizational structure carefully before creating datasets.

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

This method makes an API call to fetch the latest dataset state from the server. The returned dataset instance reflects the current state in Fiddler.

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

Parameter
Type
Required
Default
Description

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

Dataset names are case-sensitive and must match exactly. Use this method when you have a known dataset name from configuration or user input.

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

Parameter
Type
Required
Default
Description

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

This method returns an iterator for memory efficiency. Convert to a list with list(Dataset.list(application_id)) if you need to iterate multiple times or get the total count. The iterator fetches datasets lazily from the API.

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

Parameter
Type
Required
Default
Description

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

After successful creation, the dataset instance is returned with server-assigned metadata. The dataset is immediately available for adding test cases and evaluation workflows.

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

Parameter
Type
Required
Default
Description

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

This method is idempotent - calling it multiple times with the same name and application_id will return the same dataset. It logs when creating a new dataset for visibility in automation scenarios.

update()

Update dataset description, metadata.

Parameters

Parameter
Type
Required
Default
Description

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

This method performs a complete replacement of the specified fields. For partial updates, retrieve current values, modify them, and pass the complete new values. The dataset name and ID cannot be changed.

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:

  1. Verifies that no experiments are currently associated with the dataset

  2. Prevents deletion if any experiments reference this dataset

  3. 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

This operation is irreversible. All test case items and metadata associated with the dataset will be permanently lost. Ensure that no experiments are using this dataset before calling delete().

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

Parameter
Type
Required
Default
Description

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

This method automatically generates UUIDs and timestamps for each item. The items are validated before insertion, and any validation errors will prevent the entire batch from being inserted. Use this method for bulk insertion of test cases into datasets.

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:

  1. If input_columns is specified, those columns become inputs

  2. If input_columns is None, all unmapped columns become inputs

  3. Remaining unmapped columns are automatically assigned to extras

  4. Source columns are always mapped to source_name and source_id

Parameters

Parameter
Type
Required
Default
Description

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

This method requires pandas to be installed. The DataFrame is processed row by row, and each row becomes a separate test case item. Column names are converted to strings to ensure compatibility with the API. Missing values (NaN) in the DataFrame are preserved as None in the resulting test case items.

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:

  1. If input_columns is specified, those columns become inputs

  2. If input_columns is None, all unmapped columns become inputs

  3. Remaining unmapped columns are automatically assigned to extras

  4. Source columns are always mapped to source_name and source_id

Parameters

Parameter
Type
Required
Default
Description

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

This method requires pandas to be installed. The CSV file is read using pandas.read_csv() with default parameters. For advanced CSV reading options (custom delimiters, encoding, etc.), use pandas.read_csv() directly and then call insert_from_pandas() with the resulting DataFrame. Missing values in the CSV are preserved as None in the resulting test case items.

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

Parameter
Type
Required
Default
Description

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

This method reads the file line by line and parses each line as JSON. Empty lines are automatically skipped. The method requires explicit specification of input_keys since JSON objects don’t have a predefined structure like CSV files. Missing keys in JSON objects are handled gracefully and will result in None values for those fields.

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

Parameter
Type
Required
Default
Description

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

This method automatically generates UUIDs and timestamps for each item. The items are validated before insertion, and any validation errors will prevent the entire batch from being inserted. Use this method for bulk insertion of test cases into datasets.

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

Parameter
Type
Required
Default
Description

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

This method automatically generates UUIDs and timestamps for each item. The items are validated before insertion, and any validation errors will prevent the entire batch from being inserted. Use this method for bulk insertion of test cases into datasets.

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

This method returns an iterator for memory efficiency. Convert to a list with list(dataset.get_items()) if you need to iterate multiple times or get the total count. The iterator fetches items lazily from the API.

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

This method returns an iterator for memory efficiency. Convert to a list with list(dataset.get_items()) if you need to iterate multiple times or get the total count. The iterator fetches items lazily from the API.

Last updated

Was this helpful?