From 931f68837a7af8107d87eaa462e7eb0c140a113a Mon Sep 17 00:00:00 2001 From: BigTava Date: Mon, 6 Jan 2025 13:01:42 +0000 Subject: [PATCH 1/8] GSYE-719: export carbon emissions after cli simulation --- src/gsy_e/gsy_e_core/cli.py | 6 ++ src/gsy_e/gsy_e_core/export.py | 19 +++++- .../gsy_e_core/simulation/results_manager.py | 5 +- src/gsy_e/gsy_e_core/simulation/simulation.py | 2 + tests/results/__init__.py | 0 tests/results/constants.py | 0 tests/results/test_results.py | 60 +++++++++++++++++++ 7 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 tests/results/__init__.py create mode 100644 tests/results/constants.py create mode 100644 tests/results/test_results.py diff --git a/src/gsy_e/gsy_e_core/cli.py b/src/gsy_e/gsy_e_core/cli.py index 15d5a14d13..ab8777bf7b 100644 --- a/src/gsy_e/gsy_e_core/cli.py +++ b/src/gsy_e/gsy_e_core/cli.py @@ -181,6 +181,12 @@ def main(log_level): help="Market type. 1 for one-sided market, 2 for two-sided market, " "3 for coefficient-based trading.", ) +@click.option( + "--country-code", + type=str, + default=False, + help="Country code according to ISO 3166-1 alpha-2.", +) def run( setup_module_name, settings_file, diff --git a/src/gsy_e/gsy_e_core/export.py b/src/gsy_e/gsy_e_core/export.py index 1c47a09af6..ae1954bd8c 100644 --- a/src/gsy_e/gsy_e_core/export.py +++ b/src/gsy_e/gsy_e_core/export.py @@ -35,6 +35,7 @@ ) from gsy_framework.enums import AvailableMarketTypes, BidOfferMatchAlgoEnum, SpotMarketTypeEnum from gsy_framework.utils import mkdir_from_str +from gsy_framework.sim_results.carbon_emissions import CarbonEmissionsHandler from pendulum import DateTime import gsy_e.constants @@ -56,6 +57,7 @@ from gsy_e.gsy_e_core.util import constsettings_to_dict from gsy_e.models.area import Area + if TYPE_CHECKING: from gsy_e.gsy_e_core.sim_results.endpoint_buffer import SimulationEndpointBuffer from gsy_e.models.area.scm_manager import SCMManager @@ -84,6 +86,7 @@ "trade_profile": "trade_profile", "imported_exported_energy": "imported_exported_energy", "hierarchy_self_consumption_percent": "hierarchy_self_consumption_percent", + "carbon_emissions": "carbon_emissions", } @@ -93,12 +96,13 @@ class ExportAndPlot: # pylint: disable=too-many-arguments def __init__( - self, root_area: Area, path: str, subdir: str, endpoint_buffer: "SimulationEndpointBuffer" + self, root_area: Area, path: str, subdir: str, endpoint_buffer: "SimulationEndpointBuffer", country_code: str ): self.area = root_area self.endpoint_buffer = endpoint_buffer self.file_stats_endpoint = file_export_endpoints_factory() self.raw_data_subdir = None + self.country_code = country_code try: if path is not None: path = os.path.abspath(path) @@ -126,10 +130,23 @@ def _export_json_data(self) -> None: json.dump(constsettings_to_dict(), outfile, indent=2) for in_key, value in self.endpoint_buffer.generate_json_report().items(): out_key = results_field_to_json_filename_mapping[in_key] + + # Only to export carbon emissions + if in_key == "trade_profile" and self.country_code: + carbon_emissions_handler = CarbonEmissionsHandler( + entsoe_api_key=os.environ.get("ENTSOE_API_SECURITY_TOKEN", None) + ) + value = carbon_emissions_handler.calculate_carbon_emissions_from_gsy_trade_profile( + country_code=self.country_code, trade_profile=value + ) + out_key = "carbon_emissions" + json_file = os.path.join(json_dir, out_key + ".json") with open(json_file, "w", encoding="utf-8") as outfile: json.dump(value, outfile, indent=2) + + def _export_setup_json(self) -> None: setup_json_file = os.path.join(self.directory, "setup_file.json") diff --git a/src/gsy_e/gsy_e_core/simulation/results_manager.py b/src/gsy_e/gsy_e_core/simulation/results_manager.py index b8fcb54ad6..7d5c38c4b0 100644 --- a/src/gsy_e/gsy_e_core/simulation/results_manager.py +++ b/src/gsy_e/gsy_e_core/simulation/results_manager.py @@ -50,6 +50,7 @@ def __init__( export_path: str, export_subdir: Optional[str], started_from_cli: bool, + country_code: str = None, ) -> None: self.export_results_on_finish = export_results_on_finish self.export_path = export_path @@ -63,6 +64,7 @@ def __init__( self._endpoint_buffer = None self._export = None self._scm_manager = None + self.country_code = country_code def init_results( self, redis_job_id: str, area: "AreaBase", config_params: "SimulationSetup" @@ -71,10 +73,9 @@ def init_results( self._endpoint_buffer = SimulationEndpointBuffer( redis_job_id, config_params.seed, area, self.export_results_on_finish ) - if self.export_results_on_finish: self._export = ExportAndPlot( - area, self.export_path, self.export_subdir, self._endpoint_buffer + area, self.export_path, self.export_subdir, self._endpoint_buffer, self.country_code ) @property diff --git a/src/gsy_e/gsy_e_core/simulation/simulation.py b/src/gsy_e/gsy_e_core/simulation/simulation.py index 3bf4fb3a92..87e7344487 100644 --- a/src/gsy_e/gsy_e_core/simulation/simulation.py +++ b/src/gsy_e/gsy_e_core/simulation/simulation.py @@ -77,6 +77,7 @@ def __init__( enable_bc=False, slot_length_realtime: Duration = None, incremental: bool = False, + country_code: str = None, ): self.status = SimulationStatusManager( paused=paused, pause_after=pause_after, incremental=incremental @@ -100,6 +101,7 @@ def __init__( export_path=export_path, export_subdir=export_subdir, started_from_cli=redis_job_id is None, + country_code=country_code ) self.area = None diff --git a/tests/results/__init__.py b/tests/results/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/results/constants.py b/tests/results/constants.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/results/test_results.py b/tests/results/test_results.py new file mode 100644 index 0000000000..90751ef346 --- /dev/null +++ b/tests/results/test_results.py @@ -0,0 +1,60 @@ +""" +Copyright 2018 Grid Singularity +This file is part of Grid Singularity Exchange. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + +from unittest.mock import Mock, patch + +from gsy_framework.constants_limits import TIME_ZONE +from pendulum import duration, today + +from gsy_e.gsy_e_core.simulation import Simulation +from gsy_e.models.config import SimulationConfig + +class TestResults: + # pylint: disable=protected-access + + @staticmethod + @patch("gsy_e.gsy_e_core.simulation.external_events.SimulationExternalEvents", Mock()) + def test_results_are_calculated_correctly(): + # Given + simulation_config = SimulationConfig( + sim_duration=duration(hours=int(24)), + slot_length=duration(minutes=int(60)), + tick_length=duration(seconds=int(60)), + start_date=today(tz=TIME_ZONE), + external_connection_enabled=False, + ) + simulation = Simulation( + setup_module_name="two_sided_market.default_2a_high_res_graph", + simulation_config=simulation_config, + simulation_events=None, + seed=0, + paused=False, + pause_after=duration(), + repl=False, + no_export=True, + export_path=None, + export_subdir=None, + redis_job_id="null", + enable_bc=False, + ) + + # When + simulation.run() + + # Then + print("results = ", simulation._results._endpoint_buffer.generate_json_report()) From 4925a79663c9713f4adbbfd30d4017ab71ccfb9a Mon Sep 17 00:00:00 2001 From: BigTava Date: Wed, 8 Jan 2025 17:46:27 +0000 Subject: [PATCH 2/8] GSYE-719: change country-code default value to None --- src/gsy_e/gsy_e_core/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gsy_e/gsy_e_core/cli.py b/src/gsy_e/gsy_e_core/cli.py index ab8777bf7b..da06425b85 100644 --- a/src/gsy_e/gsy_e_core/cli.py +++ b/src/gsy_e/gsy_e_core/cli.py @@ -184,7 +184,7 @@ def main(log_level): @click.option( "--country-code", type=str, - default=False, + default=None, help="Country code according to ISO 3166-1 alpha-2.", ) def run( From b11e5ea665d1d7dc11b16f045aa332bbd5debde4 Mon Sep 17 00:00:00 2001 From: BigTava Date: Thu, 9 Jan 2025 17:10:34 +0000 Subject: [PATCH 3/8] GSYE-719: calculate carbon emissions from imported energy instead of trade_profile --- src/gsy_e/gsy_e_core/export.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/gsy_e/gsy_e_core/export.py b/src/gsy_e/gsy_e_core/export.py index ae1954bd8c..664f826644 100644 --- a/src/gsy_e/gsy_e_core/export.py +++ b/src/gsy_e/gsy_e_core/export.py @@ -131,22 +131,19 @@ def _export_json_data(self) -> None: for in_key, value in self.endpoint_buffer.generate_json_report().items(): out_key = results_field_to_json_filename_mapping[in_key] - # Only to export carbon emissions - if in_key == "trade_profile" and self.country_code: + if in_key == "imported_exported_energy" and self.country_code: carbon_emissions_handler = CarbonEmissionsHandler( entsoe_api_key=os.environ.get("ENTSOE_API_SECURITY_TOKEN", None) ) - value = carbon_emissions_handler.calculate_carbon_emissions_from_gsy_trade_profile( - country_code=self.country_code, trade_profile=value + value = carbon_emissions_handler.calculate_from_gsy_imported_exported_energy( + country_code=self.country_code, imported_exported_energy=value ) out_key = "carbon_emissions" - + json_file = os.path.join(json_dir, out_key + ".json") with open(json_file, "w", encoding="utf-8") as outfile: json.dump(value, outfile, indent=2) - - def _export_setup_json(self) -> None: setup_json_file = os.path.join(self.directory, "setup_file.json") From a3bd0ff4706da2ac5191e6d17688b032faf96224 Mon Sep 17 00:00:00 2001 From: BigTava Date: Thu, 23 Jan 2025 14:30:27 +0000 Subject: [PATCH 4/8] GSYE-719: improve cli help message and remove test_resutls --- src/gsy_e/gsy_e_core/cli.py | 2 +- tests/results/__init__.py | 0 tests/results/constants.py | 0 tests/results/test_results.py | 60 ----------------------------------- 4 files changed, 1 insertion(+), 61 deletions(-) delete mode 100644 tests/results/__init__.py delete mode 100644 tests/results/constants.py delete mode 100644 tests/results/test_results.py diff --git a/src/gsy_e/gsy_e_core/cli.py b/src/gsy_e/gsy_e_core/cli.py index 4f329da1ef..aa7e3ae8d5 100644 --- a/src/gsy_e/gsy_e_core/cli.py +++ b/src/gsy_e/gsy_e_core/cli.py @@ -186,7 +186,7 @@ def main(log_level): "--country-code", type=str, default=None, - help="Country code according to ISO 3166-1 alpha-2.", + help="Country code according to ISO 3166-1 alpha-2. Only used for calculating carbon emissions.", ) def run( setup_module_name, diff --git a/tests/results/__init__.py b/tests/results/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/results/constants.py b/tests/results/constants.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/results/test_results.py b/tests/results/test_results.py deleted file mode 100644 index 90751ef346..0000000000 --- a/tests/results/test_results.py +++ /dev/null @@ -1,60 +0,0 @@ -""" -Copyright 2018 Grid Singularity -This file is part of Grid Singularity Exchange. - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -""" - -from unittest.mock import Mock, patch - -from gsy_framework.constants_limits import TIME_ZONE -from pendulum import duration, today - -from gsy_e.gsy_e_core.simulation import Simulation -from gsy_e.models.config import SimulationConfig - -class TestResults: - # pylint: disable=protected-access - - @staticmethod - @patch("gsy_e.gsy_e_core.simulation.external_events.SimulationExternalEvents", Mock()) - def test_results_are_calculated_correctly(): - # Given - simulation_config = SimulationConfig( - sim_duration=duration(hours=int(24)), - slot_length=duration(minutes=int(60)), - tick_length=duration(seconds=int(60)), - start_date=today(tz=TIME_ZONE), - external_connection_enabled=False, - ) - simulation = Simulation( - setup_module_name="two_sided_market.default_2a_high_res_graph", - simulation_config=simulation_config, - simulation_events=None, - seed=0, - paused=False, - pause_after=duration(), - repl=False, - no_export=True, - export_path=None, - export_subdir=None, - redis_job_id="null", - enable_bc=False, - ) - - # When - simulation.run() - - # Then - print("results = ", simulation._results._endpoint_buffer.generate_json_report()) From 2fadd057a06ab69cec4686627f7f7c7265597d26 Mon Sep 17 00:00:00 2001 From: BigTava Date: Thu, 23 Jan 2025 14:43:33 +0000 Subject: [PATCH 5/8] GSYE-719: update requirements with the locked numpy==1.24.4 --- requirements/base.in | 2 +- requirements/base.txt | 31 +-------------------------- requirements/dev.txt | 48 ++---------------------------------------- requirements/tests.txt | 44 +------------------------------------- 4 files changed, 5 insertions(+), 120 deletions(-) diff --git a/requirements/base.in b/requirements/base.in index 86dc1551af..ad7471b84d 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -4,7 +4,7 @@ cached_property click click-default-group colorlog==4.7.2 -numpy +numpy==1.24.4 pendulum==2.1.2 plotly python-rex diff --git a/requirements/base.txt b/requirements/base.txt index c302ec6c9f..2c0d20bc6d 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -6,8 +6,6 @@ # -e git+https://github.com/gridsingularity/gsy-framework@master#egg=gsy_framework # via -r requirements/base.in -async-timeout==4.0.3 - # via gsy-framework attrs==23.2.0 # via # -r requirements/base.in @@ -72,12 +70,6 @@ filelock==3.14.0 # gsy-framework # tox # virtualenv -flake8==4.0.1 - # via - # flake8-tuple - # gsy-framework -flake8-tuple==0.4.1 - # via gsy-framework geocoder==1.17.5 # via gsy-framework identify==2.5.36 @@ -88,8 +80,6 @@ idna==3.7 # via # gsy-framework # requests -importlib-resources==6.4.0 - # via gsy-framework jsonschema==4.22.0 # via gsy-framework jsonschema-specifications==2023.12.1 @@ -98,17 +88,13 @@ jsonschema-specifications==2023.12.1 # jsonschema kafka-python==2.0.2 # via gsy-framework -mccabe==0.6.1 - # via - # flake8 - # gsy-framework mpmath==1.3.0 # via sympy nodeenv==1.8.0 # via # gsy-framework # pre-commit -numpy==1.26.4 +numpy==1.24.4 # via -r requirements/base.in openpyxl==3.0.10 # via gsy-framework @@ -122,8 +108,6 @@ pendulum==2.1.2 # via # -r requirements/base.in # gsy-framework -pkgutil-resolve-name==1.3.10 - # via gsy-framework platformdirs==4.2.2 # via # gsy-framework @@ -143,14 +127,6 @@ psycopg2==2.9.9 # via -r requirements/base.in psycopg2-binary==2.9.9 # via -r requirements/base.in -pycodestyle==2.8.0 - # via - # flake8 - # gsy-framework -pyflakes==2.4.0 - # via - # flake8 - # gsy-framework pyproject-api==1.6.1 # via # gsy-framework @@ -200,7 +176,6 @@ rq==1.16.2 # via -r requirements/base.in six==1.16.0 # via - # flake8-tuple # geocoder # gsy-framework # python-dateutil @@ -213,8 +188,6 @@ tabulate==0.9.0 # via gsy-framework tenacity==8.3.0 # via plotly -tomli==2.0.1 - # via gsy-framework tox==4.15.0 # via gsy-framework unidecode==0.4.21 @@ -230,8 +203,6 @@ virtualenv==20.26.2 # tox websockets==12.0 # via gsy-framework -zipp==3.18.2 - # via gsy-framework # The following packages are considered to be unsafe in a requirements file: # setuptools diff --git a/requirements/dev.txt b/requirements/dev.txt index 384585f13b..220c12eb3c 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -8,10 +8,6 @@ # via -r requirements/base.txt astroid==3.2.1 # via pylint -async-timeout==4.0.3 - # via - # -r requirements/base.txt - # gsy-framework attrs==23.2.0 # via # -r requirements/base.txt @@ -103,15 +99,6 @@ filelock==3.14.0 # gsy-framework # tox # virtualenv -flake8==4.0.1 - # via - # -r requirements/base.txt - # flake8-tuple - # gsy-framework -flake8-tuple==0.4.1 - # via - # -r requirements/base.txt - # gsy-framework geocoder==1.17.5 # via # -r requirements/base.txt @@ -126,10 +113,6 @@ idna==3.7 # -r requirements/base.txt # gsy-framework # requests -importlib-resources==6.4.0 - # via - # -r requirements/base.txt - # gsy-framework invoke==2.2.0 # via fabric isort==5.13.2 @@ -148,11 +131,7 @@ kafka-python==2.0.2 # -r requirements/base.txt # gsy-framework mccabe==0.6.1 - # via - # -r requirements/base.txt - # flake8 - # gsy-framework - # pylint + # via pylint mpmath==1.3.0 # via # -r requirements/base.txt @@ -162,7 +141,7 @@ nodeenv==1.8.0 # -r requirements/base.txt # gsy-framework # pre-commit -numpy==1.26.4 +numpy==1.24.4 # via -r requirements/base.txt openpyxl==3.0.10 # via @@ -181,10 +160,6 @@ pendulum==2.1.2 # via # -r requirements/base.txt # gsy-framework -pkgutil-resolve-name==1.3.10 - # via - # -r requirements/base.txt - # gsy-framework platformdirs==4.2.2 # via # -r requirements/base.txt @@ -211,18 +186,8 @@ psycopg2==2.9.9 # via -r requirements/base.txt psycopg2-binary==2.9.9 # via -r requirements/base.txt -pycodestyle==2.8.0 - # via - # -r requirements/base.txt - # flake8 - # gsy-framework pycparser==2.22 # via cffi -pyflakes==2.4.0 - # via - # -r requirements/base.txt - # flake8 - # gsy-framework pylint==3.2.0 # via -r requirements/dev.in pynacl==1.5.0 @@ -288,7 +253,6 @@ rq==1.16.2 six==1.16.0 # via # -r requirements/base.txt - # flake8-tuple # geocoder # gsy-framework # python-dateutil @@ -305,10 +269,6 @@ tenacity==8.3.0 # via # -r requirements/base.txt # plotly -tomli==2.0.1 - # via - # -r requirements/base.txt - # gsy-framework tomlkit==0.12.5 # via pylint tox==4.15.0 @@ -336,10 +296,6 @@ websockets==12.0 # gsy-framework wrapt==1.16.0 # via deprecated -zipp==3.18.2 - # via - # -r requirements/base.txt - # gsy-framework # The following packages are considered to be unsafe in a requirements file: # setuptools diff --git a/requirements/tests.txt b/requirements/tests.txt index 3d8f202d86..ed6411f3dc 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -10,10 +10,6 @@ astroid==3.2.1 # via # -r requirements/dev.txt # pylint -async-timeout==4.0.3 - # via - # -r requirements/dev.txt - # gsy-framework attrs==23.2.0 # via # -r requirements/dev.txt @@ -131,15 +127,6 @@ filelock==3.14.0 # gsy-framework # tox # virtualenv -flake8==4.0.1 - # via - # -r requirements/dev.txt - # flake8-tuple - # gsy-framework -flake8-tuple==0.4.1 - # via - # -r requirements/dev.txt - # gsy-framework geocoder==1.17.5 # via # -r requirements/dev.txt @@ -158,10 +145,6 @@ idna==3.7 # -r requirements/dev.txt # gsy-framework # requests -importlib-resources==6.4.0 - # via - # -r requirements/dev.txt - # gsy-framework iniconfig==2.0.0 # via pytest invoke==2.2.0 @@ -193,8 +176,6 @@ markupsafe==2.1.5 mccabe==0.6.1 # via # -r requirements/dev.txt - # flake8 - # gsy-framework # pylint mpmath==1.3.0 # via @@ -205,7 +186,7 @@ nodeenv==1.8.0 # -r requirements/dev.txt # gsy-framework # pre-commit -numpy==1.26.4 +numpy==1.24.4 # via -r requirements/dev.txt openpyxl==3.0.10 # via @@ -237,10 +218,6 @@ pendulum==2.1.2 # via # -r requirements/dev.txt # gsy-framework -pkgutil-resolve-name==1.3.10 - # via - # -r requirements/dev.txt - # gsy-framework platformdirs==4.2.2 # via # -r requirements/dev.txt @@ -268,20 +245,10 @@ psycopg2==2.9.9 # via -r requirements/dev.txt psycopg2-binary==2.9.9 # via -r requirements/dev.txt -pycodestyle==2.8.0 - # via - # -r requirements/dev.txt - # flake8 - # gsy-framework pycparser==2.22 # via # -r requirements/dev.txt # cffi -pyflakes==2.4.0 - # via - # -r requirements/dev.txt - # flake8 - # gsy-framework pylint==3.2.0 # via -r requirements/dev.txt pynacl==1.5.0 @@ -365,7 +332,6 @@ six==1.16.0 # -r requirements/dev.txt # behave # configobj - # flake8-tuple # geocoder # gsy-framework # parse-type @@ -383,10 +349,6 @@ tenacity==8.3.0 # via # -r requirements/dev.txt # plotly -tomli==2.0.1 - # via - # -r requirements/dev.txt - # gsy-framework tomlkit==0.12.5 # via # -r requirements/dev.txt @@ -418,10 +380,6 @@ wrapt==1.16.0 # via # -r requirements/dev.txt # deprecated -zipp==3.18.2 - # via - # -r requirements/dev.txt - # gsy-framework # The following packages are considered to be unsafe in a requirements file: # setuptools From 634fd48ffc99d9decf5821ce24bec4963145b0a0 Mon Sep 17 00:00:00 2001 From: BigTava Date: Thu, 23 Jan 2025 15:07:33 +0000 Subject: [PATCH 6/8] GSYE_719: lock pytz==2024.2 --- requirements/base.in | 2 +- requirements/base.txt | 2 +- requirements/dev.txt | 2 +- requirements/tests.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements/base.in b/requirements/base.in index ad7471b84d..b0bd2be350 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -10,7 +10,7 @@ plotly python-rex redis rq -pytz +pytz==2024.2 sortedcontainers sympy pony diff --git a/requirements/base.txt b/requirements/base.txt index 2c0d20bc6d..f25682312c 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -137,7 +137,7 @@ python-dateutil==2.9.0.post0 # pendulum python-rex==0.4 # via -r requirements/base.in -pytz==2024.1 +pytz==2024.2 # via -r requirements/base.in pytzdata==2020.1 # via diff --git a/requirements/dev.txt b/requirements/dev.txt index 220c12eb3c..f924ed8cf6 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -204,7 +204,7 @@ python-dateutil==2.9.0.post0 # pendulum python-rex==0.4 # via -r requirements/base.txt -pytz==2024.1 +pytz==2024.2 # via -r requirements/base.txt pytzdata==2020.1 # via diff --git a/requirements/tests.txt b/requirements/tests.txt index ed6411f3dc..fbbbb943db 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -279,7 +279,7 @@ python-dateutil==2.9.0.post0 # pendulum python-rex==0.4 # via -r requirements/dev.txt -pytz==2024.1 +pytz==2024.2 # via -r requirements/dev.txt pytzdata==2020.1 # via From 5f0c48e90b69440f684431ab51bd4ce160b5e165 Mon Sep 17 00:00:00 2001 From: BigTava Date: Thu, 23 Jan 2025 16:17:21 +0000 Subject: [PATCH 7/8] GSYE-719: fix flake8 warnings when running tox --- src/gsy_e/gsy_e_core/cli.py | 3 ++- src/gsy_e/gsy_e_core/export.py | 7 ++++++- src/gsy_e/gsy_e_core/simulation/results_manager.py | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gsy_e/gsy_e_core/cli.py b/src/gsy_e/gsy_e_core/cli.py index aa7e3ae8d5..b4b695e690 100644 --- a/src/gsy_e/gsy_e_core/cli.py +++ b/src/gsy_e/gsy_e_core/cli.py @@ -186,7 +186,8 @@ def main(log_level): "--country-code", type=str, default=None, - help="Country code according to ISO 3166-1 alpha-2. Only used for calculating carbon emissions.", + help="Country code according to ISO 3166-1 alpha-2. Only used for " + "calculating carbon emissions.", ) def run( setup_module_name, diff --git a/src/gsy_e/gsy_e_core/export.py b/src/gsy_e/gsy_e_core/export.py index aa6d244d7d..b8352ff178 100644 --- a/src/gsy_e/gsy_e_core/export.py +++ b/src/gsy_e/gsy_e_core/export.py @@ -96,7 +96,12 @@ class ExportAndPlot: # pylint: disable=too-many-arguments def __init__( - self, root_area: Area, path: str, subdir: str, endpoint_buffer: "SimulationEndpointBuffer", country_code: str + self, + root_area: Area, + path: str, + subdir: str, + endpoint_buffer: "SimulationEndpointBuffer", + country_code: str, ): self.area = root_area self.endpoint_buffer = endpoint_buffer diff --git a/src/gsy_e/gsy_e_core/simulation/results_manager.py b/src/gsy_e/gsy_e_core/simulation/results_manager.py index 7d5c38c4b0..e4a63b5978 100644 --- a/src/gsy_e/gsy_e_core/simulation/results_manager.py +++ b/src/gsy_e/gsy_e_core/simulation/results_manager.py @@ -75,7 +75,11 @@ def init_results( ) if self.export_results_on_finish: self._export = ExportAndPlot( - area, self.export_path, self.export_subdir, self._endpoint_buffer, self.country_code + area, + self.export_path, + self.export_subdir, + self._endpoint_buffer, + self.country_code, ) @property From e436bee092a0d075936e2af8d2fb5be87d59b09e Mon Sep 17 00:00:00 2001 From: BigTava Date: Wed, 29 Jan 2025 15:52:46 +0000 Subject: [PATCH 8/8] GSYE-719: fix psycopg2==2.9.10 --- requirements/base.in | 4 ++-- requirements/base.txt | 4 ++-- requirements/dev.txt | 4 ++-- requirements/tests.txt | 4 ++-- src/gsy_e/gsy_e_core/export.py | 2 +- tox.ini | 1 + 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/requirements/base.in b/requirements/base.in index b0bd2be350..c8e4dd44d4 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -14,7 +14,7 @@ pytz==2024.2 sortedcontainers sympy pony -psycopg2==2.9.9 -psycopg2-binary==2.9.9 +psycopg2==2.9.10 +psycopg2-binary==2.9.10 -e git+https://github.com/gridsingularity/gsy-framework@master#egg=gsy_framework diff --git a/requirements/base.txt b/requirements/base.txt index f25682312c..f77a1de0db 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -123,9 +123,9 @@ pony==0.7.17 # via -r requirements/base.in pre-commit==3.5.0 # via gsy-framework -psycopg2==2.9.9 +psycopg2==2.9.10 # via -r requirements/base.in -psycopg2-binary==2.9.9 +psycopg2-binary==2.9.10 # via -r requirements/base.in pyproject-api==1.6.1 # via diff --git a/requirements/dev.txt b/requirements/dev.txt index f924ed8cf6..955360b5bb 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -182,9 +182,9 @@ pre-commit==3.5.0 # gsy-framework psutil==5.9.8 # via -r requirements/dev.in -psycopg2==2.9.9 +psycopg2==2.9.10 # via -r requirements/base.txt -psycopg2-binary==2.9.9 +psycopg2-binary==2.9.10 # via -r requirements/base.txt pycparser==2.22 # via cffi diff --git a/requirements/tests.txt b/requirements/tests.txt index fbbbb943db..36ef39edc4 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -241,9 +241,9 @@ pre-commit==3.5.0 # gsy-framework psutil==5.9.8 # via -r requirements/dev.txt -psycopg2==2.9.9 +psycopg2==2.9.10 # via -r requirements/dev.txt -psycopg2-binary==2.9.9 +psycopg2-binary==2.9.10 # via -r requirements/dev.txt pycparser==2.22 # via diff --git a/src/gsy_e/gsy_e_core/export.py b/src/gsy_e/gsy_e_core/export.py index b8352ff178..9f87d8f5f0 100644 --- a/src/gsy_e/gsy_e_core/export.py +++ b/src/gsy_e/gsy_e_core/export.py @@ -35,7 +35,7 @@ ) from gsy_framework.enums import AvailableMarketTypes, BidOfferMatchAlgoEnum from gsy_framework.utils import mkdir_from_str -from gsy_framework.sim_results.carbon_emissions import CarbonEmissionsHandler +from gsy_framework.sim_results.carbon_emissions.results import CarbonEmissionsHandler from pendulum import DateTime import gsy_e.constants diff --git a/tox.ini b/tox.ini index 35813dfebf..c30bf3dfb5 100644 --- a/tox.ini +++ b/tox.ini @@ -29,6 +29,7 @@ allowlist_externals = behavex rm ln + flake8 [testenv:setup] pass_env = {[pkgenv]pass_env}