Units - Access object for time series data (unit format)¶
Provides access API to time series data resources (unit format). Unit is a resource that outputs the time series data in types described in Time series data objects.
Request Methods¶
Warning
Be sure to create the access object using units on client.
client = intdash.Client(...)
client.units.list(edge_name='test_edge', start='2020/07/01 09:00+09:00', end='2020/07/01 10:00+09:00')
- class Units(...)[source]¶
Access object for time series data (unit format).
- list(start, end, measurement_uuid=None, edge_uuid=None, edge_name=None, id_queries=None, labels=None, limit=None, iterator=False, exit_on_error=False)[source]¶
Retrieves the list of time series data (unit object).
- Parameters
start (pandas.Timestamp) – Start point of retrieval range
end (pandas.Timestamp) – End point of retrieval range
measurement_uuid (str) – UUID of the source measurement
edge_uuid (str) – UUID of the source edge
edge_name (str) – Name of the source edge
id_queries (list[IdQuery]) – List of IDs of the data to be retrieved
labels (list[str]) – List of labels of the data to be retrieved
limit (int) – Maximum number of items retrieved
iterator (bool) – If True, create an iterator.
exit_on_error (bool) – If true, if an error occurs during the retrieval, the process is aborted and the list of Units up to the point of interruption is returned.
- Returns
List of unit objects
- Return type
list[Unit]
Note
Specify one of
measurement_uuid
,edge_uuid
, oredge_name
. If specified at the same time, they will be referenced with the priority ofmeasurement_uuid
>edge_uuid
>edge_name
. Low priority parameters will be ignored.Note
If both
labels
andid_queries
are specified, all data that matches either of them will be the retrieved. (When usinglabels
, it is necessary to register a signal definition separately.)Note
If
limit
is not specified, all data in the specified range will be retrieved.If the size of the data to be retrieved is large, you can use the iterator that retrieves the data for each limit by specifying the upper limit for the number of retrievals inlimit
and settingiterator
toTrue
.For more information, see Retrieving time series data in Tutorial.Note
When an exception occurs in the retrieval process on the server side, the Unit that stores the exception message is output and the process ends normally (see the example below). The
data_type
of this Unit is String. If you want to interrupt the process when an exception occurs, assignTrue
toexit_on_error
.Examples
The following is an example when an exception occurs during data retrieval. The error message is stored in a Unit. The data_type of the Unit that stores the error message is String. The namespace of the endpoint where the error occurred is output to id. You can use the information in the Unit to retry or to investigate the cause.
>>> us = lc.units.list( measurement_uuid=sample_measurement.uuid, labels=['nmea', 'test'], start=sample_measurement.basetime, end=sample_measurement.basetime + pd.Timedelta(seconds=10), exit_on_error=False )
>>> import json >>> for u in us: if u.data.data_type.value == DataType.basetime.value: continue if 'error' in u.data.id: print(u) error_message = json.loads(u.data.value)['error_description'] raise ValueError(f'contains failed data: {error_message}') # elapsed_time: 0 days 00:00:00 # channel: 1 # measurement_uuid: 3b5b9bed-d509-4198-aea0-54ee714f7a5b # data_type: string # id: intdash/measurement/get/data/error # value: {"error":"converted_error","error_description":"Error occurred in signal conversion","error_extra":{"signal_channel":1,"signal_data_id":"GPRMC","signal_data_type":2,"signal_label":"nmea"}} ValueError: contains failed data: Error occurred in signal conversion
- store(measurement_uuid, units, serial_number=0, final=True)[source]¶
Stores time series data (unit object) to the server.
- Parameters
measurement_uuid (str) – UUID of the measurement
units (list[Unit]) – List of unit objects to be stored
serial_number (int) – Section serial number
final (bool) – Final flag
Note
The maximum amount of
units
that can be specified in a single operation is 2GB. if it exceeds 2GB, runstore()
multiple times.
Response¶
Refer to Time series data objects for data types.
- class Unit(...)[source]¶
An object that represents a Unit resource.
- elapsed_time¶
Elapsed time
- Type
pandas.Timedelta
- channel¶
Channel number
- Type
int
- data¶
Data
- Type
data.Data
Note
The request parameter object is the same as the object for DataPoints. Check DataPoints - Access object for time series data (data point format) for details.