Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSYE-842: Provide filepath to ProfilesHandler.rotate_profile in order… #1827

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/gsy_e/gsy_e_core/user_profile_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,11 @@ def _read_new_datapoints_from_buffer_or_rotate_profile(
)

def rotate_profile(
self, profile_type: InputProfileTypes, profile, profile_uuid: str = None
self,
profile_type: InputProfileTypes,
profile,
profile_uuid: str = None,
input_profile_path: str = None,
Copy link
Member

@spyrostz spyrostz Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand but why the extra parameter here? If I recall correctly, this is exactly the reason why we allow str as the type of the profile parameter, in order to be able to support file paths. Did you try setting the profile path to the profile parameter and it did not work out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a look into the StrategyProfile. If the profiles was already read once, the profile will be the profile for he first week. This will be used by the read_arbitrary_profile which will re-use it, but even worse: it will convert it again into kWh. The latter resulted in very low energy demands that are close to or lower than our Floating_point_tollerance.

I am open to better solutions here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that you can use the input_profile in the StrategyProfile class. Let me leave a possible suggestion that you can also double check if it works out.

) -> Dict[DateTime, float]:
"""Reads a new chunk of profile if the buffer does not contain the current time stamp
Profile chunks are either generated from single values, input daily profiles or profiles
Expand All @@ -491,11 +495,14 @@ def rotate_profile(
profile (any of str, dict, float): Any arbitrary input
(same input as for read_arbitrary_profile)
profile_uuid (str): optional, if set the profiles is read from the DB
input_profile_path (str), optional, for profiles provided by files

Returns: Profile chunk as dictionary

"""
if profile_uuid is None and self.should_create_profile(profile):
if input_profile_path:
profile = input_profile_path
return read_arbitrary_profile(
profile_type, profile, current_timestamp=self.current_timestamp
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from abc import ABC, abstractmethod
from typing import Optional, Dict, Union, List
from statistics import mean

from gsy_framework.constants_limits import ConstSettings, GlobalConfig, FLOATING_POINT_TOLERANCE
from gsy_framework.read_user_profile import InputProfileTypes
Expand Down Expand Up @@ -44,6 +45,7 @@ def get_results_dict(self, current_time_slot: DateTime) -> dict:
return {
"tanks": tanks_state,
**self._hp_state.get_results_dict(current_time_slot),
"storage_temp_C": mean([tank["storage_temp_C"] for tank in tanks_state]),
}
return {**self._hp_state.get_results_dict(current_time_slot), **tanks_state}

Expand Down
5 changes: 4 additions & 1 deletion src/gsy_e/models/strategy/strategy_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ def read_or_rotate_profiles(self, reconfigure=False):
profile = self.profile

Copy link
Member

@spyrostz spyrostz Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be checked whether it violates the previous if clauses, however the solution can be similar to this, so that the profile variable is overridden if we need to rotate a profile that originates from a CSV file:

Suggested change
if isinstance(self.input_profile, str):
profile = self.input_profile

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if isinstance(self.input_profile, str): will always we True for all the market slot in the simulation which will result in calling the read_arbitrary_profile inside the ProfilesHandler on every market slot, which is not what we want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grrrr, you are right, I just saw the should_create_profile. I agree with you then that it is ok to bite the bullet and deal with the extra parameter. Thanks for bearing with me!

self.profile = global_objects.profiles_handler.rotate_profile(
profile_type=self.profile_type, profile=profile, profile_uuid=self.input_profile_uuid
profile_type=self.profile_type,
profile=profile,
profile_uuid=self.input_profile_uuid,
input_profile_path=self.input_profile,
)


Expand Down
Loading