Skip to content

Function contracts

uptimely.contracts defines the operation types, allowed return kinds, and reference syntax shared by spec definitions and execution plans.

Operation types and rules

FunctionOperation describes the supported operations. FunctionReturns distinguishes dataframe-producing functions, functions that return no data, and any for the uncontrolled escape operation. Escape declarations may have any number of dataframe arguments, and their any return kind does not describe a dataframe result. The lookup tables describe input counts and return kinds for each operation; None in DATAFRAME_INPUT_COUNTS means the operation has no fixed dataframe argument count. Escape is not a fragment operation. At execution, its callable is invoked independently of dataframe state, its return value is ignored, and it does not produce a dataframe fragment or materialize declared output features.

Shared contracts for spec function operations.

FunctionOperation module-attribute

FunctionOperation = typing.Literal['read', 'write', 'escape', 'vectorize', 'collapse', 'expand', 'conform']

FunctionReturns module-attribute

FunctionReturns = typing.Literal['dataframe', 'none', 'any']

FUNCTION_OPERATIONS module-attribute

FUNCTION_OPERATIONS = ('read', 'write', 'escape', 'vectorize', 'collapse', 'expand', 'conform')

FRAGMENT_OPERATIONS module-attribute

FRAGMENT_OPERATIONS: tuple[FunctionOperation, ...] = ('read', 'conform', 'expand', 'collapse')

DATAFRAME_INPUT_COUNTS module-attribute

DATAFRAME_INPUT_COUNTS: dict[FunctionOperation, int | None] = {'read': 0, 'collapse': 1, 'conform': 2, 'expand': 2, 'vectorize': 1, 'write': 1, 'escape': None}

OPERATION_RETURN_KINDS module-attribute

OPERATION_RETURN_KINDS: dict[FunctionOperation, FunctionReturns] = {'read': 'dataframe', 'write': 'none', 'escape': 'any', 'vectorize': 'dataframe', 'collapse': 'dataframe', 'expand': 'dataframe', 'conform': 'dataframe'}

Reference syntax

These constants define dataset, feature, and dimension reference prefixes, the current-dataset marker, and selectors for identifiers and dataframes.

Shared contracts for spec function operations.

FEATURE_PREFIX module-attribute

FEATURE_PREFIX = '$features.'

DATASET_PREFIX module-attribute

DATASET_PREFIX = '$datasets.'

DIMENSION_PREFIX module-attribute

DIMENSION_PREFIX = '$dimensions.'

STRUCTURAL_PREFIXES module-attribute

STRUCTURAL_PREFIXES = (FEATURE_PREFIX, DATASET_PREFIX, DIMENSION_PREFIX)

CURRENT_ID module-attribute

CURRENT_ID = '@'

ID_SELECTOR module-attribute

ID_SELECTOR = '.id'

DATAFRAME_SELECTOR module-attribute

DATAFRAME_SELECTOR = '.dataframe'