Skip to content

Datasets API | <Client>.datasets

spectrumx.api.datasets

API functions specific to datasets.

Classes:

Name Description
DatasetAPI

Classes

DatasetAPI

DatasetAPI(
    *,
    gateway: GatewayClient,
    dry_run: bool = True,
    verbose: bool = False,
)

Methods:

Name Description
get_files

Get files in the dataset as a paginator.

Source code in spectrumx/api/datasets.py
def __init__(
    self,
    *,
    gateway: GatewayClient,
    dry_run: bool = True,
    verbose: bool = False,
) -> None:
    """Initializes the DatasetAPI."""
    self.dry_run = dry_run
    self.gateway = gateway
    self.verbose = verbose
Functions
get_files
get_files(dataset_uuid: UUID) -> Paginator[File]

Get files in the dataset as a paginator.

Parameters:

Name Type Description Default
dataset_uuid UUID

The UUID of the dataset to get files for.

required

Returns: A paginator for the files in the dataset.

Source code in spectrumx/api/datasets.py
def get_files(
    self,
    dataset_uuid: uuid.UUID,
) -> Paginator[File]:
    """Get files in the dataset as a paginator.

    Args:
        dataset_uuid: The UUID of the dataset to get files for.
    Returns:
        A paginator for the files in the dataset.
    """
    if self.dry_run:
        log_user("Dry run enabled: files will be simulated")

    # Create a paginator that fetches from the dataset files endpoint
    pagination: Paginator[File] = Paginator(
        Entry=File,
        gateway=self.gateway,
        list_method=self.gateway.get_dataset_files,
        list_kwargs={"dataset_uuid": dataset_uuid},
        dry_run=self.dry_run,
        verbose=self.verbose,
    )

    return pagination

Functions