Exemplo n.º 1
0
def disabled_test_time_series_api_write():
    prediction_storage_provider = TimeSeriesAPIPredictionStorageProvider(
        _get_config())
    prediction_data = PredictionData(name=name,
                                     time_range=time_range,
                                     data=data)
    prediction_storage_provider.put_predictions(prediction_data)
Exemplo n.º 2
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)
Exemplo n.º 3
0
def prediction_storage_provider_factory(prediction_storage_provider_config):
    prediction_storage_provider_type = prediction_storage_provider_config.get(
        "type", None
    )
    prediction_storage_provider = None

    if "time_series_api" == prediction_storage_provider_type:
        from latigo.time_series_api import TimeSeriesAPIPredictionStorageProvider

        prediction_storage_provider = TimeSeriesAPIPredictionStorageProvider(
            prediction_storage_provider_config
        )

    elif "influx" == prediction_storage_provider_type:
        from latigo.prediction_storage_provider import InfluxPredictionStorageProvider

        prediction_storage_provider = InfluxPredictionStorageProvider(
            prediction_storage_provider_config
        )
    elif "mock" == prediction_storage_provider_type:
        prediction_storage_provider = MockPredictionStorageProvider(
            prediction_storage_provider_config
        )
    else:
        prediction_storage_provider = DevNullPredictionStorageProvider(
            prediction_storage_provider_config
        )
    return prediction_storage_provider
Exemplo n.º 4
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)
Exemplo n.º 5
0
def prediction_storage(config) -> TimeSeriesAPIPredictionStorageProvider:
    prediction_storage = TimeSeriesAPIPredictionStorageProvider(
        config["prediction_storage"])
    return prediction_storage