Esempio n. 1
0
def test_name_lookup_bug1():
    config = _get_config()
    logger.info("")
    logger.info("WRITING Data 1 ---------------")
    prediction_storage_provider = TimeSeriesAPIPredictionStorageProvider(
        config)
    name = "an inconspicuous tag name"
    in_meta = {"name": name, "unit": unit, "asset_id": asset}
    prediction_data = PredictionDataSet(meta_data=in_meta,
                                        time_range=time_range,
                                        data=data1_wrapped)
    out_meta1 = prediction_storage_provider.put_prediction(
        prediction_data=prediction_data)
    logger.info(pprint.pformat(out_meta1))
    logger.info("")
    logger.info("WRITING Data 2 ---------------")
    name2 = f"{name}_with_apendage"
    in_meta2 = {"name": name2, "unit": unit, "asset_id": asset}
    prediction_data2 = PredictionDataSet(meta_data=in_meta2,
                                         time_range=time_range,
                                         data=data2_wrapped)
    out_meta2 = prediction_storage_provider.put_prediction(
        prediction_data=prediction_data2)
    logger.info(pprint.pformat(out_meta2))
    logger.info("")
    logger.info("READING ---------------")
    sensor_data_provider = TimeSeriesAPISensorDataProvider(config)
    sensor_data = sensor_data_provider.get_data_for_range(
        spec=spec, time_range=time_range)
Esempio n. 2
0
def test_time_series_api_write_read():
    config = _get_config()
    logger.info("")
    logger.info("WRITING ---------------")
    prediction_storage_provider = TimeSeriesAPIPredictionStorageProvider(
        config)
    meta_data = {"unit": unit, "asset_id": asset, "name": name}
    prediction_data = PredictionDataSet(time_range=time_range,
                                        data=data1_wrapped,
                                        meta_data=meta_data)
    meta = prediction_storage_provider.put_prediction(
        prediction_data=prediction_data)
    logger.info(pprint.pformat(meta))
    logger.info("")
    logger.info("READING ---------------")
    sensor_data_provider = TimeSeriesAPISensorDataProvider(config)
    sensor_data = sensor_data_provider.get_data_for_range(
        spec=spec, time_range=time_range)
Esempio n. 3
0
def sensor_data_provider_factory(sensor_data_provider_config):
    sensor_data_provider_type = sensor_data_provider_config.get("type", None)

    if "time_series_api" == sensor_data_provider_type:
        from latigo.time_series_api import TimeSeriesAPISensorDataProvider

        sensor_data_provider = TimeSeriesAPISensorDataProvider(sensor_data_provider_config)
    else:
        raise ValueError(f"'{sensor_data_provider_type}' in not valid sensor data provider type")
    return sensor_data_provider
Esempio n. 4
0
def sensor_data_provider_factory(sensor_data_provider_config):
    sensor_data_provider_type = sensor_data_provider_config.get("type", None)
    sensor_data_provider = None

    if "time_series_api" == sensor_data_provider_type:
        from latigo.time_series_api import TimeSeriesAPISensorDataProvider

        sensor_data_provider = TimeSeriesAPISensorDataProvider(
            sensor_data_provider_config)
    elif "mock" == sensor_data_provider_type:
        sensor_data_provider = MockSensorDataProvider(
            sensor_data_provider_config)
    else:
        sensor_data_provider = DevNullSensorDataProvider(
            sensor_data_provider_config)
    return sensor_data_provider
Esempio n. 5
0
def disabled_test_time_series_api_actual_read():
    sensor_data_provider = TimeSeriesAPISensorDataProvider(_get_config())
    sensor_data = sensor_data_provider.get_data_for_range(
        spec=actual_spec, time_range=time_range)
    logger.info(pprint.pformat(sensor_data))
Esempio n. 6
0
def disabled_test_time_series_api_read():
    sensor_data_provider = TimeSeriesAPISensorDataProvider(_get_config())
    sensor_data = sensor_data_provider.get_data_for_range(
        spec=spec, time_range=time_range)
Esempio n. 7
0
def ts_api(config) -> TimeSeriesAPISensorDataProvider:
    return TimeSeriesAPISensorDataProvider(config["sensor_data"])