Skip to content
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
6 changes: 3 additions & 3 deletions floatcsep/cmd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def run(config, **kwargs):
exp.make_repr()

log.info('Finalized')
log.debug('')
log.debug(f'-------- END OF RUN --------')


def plot(config, **kwargs):
Expand All @@ -43,7 +43,7 @@ def plot(config, **kwargs):
exp.plot_forecasts()
exp.generate_report()

log.info('Finalized')
log.info('Finalized\n')
log.debug('')


Expand Down Expand Up @@ -77,7 +77,7 @@ def floatcsep():
help='Run a calculation')
parser.add_argument('config', type=str,
help='Experiment Configuration file')
parser.add_argument('-l', '--log', action='store_false', default=True,
parser.add_argument('-l', '--logging', action='store_true', default=False,
help="Don't log experiment")
parser.add_argument('-t', '--timestamp', action='store_true',
default=False, help="Timestamp results")
Expand Down
20 changes: 13 additions & 7 deletions floatcsep/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ def __init__(self,
rundir,
f'run_{datetime.datetime.utcnow().date().isoformat()}')
os.makedirs(os.path.join(workdir, rundir), exist_ok=True)
if kwargs.get(log, True):
logpath = os.path.join(workdir, rundir, 'experiment.log')
log.info(f'Logging at {logpath}')
add_fhandler(logpath)

self.name = name if name else 'floatingExp'
self.path = PathTree(workdir, rundir)
Expand All @@ -152,9 +148,17 @@ def __init__(self,
self.model_config = models if isinstance(models, str) else None
self.test_config = tests if isinstance(tests, str) else None

logger = kwargs.get('logging', True)
if logger:
filename = 'experiment.log' if logger is True else logger
self.path.logger = os.path.join(workdir, rundir, filename)
log.info(f'Logging at {self.path.logger}')
add_fhandler(self.path.logger)

log.debug(f'-------- BEGIN OF RUN --------')
log.info(f'Setting up experiment {self.name}:')
log.info(f'\tStart: {self.start_date}')
log.info(f'\tEnd: {self.start_date}')
log.info(f'\tEnd: {self.end_date}')
log.info(f'\tTime windows: {len(self.timewindows)}')
log.info(f'\tRegion: {self.region.name if self.region else None}')
log.info(f'\tMagnitude range: [{numpy.min(self.magnitudes)},'
Expand Down Expand Up @@ -957,7 +961,7 @@ def from_yml(cls, config_yml: str, reprdir=None, **kwargs):
with open(config_yml, 'r') as yml:

# experiment configuration file
_dict = yaml.safe_load(yml)
_dict = yaml.load(yml, NoAliasLoader)
_dir_yml = dirname(config_yml)
# uses yml path and append if a rel/abs path is given in config.
_path = _dict.get('path', '')
Expand All @@ -977,5 +981,7 @@ def from_yml(cls, config_yml: str, reprdir=None, **kwargs):
_dict['rundir'] = _dict.get('rundir',
kwargs.pop('rundir', 'results'))
_dict['config_file'] = relpath(config_yml, _dir_yml)
# print(_dict['rundir'])
if 'logging' in _dict:
kwargs.pop('logging')

return cls(**_dict, **kwargs)