-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
473 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
nisystemlink/clients/dataframe/models/_query_decimated_data_request.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from enum import Enum | ||
from typing import List, Optional | ||
|
||
from nisystemlink.clients.core._uplink._json_model import JsonModel | ||
|
||
from ._query_table_data_base import QueryTableDataBase | ||
|
||
|
||
class DecimationMethod(str, Enum): | ||
"""Represents the different methods that can be used to decimate data.""" | ||
|
||
Lossy = "LOSSY" | ||
"""Creates an ``x_column`` ordered set and returns an uniformly distributed | ||
sample of rows with as many rows as the number specified as ``intervals.``""" | ||
|
||
MaxMin = "MAX_MIN" | ||
"""Creates an ``x_column`` ordered set which will be divided in the number of | ||
``intervals`` specified. For each of the intervals, the maximum and minimum | ||
values for all the columns specified in ``y_columns`` will be returned.""" | ||
|
||
EntryExit = "ENTRY_EXIT" | ||
"""Creates an ``x_column`` ordered set which will be divided in the number of | ||
``intervals`` specified. For each of the intervals, the first and last row | ||
within the interval will be returned in addition to the maximum and minimum | ||
values for all the columns specified in ``y_columns``.""" | ||
|
||
|
||
class DecimationOptions(JsonModel): | ||
"""Contains the parameters to use for data decimation.""" | ||
|
||
x_column: Optional[str] = None | ||
"""The name of the column that will be used as the x-axis for decimating the | ||
data. The column in the table that was specified as Index will be used if | ||
this field is excluded. Only numeric columns are supported. i.e. ``INT32``, | ||
``INT64``, ``FLOAT32``, ``FLOAT64`` and ``TIMESTAMP``.""" | ||
|
||
y_columns: Optional[List[str]] = None | ||
"""A list of columns to decimate by. This property is only needed when the | ||
specified method is ``MAX_MIN`` or ``ENTRY_EXIT``. Only numeric columns are | ||
supported. i.e. ``INT32``, ``INT64``, ``FLOAT32``, ``FLOAT64`` and | ||
``TIMESTAMP``.""" | ||
|
||
intervals: Optional[int] = None | ||
"""Number of intervals to use for decimation. Defaults to 1000.""" | ||
|
||
method: Optional[DecimationMethod] = None | ||
"""Specifies the method used to decimate the data. Defaults to | ||
:class:`DecimationMethod.Lossy`""" | ||
|
||
|
||
class QueryDecimatedDataRequest(QueryTableDataBase): | ||
"""Specifies the columns, filters and decimation parameters for a query.""" | ||
|
||
decimation: Optional[DecimationOptions] = None | ||
"""The decimation options to use when querying data. If not specified, the | ||
default is to use :class:`DecimationMethod.Lossy` with 1000 intervals over | ||
the table's index column.""" |
54 changes: 54 additions & 0 deletions
54
nisystemlink/clients/dataframe/models/_query_table_data_base.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from enum import Enum | ||
from typing import List, Optional | ||
|
||
from nisystemlink.clients.core._uplink._json_model import JsonModel | ||
|
||
|
||
class FilterOperation(str, Enum): | ||
"""Represents the different operations that can be used in a filter.""" | ||
|
||
Equals = "EQUALS" | ||
NotEquals = "NOT_EQUALS" | ||
LessThan = "LESS_THAN" | ||
LessThanEquals = "LESS_THAN_EQUALS" | ||
GreaterThan = "GREATER_THAN" | ||
GreaterThanEquals = "GREATER_THAN_EQUALS" | ||
Contains = "CONTAINS" | ||
NotContains = "NOT_CONTAINS" | ||
|
||
|
||
class ColumnFilter(JsonModel): | ||
"""A filter to apply to the table data.""" | ||
|
||
column: str | ||
"""The name of the column to use for filtering.""" | ||
|
||
operation: FilterOperation | ||
"""How to compare the column's value with the specified value. | ||
An error is returned if the column's data type does not support the specified operation: | ||
* String columns only support ``EQUALS``, ``NOT_EQUALS``, ``CONTAINS``, and ``NOT_CONTAINS``. | ||
* Non-string columns do not support ``CONTAINS`` or ``NOT_CONTAINS``. | ||
* When ``value`` is ``None``, the operation must be ``EQUALS`` or ``NOT_EQUALS``. | ||
* When ``value`` is ``NaN`` for a floating-point column, the operation must be ``NOT_EQUALS``. | ||
""" | ||
|
||
value: Optional[str] | ||
"""The comparison value to use for filtering. An error will be returned if | ||
the value cannot be converted to the column's data type.""" | ||
|
||
|
||
class QueryTableDataBase(JsonModel): | ||
"""Contains the common set of options when querying table data.""" | ||
|
||
columns: Optional[List[str]] = None | ||
"""The names of columns to include in the response. The response will | ||
include the columns in the same order specified in this parameter. All | ||
columns are included in the order specified at table creation if this | ||
property is excluded.""" | ||
|
||
filters: Optional[List[ColumnFilter]] = None | ||
"""A list of columns to filter by. Only rows whose columns contain values | ||
matching all of the specified filters are returned. The columns used for | ||
filtering do not need to be included in the columns list. When reading | ||
decimated data, the filters are applied before decimation.""" |
30 changes: 30 additions & 0 deletions
30
nisystemlink/clients/dataframe/models/_query_table_data_request.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from typing import List, Optional | ||
|
||
from nisystemlink.clients.core._uplink._json_model import JsonModel | ||
from nisystemlink.clients.core._uplink._with_paging import WithPaging | ||
|
||
from ._query_table_data_base import QueryTableDataBase | ||
|
||
|
||
class ColumnOrderBy(JsonModel): | ||
"""Specifies a column to order by and the ordering direction.""" | ||
|
||
column: str | ||
"""The name of the column to order by.""" | ||
|
||
descending: Optional[bool] = None | ||
"""Whether the ordering should be in descending order.""" | ||
|
||
|
||
class QueryTableDataRequest(QueryTableDataBase, WithPaging): | ||
"""Contains the filtering and sorting options to use when querying table data.""" | ||
|
||
order_by: Optional[List[ColumnOrderBy]] = None | ||
"""A list of columns to order the results by. Multiple columns may be | ||
specified to order rows that have the same value for prior columns. The | ||
columns used for sorting do not need to be included in the columns list, in | ||
which case they are not returned. If ``order_by`` is not specified, then the | ||
order in which results are returned is undefined.""" | ||
|
||
take: Optional[int] = None | ||
"""Limits the returned list to the specified number of results.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from nisystemlink.clients.core._uplink._json_model import JsonModel | ||
|
||
from ._data_frame import DataFrame | ||
|
||
|
||
class TableRows(JsonModel): | ||
"""Contains the result of a query for rows of decimated data.""" | ||
|
||
frame: DataFrame | ||
"""The data frame containing the rows of data.""" |
Oops, something went wrong.