-
Notifications
You must be signed in to change notification settings - Fork 8
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
WIP : output_management #54
base: master
Are you sure you want to change the base?
Conversation
src/walter/output_manager.py
Outdated
# Ne marche que si : | ||
# Le log_mere contient toutes les variables a transmettre, dont les dictionnaires et leurs indices. | ||
for var in self.df: | ||
var.append(kwargs[var]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.df[var].append(kwargs.get(var, default_value))
src/walter/output_manager.py
Outdated
|
||
def log(self, **kwds): | ||
"""log each logger """ | ||
if self.loggers is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you dispatch the log to the different loggers?
src/walter/output_manager.py
Outdated
def log_Apex_Sirius(Apex_Sirius_dico_df, day, current_temperature, _Tempcum, duree_du_jour, latitude, DOY, StA): | ||
apex = Apex_Sirius_dico_df | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def log_Apex_Sirius(...):
logger = get_global_logger()
logger.log(name='ApexSirius',
Elapsed_time=day,
Temperature=current_temperature, ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_LOGGER = None
def get_global_logger():
if _LOGGER is None:
global _LOGGER
_LOGGER = Logger()
return _LOGGER
isolate the output management in a external module in several steps.
"The output management means saving the simulation outputs at each stage of the simulation including global variables and simulation status"
gather the logs ( or trace of execution) just before the produce to extract them from if and else in order to simplify better. This will be done in a separate branch and test to be merge in master rapidly
make a first move of everything concerning the outputs management in an external file output_manager (copy-paste only). test this branch with global test.
Think of new design patterns to resume the outputs management like same name of attributs (1) or a ordered dict which does the changes for keys and values.
make loger converge to take as input only module data objects (Bud, ...). To do so, create a Logger class that can be called within walter.lpy to save values of updated global variables (DOY, Temperature,GAI ...) and then used by log member function dedicated to log the different modules only with module as arg.
see whether output names could match instance member names to simplify output log functions. Meantime add a {output_name: member_name} mapping to modules to automate the job of the log functions
(1) exemple = Temp_cum -> tempcum (not the same)
see whether the maping is really required or if alternatively all (instead of user defined for almost all) instance variable should be loged, to increase robustness of log function