Skip to content

sift_py.data.query

Module containing utilities to construct a data query which is ultimately passed to sift_py.data.service.DataService.execute to download telemetry.

This module also contains types that represent the result of a data query which can be easily converted into a pandas data frame or series.

CLASS DESCRIPTION
CalculatedChannelQuery

Represents a single calculated channel to include in the sift_py.data.query.DataQuery.

ChannelQuery

Represents a single channel to include in the sift_py.data.query.DataQuery.

DataQuery

A query that is meant to be passed to sift_py.data.service.DataService.execute to

DataQueryResult

The result of a data query which can contain multiple channels.

DataQueryResultSet

Represents time series data for a single channel. Can easily be converted into a pandas data frame like so:

ExpressionChannelReference
ATTRIBUTE DESCRIPTION
ChannelLookupInfo

TYPE: TypeAlias

ChannelLookupInfo module-attribute

ChannelLookupInfo: TypeAlias = Union[
    str, Tuple[str, ChannelDataType]
]

CalculatedChannelQuery

CalculatedChannelQuery(
    channel_key: str,
    expression: str,
    expression_channel_references: List[
        ExpressionChannelReference
    ],
    run_name: Optional[str] = None,
)

Represents a single calculated channel to include in the sift_py.data.query.DataQuery.

ATTRIBUTE DESCRIPTION
channel_key

TYPE: str

expression

TYPE: str

expression_channel_references

TYPE: List[ExpressionChannelReference]

run_name

TYPE: Optional[str]

channel_key instance-attribute

channel_key: str = channel_key

expression instance-attribute

expression: str = expression

expression_channel_references instance-attribute

expression_channel_references: List[
    ExpressionChannelReference
] = expression_channel_references

run_name instance-attribute

run_name: Optional[str] = run_name

ChannelQuery

ChannelQuery(
    channel_name: str,
    component: Optional[str] = None,
    run_name: Optional[str] = None,
)

Represents a single channel to include in the sift_py.data.query.DataQuery.

METHOD DESCRIPTION
fqn
ATTRIBUTE DESCRIPTION
channel_name

TYPE: str

component

TYPE: Optional[str]

run_name

TYPE: Optional[str]

channel_name instance-attribute

channel_name: str = channel_name

component instance-attribute

component: Optional[str]

run_name instance-attribute

run_name: Optional[str] = run_name

fqn

fqn() -> str

DataQuery

DataQuery(
    asset_name: str,
    start_time: Union[
        Timestamp, Timestamp, datetime, str, int
    ],
    end_time: Union[
        Timestamp, Timestamp, datetime, str, int
    ],
    channels: List[
        Union[ChannelQuery, CalculatedChannelQuery]
    ],
    sample_ms: int = 0,
    _: int = DEFAULT_PAGE_SIZE,
)

A query that is meant to be passed to sift_py.data.service.DataService.execute to retrieve telemetry.

  • asset_name: The name of the asset to query telemetry for.
  • start_time: The start time of the time range of the data to request.
  • end_time: The end time of the time range of the data to request.
  • sample_ms: The sampling rate to use when retrieving data. The lower the sampling rate, the greater the data-fidelity. A sampling rate of 0 retrieves full-fidelity data.
  • channels: List of either ChannelQuery or CalculatedChannelQuery, but not both. Represents the channels to retrieve data from.
ATTRIBUTE DESCRIPTION
DEFAULT_PAGE_SIZE

asset_name

TYPE: str

channels

TYPE: List[Union[ChannelQuery, CalculatedChannelQuery]]

end_time

TYPE: Timestamp

page_size

TYPE: int

sample_ms

TYPE: int

start_time

TYPE: Timestamp

DEFAULT_PAGE_SIZE class-attribute instance-attribute

DEFAULT_PAGE_SIZE = 100000

asset_name instance-attribute

asset_name: str = asset_name

channels instance-attribute

channels: List[
    Union[ChannelQuery, CalculatedChannelQuery]
] = channels

end_time instance-attribute

end_time: Timestamp = to_timestamp_nanos(end_time)

page_size instance-attribute

page_size: int = DEFAULT_PAGE_SIZE

sample_ms instance-attribute

sample_ms: int = sample_ms

start_time instance-attribute

start_time: Timestamp = to_timestamp_nanos(start_time)

DataQueryResult

DataQueryResult(
    merged_channel_data: Dict[str, List[ChannelTimeSeries]],
)

The result of a data query which can contain multiple channels.

METHOD DESCRIPTION
all_channels

Returns all channel data.

channel

Like channels but returns a single DataQueryResultSet.

channels

Returns a sift_py.data.channel.ChannelTimeSeries given the lookup argument.

all_channels

all_channels() -> List[DataQueryResultSet]

Returns all channel data.

channel

Like channels but returns a single DataQueryResultSet.

channels

channels(
    *lookup: ChannelLookupInfo,
) -> List[DataQueryResultSet]

Returns a sift_py.data.channel.ChannelTimeSeries given the lookup argument. If a lookup is a fully qualified name (FQN) str and there are multiple channels with the same FQN, this will raise a ValueError. In these situations, lookup must be a tuple where the first item is the channel FQN and the second the sift_py.ingestion.channel.ChannelDataType.

If lookup is a tuple, then the channel data-type will be appended to the key referencing the sift_py.data.channel.ChannelTimeSeries.

DataQueryResultSet

DataQueryResultSet(
    identifier: str,
    timestamps: List[Timestamp],
    values: List[Any],
)

Represents time series data for a single channel. Can easily be converted into a pandas data frame like so:

pd.DataFrame(data_query_result_set.all_columns())
METHOD DESCRIPTION
columns

Returns both the time and value columns with options to override the column names.

time_column

Returns a single key-value pair dictionary meant to represent the time column of the data-set.

value_column

Returns a single key-value pair dictionary meant to represent the value column of the data-set.

ATTRIBUTE DESCRIPTION
identifier

TYPE: str

timestamps

TYPE: List[Timestamp]

values

TYPE: List[Any]

identifier instance-attribute

identifier: str = identifier

timestamps instance-attribute

timestamps: List[Timestamp] = timestamps

values instance-attribute

values: List[Any] = values

columns

columns(
    time_column_name: Optional[str] = None,
    value_column_name: Optional[str] = None,
) -> Dict[str, List[Any]]

Returns both the time and value columns with options to override the column names.

time_column

time_column(
    column_name: Optional[str] = None,
) -> Dict[str, List[Any]]

Returns a single key-value pair dictionary meant to represent the time column of the data-set. column_name can be used to override the name of the column.

value_column

value_column(
    column_name: Optional[str] = None,
) -> Dict[str, List[Any]]

Returns a single key-value pair dictionary meant to represent the value column of the data-set. column_name can be used to override the name of the column.

ExpressionChannelReference

Bases: TypedDict

ATTRIBUTE DESCRIPTION
channel_name

TYPE: str

component

TYPE: NotRequired[str]

data_type

TYPE: NotRequired[ChannelDataType]

reference

TYPE: str

channel_name instance-attribute

channel_name: str

component instance-attribute

component: NotRequired[str]

data_type instance-attribute

data_type: NotRequired[ChannelDataType]

reference instance-attribute

reference: str