Judgment Labs Logo
PythonDatasets

Dataset

_batch_examples()

Generator that yields batches of examples for efficient memory usage.

Works with any iterable including generators, consuming only batch_size items at a time.

def _batch_examples(examples, batch_size=100) -> Iterator[List[Example]]:

Parameters

examples

required

:

Iterable[Example]

batch_size

:

int

Default:

100

Returns

Iterator[List[Example]]


example_to_dataset_entry()

Serialize an Example into the dataset example payload shape.

The example's custom properties become the example data fields; example_id and created_at are lifted to the top level. For a trace-typed column (declared {"type": "trace"} in the dataset schema), set the field to the trace id string.

def example_to_dataset_entry(example) -> Dict[str, Any]:

Parameters

example

required

:

Example

Returns

Dict[str, Any]


example_from_dataset_entry()

Build an Example from a server dataset example payload.

The server returns examples as {example_id, created_at, data, offline_trace_id, metadata, ...} with the example fields nested under data.

def example_from_dataset_entry(entry) -> Example:

Parameters

entry

required

:

Dict[str, Any]

Returns

Example