@@ -135,10 +135,6 @@ def __init__(self,
135
135
rundir ,
136
136
f'run_{ datetime .datetime .utcnow ().date ().isoformat ()} ' )
137
137
os .makedirs (os .path .join (workdir , rundir ), exist_ok = True )
138
- if kwargs .get (log , True ):
139
- logpath = os .path .join (workdir , rundir , 'experiment.log' )
140
- log .info (f'Logging at { logpath } ' )
141
- add_fhandler (logpath )
142
138
143
139
self .name = name if name else 'floatingExp'
144
140
self .path = PathTree (workdir , rundir )
@@ -152,9 +148,17 @@ def __init__(self,
152
148
self .model_config = models if isinstance (models , str ) else None
153
149
self .test_config = tests if isinstance (tests , str ) else None
154
150
151
+ logger = kwargs .get ('logging' , True )
152
+ if logger :
153
+ filename = 'experiment.log' if logger is True else logger
154
+ self .path .logger = os .path .join (workdir , rundir , filename )
155
+ log .info (f'Logging at { self .path .logger } ' )
156
+ add_fhandler (self .path .logger )
157
+
158
+ log .debug (f'-------- BEGIN OF RUN --------' )
155
159
log .info (f'Setting up experiment { self .name } :' )
156
160
log .info (f'\t Start: { self .start_date } ' )
157
- log .info (f'\t End: { self .start_date } ' )
161
+ log .info (f'\t End: { self .end_date } ' )
158
162
log .info (f'\t Time windows: { len (self .timewindows )} ' )
159
163
log .info (f'\t Region: { self .region .name if self .region else None } ' )
160
164
log .info (f'\t Magnitude range: [{ numpy .min (self .magnitudes )} ,'
@@ -957,7 +961,7 @@ def from_yml(cls, config_yml: str, reprdir=None, **kwargs):
957
961
with open (config_yml , 'r' ) as yml :
958
962
959
963
# experiment configuration file
960
- _dict = yaml .safe_load (yml )
964
+ _dict = yaml .load (yml , NoAliasLoader )
961
965
_dir_yml = dirname (config_yml )
962
966
# uses yml path and append if a rel/abs path is given in config.
963
967
_path = _dict .get ('path' , '' )
@@ -977,5 +981,7 @@ def from_yml(cls, config_yml: str, reprdir=None, **kwargs):
977
981
_dict ['rundir' ] = _dict .get ('rundir' ,
978
982
kwargs .pop ('rundir' , 'results' ))
979
983
_dict ['config_file' ] = relpath (config_yml , _dir_yml )
980
- # print(_dict['rundir'])
984
+ if 'logging' in _dict :
985
+ kwargs .pop ('logging' )
986
+
981
987
return cls (** _dict , ** kwargs )
0 commit comments