Row-context utilities¶
RowContext describes which nearby rows a calculation needs. Use it when a
function depends on earlier, later, or all rows in a profile. Python helpers
for declaring these needs are listed in Python authoring.
row_context¶
Import RowContext, ContextExtent, and UNBOUNDED from
uptimely.spec.row_context.
ref.row_context("before") and ref.row_context("after") pass the requested
extent to the function. ref.row_context("dimension") passes the dimension ID.
Portable observation-context requirements shared by spec and plans.
CountExtent
module-attribute
¶
CountExtent = typing.Annotated[int, pydantic.Field(strict=True, ge=0)] | typing.Literal['unbounded']
ContextExtent
¶
Bases: BaseModel
Context in one direction, expressed using a single measurement.
model_config
class-attribute
instance-attribute
¶
validate_time
classmethod
¶
Require a fixed duration or the explicit unbounded marker.
reject_null_extents
classmethod
¶
Distinguish omitted measurements from invalid explicit nulls.
validate_measurement
¶
Require at most one measurement within a directional extent.
merge
¶
Take the maximum extent, requiring compatible measurements.
RowContext
¶
Bases: BaseModel
Required input observations, interpreted using the profile's logical order.
Empty directions mean current-row-only input. An absent RowContext means unknown requirements, not zero context. Unbounded directions require all observations in that direction; two unbounded directions need no ordering.
model_config
class-attribute
instance-attribute
¶
dimension
class-attribute
instance-attribute
¶
dimension: str | None = pydantic.Field(default=None, pattern=f'^{re.escape(selectors.DIMENSION_PREFIX)}[^.]+$')
before
class-attribute
instance-attribute
¶
after
class-attribute
instance-attribute
¶
requires_order
property
¶
Return whether the context distinguishes preceding from following rows.
normalize_row_count_shorthand
classmethod
¶
Interpret bare integer directions as observation counts.
validate_extent
¶
Require one measurement across both directional requirements.
to_dict
¶
Return JSON-compatible metadata without unspecified measurements.
merge
¶
Combine requirements for the same input scope without adding lags.
duration_nanoseconds
¶
Parse a fixed duration such as 1h30m without floating-point rounding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Nonnegative duration using distinct lowercase unit suffixes. Days and weeks mean exactly 24 hours and seven days. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The exact duration in nanoseconds. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If syntax is invalid or precision is finer than a nanosecond. |