Internal Types
mosaicolabs.query.protocols.QueryableProtocol ¶
Bases: Protocol
Structural protocol for classes that integrate into a multi-domain Query.
A class implicitly satisfies this protocol if it can fill its own field of the
protobuf Filter message via _apply_to(). This protocol ensures that the root
Query can orchestrate complex requests
without knowing the specific internal logic of each sub-query.
Reference Implementations¶
The following classes are standard examples of this protocol:
QueryTopic: Filters Topic-level metadata.QuerySequence: Filters Sequence-level metadata.QueryOntologyCatalog: Filters fine-grained sensor field data.
mosaicolabs.query.expressions._QueryExpression ¶
Base class for all atomic comparison operations in the Mosaico Query DSL.
A _QueryExpression represents the smallest indivisible unit of a query.
It is typically not instantiated directly by the user, but is instead the result
of a terminal method call on a queryable field (e.g., .gt(), .eq(), .between())
via the .Q query proxy.
The class manages the expression lifecycle in a Query:
- Generation: A user calls
IMU.Q.acceleration.x.gt(9.8), which generates a_QueryCatalogExpression(a subclass of this class). - Validation: A Builder receives the expression and validates its type and key uniqueness.
- Serialization: The builder calls
._to_condition()on the expression to transform it into the protobufConditionmessage expected by the platform.
Attributes:
| Name | Type | Description |
|---|---|---|
full_path |
str
|
The complete, dot-separated path to the target field on the platform. |
op |
Operator
|
The protobuf operator (e.g., |
value |
Any
|
The comparison value or data structure (e.g., a constant, a list for |
aggregator |
Optional[Aggregator]
|
The aggregator applied to the field before the comparison (e.g., |
mosaicolabs.query.expressions._QueryTopicExpression ¶
Bases: _QueryExpression
An atomic comparison unit specialized for the Topic Catalog context.
This class is utilized exclusively by the QueryTopic
builder to filter topics based on system attributes (like name or ontology_tag)
and nested user metadata.
The QueryTopic class enforces that all
provided expressions are instances of this type to prevent cross-domain query
contamination.
Internal Translation Example:
| User Call | Internal Translation |
|---|---|
QueryTopic().with_user_metadata("calibrated", eq=True) |
_QueryTopicExpression("user_metadata.calibrated", OPERATOR_EQ, True) |
QueryTopic().with_name("camera_front") |
_QueryTopicExpression("name", OPERATOR_EQ, "camera_front") |
QueryTopic().with_ontology_tag("imu") |
_QueryTopicExpression("ontology_tag", OPERATOR_EQ, "imu") |
mosaicolabs.query.expressions._QuerySequenceExpression ¶
Bases: _QueryExpression
An atomic comparison unit specialized for the Sequence Catalog context.
This class represents filters targeting high-level sequence containers.
It is the only expression type accepted by the
QuerySequence builder.
It handles fields such as the sequence name, created_at_ns, or custom
entries within the sequence's user_metadata.
Internal Translation Example:
| User Call | Internal Translation |
|---|---|
QuerySequence().with_user_metadata("project", eq="Apollo") |
_QuerySequenceExpression("user_metadata.project", OPERATOR_EQ, "Apollo") |
QuerySequence().with_name("Apollo") |
_QuerySequenceExpression("name", OPERATOR_EQ, "Apollo") |
QuerySequence().with_created_timestamp(time_start=1704067200_000000000) |
_QuerySequenceExpression("created_at_ns", OPERATOR_GE, 1704067200_000000000) |
mosaicolabs.query.expressions._QueryCatalogExpression ¶
Bases: _QueryExpression
An atomic comparison unit specialized for Data Ontology (Sensor Payload) filtering.
This expression type is used by the
QueryOntologyCatalog builder
to filter actual sensor data values across the entire platform.
Because ontology queries target specific fields within a sensor payload (e.g., accelerometer readings), these expressions use fully qualified dot-notated paths prefixed by the ontology tag.
Internal Translation Example:
| User Call | Internal Translation |
|---|---|
IMU.Q.acceleration.x.gt(9.8) |
_QueryCatalogExpression("IMU.acceleration.x", OPERATOR_GT, 9.8) |
IMU.Q.acceleration.y.gt(9.8) |
_QueryCatalogExpression("IMU.acceleration.y", OPERATOR_GT, 9.8) |
IMU.Q.acceleration.z.gt(9.8) |
_QueryCatalogExpression("IMU.acceleration.z", OPERATOR_GT, 9.8) |
get_expr_tag ¶
Returns the ontology tag the expression refers to as a string. For example: IMU.Q.acceleration.x.gt(9.8) -> imu GPS.Q.position.x.lt(1.0) -> gps
mosaicolabs.query.generation.api._QueryProxy ¶
Bases: _QueryNode
A dynamic proxy object that is attached to Ontology classes (as .Q). It intercepts attribute access (like .position or .status) to build nested query paths and provide custom error messages.
The proxy is injected as a class attribute named Q by
_QueryProxyMixin._inject_query_proxy(), which Serializable calls when
each of its subclasses is defined.
Example
from mosaicolabs import IMU
# This is a _QueryProxy instance
imu_query_proxy = IMU.Q
# This is another (nested) _QueryProxy instance
imu_query_proxy.acceleration
# This is a _QueryableField instance
imu_query_proxy.acceleration.x
# This is a _QueryExpression instance
imu_query_proxy.acceleration.x.geq(1.234)
Initializes the node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full_path
|
str
|
The query path so far (e.g., "GPS" or "GPS.position"). |
required |
field_schema
|
Union[Dict[str, DataType], DataType]
|
A nested schema of valid child fields. - Values are pa.DataType for simple fields. - Values are other dicts for nested structs. |
required |
mosaicolabs.query.generation.api._QueryValueListProxy ¶
Bases: _QueryListProxy, _ListAggregatorsMixin
The proxy of a list of values (e.g. RobotJoint.Q.positions).
Besides selecting the elements with .any(), .all() or [i], the list can be
aggregated as a whole with .max(), .min(), .range(), .count() and
.rate().
Initializes the node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full_path
|
str
|
The query path so far (e.g., "GPS" or "GPS.position"). |
required |
field_schema
|
Union[Dict[str, DataType], DataType]
|
A nested schema of valid child fields. - Values are pa.DataType for simple fields. - Values are other dicts for nested structs. |
required |
max ¶
Aggregates the list to its greatest element over the topic.
Returns:
| Type | Description |
|---|---|
Any
|
The queryable field of the elements, whose operators compare the aggregated value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the list is inside a list selected with an index specifier. |
min ¶
Aggregates the list to its smallest element over the topic.
Returns:
| Type | Description |
|---|---|
Any
|
The queryable field of the elements, whose operators compare the aggregated value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the list is inside a list selected with an index specifier. |
range ¶
Aggregates the list to the range (max - min) of its elements over the topic.
Returns:
| Type | Description |
|---|---|
Any
|
The queryable field of the elements, whose operators compare the aggregated value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the list is inside a list selected with an index specifier. |
count ¶
Aggregates the list to its number of samples over the topic, whatever the length of their lists.
Returns:
| Type | Description |
|---|---|
Any
|
A numeric queryable field, whose operators compare the aggregated value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the list is inside a list selected with an index specifier. |
rate ¶
Aggregates the list to its number of samples per second (Hz) over the topic, whatever the length of their lists.
Returns:
| Type | Description |
|---|---|
Any
|
A numeric queryable field, whose operators compare the aggregated value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the list is inside a list selected with an index specifier. |
any ¶
Returns a proxy or field scoped to the any-element quantifier ([?]).
Use this when the condition should match if at least one element in the list satisfies it.
Example::
RobotPath.Q.poses.any().position.x.gt(1.0)
Returns:
| Type | Description |
|---|---|
Union[_QueryProxy, _QueryableField]
|
Union[_QueryProxy, _QueryableField]: Either a new |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the list is inside a list selected with an index specifier. |
all ¶
Returns a proxy or field scoped to the all-elements quantifier ([!]).
Use this when the condition should match only if every element in the list satisfies it.
Example::
RobotPath.Q.poses.all().position.x.gt(1.0)
Returns:
| Type | Description |
|---|---|
Union[_QueryProxy, _QueryableField]
|
Union[_QueryProxy, _QueryableField]: Either a new |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the list is inside a list selected with an index specifier. |
mosaicolabs.query.generation.api._QueryStructListProxy ¶
Bases: _QueryListProxy
The proxy of a list of structs (e.g. RobotPath.Q.poses).
Besides selecting the elements with .any(), .all() or [i], the fields of
the structs can be accessed directly to aggregate them over all the elements
of the list (e.g. RobotPath.Q.poses.position.z.max()).
Initializes the node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full_path
|
str
|
The query path so far (e.g., "GPS" or "GPS.position"). |
required |
field_schema
|
Union[Dict[str, DataType], DataType]
|
A nested schema of valid child fields. - Values are pa.DataType for simple fields. - Values are other dicts for nested structs. |
required |
any ¶
Returns a proxy or field scoped to the any-element quantifier ([?]).
Use this when the condition should match if at least one element in the list satisfies it.
Example::
RobotPath.Q.poses.any().position.x.gt(1.0)
Returns:
| Type | Description |
|---|---|
Union[_QueryProxy, _QueryableField]
|
Union[_QueryProxy, _QueryableField]: Either a new |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the list is inside a list selected with an index specifier. |
all ¶
Returns a proxy or field scoped to the all-elements quantifier ([!]).
Use this when the condition should match only if every element in the list satisfies it.
Example::
RobotPath.Q.poses.all().position.x.gt(1.0)
Returns:
| Type | Description |
|---|---|
Union[_QueryProxy, _QueryableField]
|
Union[_QueryProxy, _QueryableField]: Either a new |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the list is inside a list selected with an index specifier. |
mosaicolabs.query.generation.api._FlattenedProxy ¶
Bases: _QueryProxy
The proxy of a struct reached through a list without an index specifier (e.g.
RobotPath.Q.poses.position): each of its fields holds the values of all the
elements of the list, so it can only be aggregated.
Initializes the node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
full_path
|
str
|
The query path so far (e.g., "GPS" or "GPS.position"). |
required |
field_schema
|
Union[Dict[str, DataType], DataType]
|
A nested schema of valid child fields. - Values are pa.DataType for simple fields. - Values are other dicts for nested structs. |
required |
mosaicolabs.query.generation.api._FlattenedField ¶
Bases: _ListAggregatorsMixin
A field reached through a list without an index specifier (e.g.
RobotPath.Q.poses.position.z): it holds the values of all the elements of the
list, so it can only be aggregated.
max ¶
Aggregates the list to its greatest element over the topic.
Returns:
| Type | Description |
|---|---|
Any
|
The queryable field of the elements, whose operators compare the aggregated value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the list is inside a list selected with an index specifier. |
min ¶
Aggregates the list to its smallest element over the topic.
Returns:
| Type | Description |
|---|---|
Any
|
The queryable field of the elements, whose operators compare the aggregated value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the list is inside a list selected with an index specifier. |
range ¶
Aggregates the list to the range (max - min) of its elements over the topic.
Returns:
| Type | Description |
|---|---|
Any
|
The queryable field of the elements, whose operators compare the aggregated value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the list is inside a list selected with an index specifier. |
count ¶
Aggregates the list to its number of samples over the topic, whatever the length of their lists.
Returns:
| Type | Description |
|---|---|
Any
|
A numeric queryable field, whose operators compare the aggregated value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the list is inside a list selected with an index specifier. |
rate ¶
Aggregates the list to its number of samples per second (Hz) over the topic, whatever the length of their lists.
Returns:
| Type | Description |
|---|---|
Any
|
A numeric queryable field, whose operators compare the aggregated value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the list is inside a list selected with an index specifier. |