Skip to content

Commit

Permalink
Merge pull request #535 from gridsingularity/feature/GSYE-737
Browse files Browse the repository at this point in the history
Feature/gsye 737
  • Loading branch information
spyrostz authored Aug 19, 2024
2 parents 0fee8e8 + d918b39 commit 8a11859
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 28 deletions.
4 changes: 2 additions & 2 deletions gsy_framework/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ class ResultsSchemas:
"percentage_completed": {"type": "number"},
},
"device_statistics": {"type": "object"},
"energy_trade_profile": {"type": "object"},
"last_energy_trade_profile": {"type": "object"},
"trade_profile": {"type": "object"},
"last_trade_profile": {"type": "object"},
"last_device_statistics": {"type": "object"},
"last_price_energy_day": {"type": "object"},
"kpi": {"type": "object"},
Expand Down
23 changes: 15 additions & 8 deletions gsy_framework/sim_results/aggregate_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,39 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

from datetime import date, timedelta # NOQA
from typing import Dict, List

from gsy_framework.sim_results.area_throughput_stats import AreaThroughputStats
from gsy_framework.sim_results.device_statistics import DeviceStatistics
from gsy_framework.sim_results.energy_trade_profile import EnergyTradeProfile
from gsy_framework.sim_results.market_price_energy_day import \
MarketPriceEnergyDay
from gsy_framework.sim_results.market_price_energy_day import MarketPriceEnergyDay
from gsy_framework.sim_results.market_summary_info import MarketSummaryInfo

REQUESTED_FIELDS_LIST = ["price_energy_day", "device_statistics",
"energy_trade_profile", "area_throughput", "market_summary"]
REQUESTED_FIELDS_LIST = [
"price_energy_day",
"device_statistics",
"trade_profile",
"area_throughput",
"market_summary",
]


REQUESTED_FIELDS_CLASS_MAP = {
"price_energy_day": MarketPriceEnergyDay,
"device_statistics": DeviceStatistics,
"energy_trade_profile": EnergyTradeProfile,
"trade_profile": EnergyTradeProfile,
"area_throughput": AreaThroughputStats,
"market_summary": MarketSummaryInfo
"market_summary": MarketSummaryInfo,
}


def merge_last_market_results_to_global(
market_results: Dict, global_results: Dict,
slot_list_ui_format: List = None, requested_fields: List = None
market_results: Dict,
global_results: Dict,
slot_list_ui_format: List = None,
requested_fields: List = None,
):
"""Global results are the accumulated statistics from the beginning of the simulation.
This function updates the global results using the market results which are results of
Expand Down
20 changes: 2 additions & 18 deletions gsy_framework/sim_results/all_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,6 @@ def __init__(self, should_export_plots: bool = False, is_scm: bool = False):

self._total_memory_utilization_kb = 0.0

@property
def _results_name_to_db_name_mapping(self):
mapping = {k: k for k in self.results_mapping}
mapping.update(
{
"bills": "price_energy_area_balance",
"trade_profile": "energy_trade_profile",
"area_throughput_stats": "area_throughput",
}
)
return mapping

def _update_memory_utilization(self):
start_time = time()
self._total_memory_utilization_kb = sum(
Expand Down Expand Up @@ -110,8 +98,7 @@ def restore_area_results_state(
self.results_mapping["assets_info"].restore_assets_info(assets_info)
if area_results_map.get(config_tree["uuid"], {}):
area_results = area_results_map[config_tree["uuid"]]
for k, result_object in self.results_mapping.items():
db_field_name = self._results_name_to_db_name_mapping[k]
for db_field_name, result_object in self.results_mapping.items():
if db_field_name not in area_results:
continue
result_object.restore_area_results_state(config_tree, area_results[db_field_name])
Expand All @@ -132,10 +119,7 @@ def all_ui_results(self) -> Dict:
@property
def all_db_results(self) -> Dict:
"""Get dict with all the results in format that can be saved to the DB."""
results = {
self._results_name_to_db_name_mapping[k]: v.ui_formatted_results
for k, v in self.results_mapping.items()
}
results = {k: v.ui_formatted_results for k, v in self.results_mapping.items()}
results["bids_offers_trades"] = self.bids_offers_trades
if not self._is_scm:
results["cumulative_market_fees"] = self.results_mapping[
Expand Down

0 comments on commit 8a11859

Please sign in to comment.