Dataset Factory
DatasetColumnType
Literal['string', 'integer', 'number', 'boolean', 'array', 'object', 'trace']
validate_dataset_schema()
Validate a dataset JSON Schema client-side before sending.
Mirrors the server's structural checks so obvious mistakes fail fast without a round-trip; the server remains the source of truth for full JSON Schema validation.
ValueError: If the schema is not a dict, does not declare top-level
type: "object", lacks a properties object, or declares
more than one trace-typed column.
def validate_dataset_schema(schema) -> None:Parameters
schema
required:Mapping[str, Any]
Returns
None
_json_schema_type()
def _json_schema_type(value) -> str:Parameters
value
required:Any
Returns
str
infer_schema_from_examples()
Infer a JSON Schema from a set of examples.
Convenience for client.datasets.create() when no explicit schema is
supplied. Property types are inferred from the example values; every
example must contain every declared field, so examples must share one
shape (the same set of non-None fields). Heterogeneous examples (where
some examples are missing fields that others have) are rejected with a
ValueError. Inferred types are JSON Schema primitives only; to
declare a trace column ({"type": "trace"}) pass an explicit schema.
ValueError: If no examples are provided or examples have heterogeneous fields.
def infer_schema_from_examples(examples) -> typing.Dict:Parameters
examples
required:Sequence[Example]
Examples to infer the schema from. Must be non-empty and homogeneous (all examples share the same set of property keys).
Returns
typing.Dict - A JSON Schema dict of the form
{"type": "object", "properties": {...}} declaring the example
fields.