Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Cohere ai Cohere python DatasetPart Model

From Leeroopedia
Knowledge Sources
Domains SDK, Datasets
Last Updated 2026-02-15 14:00 GMT

Overview

DatasetPart is a Pydantic model representing a single part (file segment) within a Cohere dataset, including metadata such as size, row count, and download URLs.

Description

The DatasetPart class models an individual part of a dataset stored in the Cohere platform. Datasets may be split into multiple parts for storage and retrieval purposes. Each part carries its own identifier, name, download URL, index position, byte size, row count, original URL, and a sample of parsed rows. All fields except id and name are optional, reflecting that metadata may not always be available depending on the dataset state.

The class extends UncheckedBaseModel and is auto-generated by the Fern API definition toolchain. It supports both Pydantic v1 and v2 through a compatibility layer, and allows extra fields to be passed through without validation errors.

Usage

Use DatasetPart when working with the Cohere Datasets API to inspect or iterate over the individual file parts that compose a dataset. This is useful when downloading dataset files, checking dataset upload progress, or examining row-level samples from each part.

Code Reference

Source Location

Signature

class DatasetPart(UncheckedBaseModel):
    id: str
    name: str
    url: typing.Optional[str] = None
    index: typing.Optional[int] = None
    size_bytes: typing.Optional[int] = None
    num_rows: typing.Optional[int] = None
    original_url: typing.Optional[str] = None
    samples: typing.Optional[typing.List[str]] = None

Import

from cohere.types import DatasetPart

I/O Contract

Fields

Field Type Required Default Description
id str Yes -- The dataset part ID
name str Yes -- The name of the dataset part
url Optional[str] No None The download URL of the file
index Optional[int] No None The index of the file within the dataset
size_bytes Optional[int] No None The size of the file in bytes
num_rows Optional[int] No None The number of rows in the file
original_url Optional[str] No None The download URL of the original file
samples Optional[List[str]] No None The first few rows of the parsed file

Usage Examples

Constructing a DatasetPart Instance

from cohere.types import DatasetPart

# Create a DatasetPart with all fields populated
part = DatasetPart(
    id="part-abc123",
    name="training_data_part_0",
    url="https://storage.cohere.ai/datasets/part-abc123/download",
    index=0,
    size_bytes=1048576,
    num_rows=5000,
    original_url="https://storage.cohere.ai/datasets/part-abc123/original",
    samples=["sample row 1", "sample row 2", "sample row 3"],
)

print(part.id)          # "part-abc123"
print(part.name)        # "training_data_part_0"
print(part.size_bytes)  # 1048576
print(part.num_rows)    # 5000

Accessing Parts from a Dataset Response

import cohere

co = cohere.Client()

dataset = co.datasets.get(id="my-dataset-id")
for part in dataset.dataset.parts:
    print(f"Part {part.index}: {part.name} ({part.size_bytes} bytes, {part.num_rows} rows)")
    if part.samples:
        print(f"  First sample: {part.samples[0]}")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment