Skip to content

Spec models

uptimely.spec.model defines the spec document structure, independent of its authoring format. The spec format reference describes the document structure.

The compiler constructs executable invocations from these declarations.

spec

uptimely.spec.model.spec defines the root spec document.

The spec document model.

SUPPORTED_SPEC_VERSION module-attribute

SUPPORTED_SPEC_VERSION = '0.2.0'

Spec

Bases: StrictModel

The complete JSON spec document.

name class-attribute instance-attribute

name: str | None = None

version class-attribute instance-attribute

version: Literal['0.2.0'] = SUPPORTED_SPEC_VERSION

source class-attribute instance-attribute

source: SpecSource = pydantic.Field(default_factory=lambda: common.SpecSource(name='manual', generated=False))

dimensions class-attribute instance-attribute

dimensions: dict[str, Dimension] = pydantic.Field(default_factory=dict)

functions class-attribute instance-attribute

functions: FunctionCatalog = pydantic.Field(default_factory=functions_module.FunctionCatalog)

entities class-attribute instance-attribute

entities: dict[str, Entity] = pydantic.Field(default_factory=dict)

normalize_resource_ids classmethod

normalize_resource_ids(value: Any) -> typing.Any

common

uptimely.spec.model.common defines shared dimensions, arguments, and bindings.

Shared types for spec document models.

BindingArgument module-attribute

BindingArgument = dict[str, typing.Any] | list[typing.Any] | str | int | float | bool | None

StrictModel

Bases: BaseModel

Base model that rejects fields outside the spec contract.

model_config class-attribute instance-attribute

model_config = pydantic.ConfigDict(extra='forbid')

SpecSource

Bases: StrictModel

Describe how a spec document was authored or generated.

name instance-attribute

name: str

generated instance-attribute

generated: bool

Dimension

Bases: StrictModel

A globally defined grain under dimensions.

id class-attribute instance-attribute

id: str = pydantic.Field(exclude=True)

type instance-attribute

type: str

description class-attribute instance-attribute

description: str | None = None

parent class-attribute instance-attribute

parent: str | None = None

Argument

Bases: StrictModel

A single argument entry under a function template's args.

id class-attribute instance-attribute

id: str = pydantic.Field(exclude=True)

type instance-attribute

type: str

comment class-attribute instance-attribute

comment: str | None = None

Binding

Bases: StrictModel

Wires an operation to a catalog function and its arguments.

function instance-attribute

function: str

args class-attribute instance-attribute

args: dict[str, BindingArgument] = pydantic.Field(default_factory=dict)

dataset

uptimely.spec.model.dataset defines entities, datasets, features, and their relationships.

Dataset and entity models for spec documents.

Entity

Bases: StrictModel

An entry under the top-level entities block.

id class-attribute instance-attribute

id: str = pydantic.Field(exclude=True)

name instance-attribute

name: str

description class-attribute instance-attribute

description: str | None = None

dimensions class-attribute instance-attribute

dimensions: list[Dimension] = pydantic.Field(default_factory=list)

datasets class-attribute instance-attribute

datasets: list[Dataset] = pydantic.Field(default_factory=list)

dimension_ids property

dimension_ids: list[str]

Return the identifiers of dimensions declared by this entity.

serialize_dimensions

serialize_dimensions(dimensions: list[Dimension]) -> list[str]

Serialize entity dimensions as references in the spec document.

Dataset

Bases: StrictModel

An entry under an entity's datasets list.

id class-attribute instance-attribute

id: str = pydantic.Field(exclude=True)

description class-attribute instance-attribute

description: str | None = None

row_scope class-attribute instance-attribute

row_scope: RowScope = pydantic.Field(default_factory=RowScope)

features class-attribute instance-attribute

features: dict[str, Feature] = pydantic.Field(default_factory=dict)

mappings class-attribute instance-attribute

mappings: dict[str, Mapping] = pydantic.Field(default_factory=dict)

order class-attribute instance-attribute

order: list[Order] = pydantic.Field(default_factory=list)

all_features property

all_features: dict[str, Feature]

Return the declared feature metadata for this dataset.

Feature

Bases: StrictModel

A dataset feature's logical metadata.

id class-attribute instance-attribute

id: str = pydantic.Field(exclude=True)

description class-attribute instance-attribute

description: str | None = None

type class-attribute instance-attribute

type: str | None = None

unit class-attribute instance-attribute

unit: str | None = None

Order

Bases: StrictModel

One logical dataset ordering key, without a physical row-order guarantee.

dimension class-attribute instance-attribute

dimension: str = pydantic.Field(pattern=f'^{re.escape(contracts.DIMENSION_PREFIX)}.+$')

direction instance-attribute

direction: Literal['asc', 'desc']

RowScope

Bases: StrictModel

The conceptual row subset represented by a dataset.

grain class-attribute instance-attribute

grain: str = ''

filtering class-attribute instance-attribute

filtering: str = ''

coverage class-attribute instance-attribute

coverage: str = ''

Mapping

Bases: StrictModel

A function binding with declared feature inputs, outputs, and row context.

id class-attribute instance-attribute

id: str = pydantic.Field(exclude=True)

binding instance-attribute

binding: Binding

features class-attribute instance-attribute

features: MappingFeatures = pydantic.Field(default_factory=MappingFeatures)

row_context class-attribute instance-attribute

row_context: RowContext | None = None

input_features property

input_features: list[str]

Return identifiers of required materialized features.

output_features property

output_features: list[str]

Return identifiers of produced features.

MappingFeatures

Bases: StrictModel

Explicit data prerequisites and produced features for one mapping.

inputs class-attribute instance-attribute

inputs: list[str] = pydantic.Field(default_factory=list)

outputs class-attribute instance-attribute

outputs: list[str] = pydantic.Field(default_factory=list)

validate_references classmethod

validate_references(values: list[str]) -> list[str]

Require distinct feature references without value selectors.

functions

uptimely.spec.model.functions defines reusable function metadata and the function catalog.

Function definitions and operation rules for spec documents.

FUNCTION_TYPES module-attribute

FUNCTION_TYPES = ['sql_query', 'python_function']

FunctionTemplate

Bases: StrictModel

One logical function definition in the spec catalog.

id class-attribute instance-attribute

id: str = pydantic.Field(exclude=True)

operation instance-attribute

operation: FunctionOperation

returns instance-attribute

returns: FunctionReturns

entrypoint instance-attribute

entrypoint: str

validate_signature class-attribute instance-attribute

validate_signature: bool = pydantic.Field(default=True, description='Whether to inspect the Python signature and check implementation contracts.')

args class-attribute instance-attribute

args: dict[str, Argument] = pydantic.Field(default_factory=dict)

description class-attribute instance-attribute

description: str | None = None

FunctionCatalog

Bases: RootModel[dict[str, FunctionTemplate]]

Function definitions keyed by their globally unique identifiers.

root class-attribute instance-attribute

root: dict[str, FunctionTemplate] = pydantic.Field(default_factory=dict)

by_operation

by_operation(operation: FunctionOperation) -> dict[str, FunctionTemplate]

Return function definitions for one operation.

get

get(function_id: str, default: Any = None) -> FunctionTemplate | typing.Any

Return one function definition, or a default when it is absent.

For supported operation types and values, see function contracts.