diff --git a/CHANGELOG.md b/CHANGELOG.md index e48f1bc1..dc2da3e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +#### v0.2.2 +- Updated requirements for tutorials ([#132](https://github.com/RWTH-EBC/FiLiP/issues/132)) +- fixed quantumleap timeseries header ([#133](https://github.com/RWTH-EBC/FiLiP/issues/133)) +- fixed broken imports for tutorials ([#134](https://github.com/RWTH-EBC/FiLiP/issues/134)) + #### v0.2.1 - Updated documentation ([#128](https://github.com/RWTH-EBC/FiLiP/issues/128)) - Improve tutorials ([#127](https://github.com/RWTH-EBC/FiLiP/issues/127)) diff --git a/docs/source/conf.py b/docs/source/conf.py index 5a28397d..e1d8f65b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -24,7 +24,7 @@ author = 'E.ON ERC - EBC' # The full version, including alpha/beta/rc tags -release = '0.2.1' +release = '0.2.2' # The short X.Y version. version = '.'.join(release.split('.')[0:2]) diff --git a/filip/__init__.py b/filip/__init__.py index 15080bee..0eda5490 100644 --- a/filip/__init__.py +++ b/filip/__init__.py @@ -4,4 +4,4 @@ from filip.config import settings from filip.clients.ngsi_v2 import HttpClient -__version__ = '0.2.1' +__version__ = '0.2.2' diff --git a/filip/models/ngsi_v2/timeseries.py b/filip/models/ngsi_v2/timeseries.py index 31769506..19f4b764 100644 --- a/filip/models/ngsi_v2/timeseries.py +++ b/filip/models/ngsi_v2/timeseries.py @@ -3,7 +3,7 @@ """ from __future__ import annotations import logging -from typing import Any, List +from typing import Any, List, Union from datetime import datetime import numpy as np import pandas as pd @@ -18,7 +18,7 @@ class TimeSeriesBase(BaseModel): """ Base model for other time series api models """ - index: List[datetime] = Field( + index: Union[List[datetime], datetime] = Field( default=None, description="Array of the timestamps which are indexes of the response " "for the requested data. It's a parallel array to 'values'." @@ -37,7 +37,7 @@ class TimeSeriesHeader(TimeSeriesBase): """ Model to describe an available entity in the time series api """ - # aliases are required due to inconsistencies in the api-specs + # aliases are required due to formally inconsistencies in the api-specs entityId: str = Field(default=None, alias="id", description="The entity id the time series api." @@ -51,7 +51,7 @@ class TimeSeriesHeader(TimeSeriesBase): description="The type of an entity") class Config: - allow_population_by_field_name = False + allow_population_by_field_name = True class IndexedValues(BaseModel): diff --git a/requirements.txt b/requirements.txt index 5a20f422..97b1a84d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,4 +17,6 @@ wget >=3.2 stringcase>=1.2.0 igraph==0.9.8 paho-mqtt>=1.6.1 -datamodel_code_generator[http]>=0.11.16 \ No newline at end of file +datamodel_code_generator[http]>=0.11.16 +# tutorials +matplotlib>=3.5.1 \ No newline at end of file diff --git a/setup.py b/setup.py index 4633b42c..e1d59fff 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setuptools.setup( name='filip', - version='0.2.1', + version='0.2.2', author='RWTH Aachen University, E.ON Energy Research Center, Institute\ of Energy Efficient Buildings and Indoor Climate', author_email='tstorek@eonerc.rwth-aachen.de', diff --git a/tests/models/test_ngsiv2_timeseries.py b/tests/models/test_ngsiv2_timeseries.py index 2d28205d..0680b0c9 100644 --- a/tests/models/test_ngsiv2_timeseries.py +++ b/tests/models/test_ngsiv2_timeseries.py @@ -3,7 +3,7 @@ """ import logging import unittest -from filip.models.ngsi_v2.timeseries import TimeSeries +from filip.models.ngsi_v2.timeseries import TimeSeries, TimeSeriesHeader logger = logging.getLogger(__name__) @@ -72,6 +72,12 @@ def setUp(self) -> None: ] } + self.timeseries_header = {"entityId": "test_id", + "entityType": "test_type"} + + self.timeseries_header_alias = {"id": "test_id", + "type": "test_type"} + def test_model_creation(self): """ Test model creation @@ -92,6 +98,13 @@ def test_extend(self): with self.assertRaises(AssertionError): ts1.extend(ts2) + def test_timeseries_header(self): + header = TimeSeriesHeader(**self.timeseries_header) + header_by_alias = TimeSeriesHeader(**self.timeseries_header_alias) + self.assertEqual(header.dict(), header_by_alias.dict()) + self.assertEqual(header.dict(by_alias=True), + header_by_alias.dict(by_alias=True)) + if __name__ == '__main__': unittest.main() diff --git a/tutorials/ngsi_v2/e1_virtual_weatherstation.py b/tutorials/ngsi_v2/e1_virtual_weatherstation.py index 182faae4..33d2daab 100644 --- a/tutorials/ngsi_v2/e1_virtual_weatherstation.py +++ b/tutorials/ngsi_v2/e1_virtual_weatherstation.py @@ -29,7 +29,7 @@ import paho.mqtt.client as mqtt # import simulation model -from tutorial.ngsi_v2.simulation_model import SimulationModel +from tutorials.ngsi_v2.simulation_model import SimulationModel # ## Parameters diff --git a/tutorials/ngsi_v2/e1_virtual_weatherstation_solution.py b/tutorials/ngsi_v2/e1_virtual_weatherstation_solution.py index c46bf8e2..b2eaf1b0 100644 --- a/tutorials/ngsi_v2/e1_virtual_weatherstation_solution.py +++ b/tutorials/ngsi_v2/e1_virtual_weatherstation_solution.py @@ -29,7 +29,7 @@ import paho.mqtt.client as mqtt # import simulation model -from tutorial.ngsi_v2.simulation_model import SimulationModel +from tutorials.ngsi_v2.simulation_model import SimulationModel # ## Parameters diff --git a/tutorials/ngsi_v2/e4_iot_thermal_zone_sensors.py b/tutorials/ngsi_v2/e4_iot_thermal_zone_sensors.py index 5d644c96..883b280a 100644 --- a/tutorials/ngsi_v2/e4_iot_thermal_zone_sensors.py +++ b/tutorials/ngsi_v2/e4_iot_thermal_zone_sensors.py @@ -37,7 +37,7 @@ from filip.models.ngsi_v2.iot import Device, DeviceAttribute, ServiceGroup from filip.utils.cleanup import clear_context_broker, clear_iot_agent # import simulation model -from tutorial.ngsi_v2.simulation_model import SimulationModel +from tutorials.ngsi_v2.simulation_model import SimulationModel # ## Parameters # ToDo: Enter your context broker host and port, e.g. http://localhost:1026 diff --git a/tutorials/ngsi_v2/e4_iot_thermal_zone_sensors_solution.py b/tutorials/ngsi_v2/e4_iot_thermal_zone_sensors_solution.py index 8e21e3ed..e72965ed 100644 --- a/tutorials/ngsi_v2/e4_iot_thermal_zone_sensors_solution.py +++ b/tutorials/ngsi_v2/e4_iot_thermal_zone_sensors_solution.py @@ -37,7 +37,7 @@ from filip.models.ngsi_v2.iot import Device, DeviceAttribute, ServiceGroup from filip.utils.cleanup import clear_context_broker, clear_iot_agent # import simulation model -from tutorial.ngsi_v2.simulation_model import SimulationModel +from tutorials.ngsi_v2.simulation_model import SimulationModel # ## Parameters # ToDo: Enter your context broker host and port, e.g. http://localhost:1026 diff --git a/tutorials/ngsi_v2/e5_iot_thermal_zone_control.py b/tutorials/ngsi_v2/e5_iot_thermal_zone_control.py index c309921d..08d7beda 100644 --- a/tutorials/ngsi_v2/e5_iot_thermal_zone_control.py +++ b/tutorials/ngsi_v2/e5_iot_thermal_zone_control.py @@ -55,7 +55,7 @@ ServiceGroup from filip.utils.cleanup import clear_context_broker, clear_iot_agent # import simulation model -from tutorial.ngsi_v2.simulation_model import SimulationModel +from tutorials.ngsi_v2.simulation_model import SimulationModel # ## Parameters # ToDo: Enter your context broker host and port, e.g http://localhost:1026 diff --git a/tutorials/ngsi_v2/e5_iot_thermal_zone_control_solution.py b/tutorials/ngsi_v2/e5_iot_thermal_zone_control_solution.py index 95540108..3e30dcb6 100644 --- a/tutorials/ngsi_v2/e5_iot_thermal_zone_control_solution.py +++ b/tutorials/ngsi_v2/e5_iot_thermal_zone_control_solution.py @@ -55,7 +55,7 @@ ServiceGroup from filip.utils.cleanup import clear_context_broker, clear_iot_agent # import simulation model -from tutorial.ngsi_v2.simulation_model import SimulationModel +from tutorials.ngsi_v2.simulation_model import SimulationModel # ## Parameters # ToDo: Enter your context broker host and port, e.g http://localhost:1026 diff --git a/tutorials/ngsi_v2/e6_timeseries_data.py b/tutorials/ngsi_v2/e6_timeseries_data.py index 780c46c1..2777165d 100644 --- a/tutorials/ngsi_v2/e6_timeseries_data.py +++ b/tutorials/ngsi_v2/e6_timeseries_data.py @@ -42,7 +42,7 @@ clear_iot_agent, \ clear_quantumleap # import simulation model -from tutorial.ngsi_v2.simulation_model import SimulationModel +from tutorials.ngsi_v2.simulation_model import SimulationModel # ## Parameters # ToDo: Enter your context broker host and port, e.g http://localhost:1026 diff --git a/tutorials/ngsi_v2/e6_timeseries_data_solution.py b/tutorials/ngsi_v2/e6_timeseries_data_solution.py index 44acceec..89d31f6c 100644 --- a/tutorials/ngsi_v2/e6_timeseries_data_solution.py +++ b/tutorials/ngsi_v2/e6_timeseries_data_solution.py @@ -41,7 +41,7 @@ clear_iot_agent, \ clear_quantumleap # import simulation model -from tutorial.ngsi_v2.simulation_model import SimulationModel +from tutorials.ngsi_v2.simulation_model import SimulationModel # ## Parameters # ToDo: Enter your context broker host and port, e.g http://localhost:1026