From e9317147beed4cdd6e7c057963081a0bf6990364 Mon Sep 17 00:00:00 2001 From: MeenaBana Date: Tue, 20 Aug 2024 12:16:47 +0200 Subject: [PATCH] Renamed function and updated relevant usages. --- notebooks/Example_Data_Downloading.ipynb | 18 ------------------ ...xploring_API_Functions_Authentication.ipynb | 10 +++++----- src/pyprediktormapclient/opc_ua.py | 6 +++--- tests/test_opc_ua.py | 2 +- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/notebooks/Example_Data_Downloading.ipynb b/notebooks/Example_Data_Downloading.ipynb index 6441fcb..3fa864b 100644 --- a/notebooks/Example_Data_Downloading.ipynb +++ b/notebooks/Example_Data_Downloading.ipynb @@ -218,24 +218,6 @@ "one_day_historic_inverter_data" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# 1 day aggregated historical inverter data in asyncio process\n", - "one_days_historic_inverter_data2 = await tsdata.get_historical_aggregated_values_async(\n", - " start_time=(datetime.datetime.now() - datetime.timedelta(30)),\n", - " end_time=(datetime.datetime.now() - datetime.timedelta(29)),\n", - " pro_interval=60*1000,\n", - " agg_name=\"Average\",\n", - " variable_list=inverters.variables_as_list(inv_var_list),\n", - " batch_size=500\n", - ")\n", - "one_days_historic_inverter_data2" - ] - }, { "cell_type": "code", "execution_count": null, diff --git a/notebooks/Exploring_API_Functions_Authentication.ipynb b/notebooks/Exploring_API_Functions_Authentication.ipynb index 865a5a6..7eff080 100644 --- a/notebooks/Exploring_API_Functions_Authentication.ipynb +++ b/notebooks/Exploring_API_Functions_Authentication.ipynb @@ -188,7 +188,7 @@ "outputs": [], "source": [ "# Selecting the single site\n", - "site_id = sites.list_of_ids()\n", + "site_id = sites.list_of_ids()[0]\n", "site_id" ] }, @@ -200,7 +200,7 @@ "source": [ "# Get all stringsets for one park\n", "string_sets_for_first_park_as_json = model_data.get_object_descendants(\n", - " \"StringSetType\", site_id, \"PV_Assets\"\n", + " \"StringSetType\", [site_id], \"PV_Assets\"\n", ")\n", "string_sets_for_first_park = AnalyticsHelper(string_sets_for_first_park_as_json)\n", "string_sets_for_first_park.dataframe" @@ -214,7 +214,7 @@ "source": [ "# All inverter data for the site\n", "inverter_json = model_data.get_object_descendants(\n", - " \"InverterType\", site_id, \"PV_Assets\"\n", + " \"InverterType\", [site_id], \"PV_Assets\"\n", ")\n", "inverters = AnalyticsHelper(inverter_json)" ] @@ -261,7 +261,7 @@ "source": [ "# Live value data of trackers\n", "live_value = opc_data.get_values(\n", - " trackers.variables_as_list([\"AngleMeasured\"])\n", + " inverters.variables_as_list([\"DCPower\"])\n", ")\n", "live_value" ] @@ -290,7 +290,7 @@ "outputs": [], "source": [ "# 1 day raw historical data\n", - "one_day_raw_historical_data = opc_data.get_raw_historical_values(\n", + "one_day_raw_historical_data = opc_data.get_historical_raw_values(\n", " start_time = datetime.datetime(2024, 7, 13, 00, 00),\n", " end_time = datetime.datetime(2024, 7, 13, 23, 59),\n", " variable_list=string_sets_for_first_park.variables_as_list([\"DCPower\"])\n", diff --git a/src/pyprediktormapclient/opc_ua.py b/src/pyprediktormapclient/opc_ua.py index 0dedce8..a449df5 100644 --- a/src/pyprediktormapclient/opc_ua.py +++ b/src/pyprediktormapclient/opc_ua.py @@ -453,7 +453,7 @@ async def process_batch(variables, time_batch): return combined_df - async def get_raw_historical_values_asyn( + async def get_historical_raw_values_asyn( self, start_time: datetime, end_time: datetime, @@ -487,8 +487,8 @@ async def get_raw_historical_values_asyn( } return self._process_df(combined_df, columns) - def get_raw_historical_values(self, *args, **kwargs): - result = self.helper.run_coroutine(self.get_raw_historical_values_asyn(*args, **kwargs)) + def get_historical_raw_values(self, *args, **kwargs): + result = self.helper.run_coroutine(self.get_historical_raw_values_asyn(*args, **kwargs)) return result diff --git a/tests/test_opc_ua.py b/tests/test_opc_ua.py index cf8a991..c37c53b 100644 --- a/tests/test_opc_ua.py +++ b/tests/test_opc_ua.py @@ -823,7 +823,7 @@ async def make_historical_request(): async def make_raw_historical_request(): tsdata = OPC_UA(rest_url=URL, opcua_url=OPC_URL) - return await tsdata.get_raw_historical_values_asyn( + return await tsdata.get_historical_raw_values_asyn( start_time=(datetime.datetime.now() - datetime.timedelta(30)), end_time=(datetime.datetime.now() - datetime.timedelta(29)), variable_list=list_of_ids,