Skip to content
Snippets Groups Projects
Commit c67b38e9 authored by Frisinghelli Daniel's avatar Frisinghelli Daniel
Browse files

Check for existing files.

parent a39eb46e
No related branches found
No related tags found
No related merge requests found
...@@ -46,27 +46,27 @@ if __name__ == '__main__': ...@@ -46,27 +46,27 @@ if __name__ == '__main__':
# path to model state # path to model state
state_file = MODEL_PATH.joinpath(PREDICTAND, state_file) state_file = MODEL_PATH.joinpath(PREDICTAND, state_file)
# load pretrained model # check if target dataset already exists
if state_file.exists(): target = TARGET_PATH.joinpath(PREDICTAND, state_file.name.replace(
# load pretrained network state_file.suffix, '.nc'))
net, _ = Network.load_pretrained_model(state_file, NET) if target.exists() and not OVERWRITE:
else: LogConfig.init_log('{} already exists.'.format(target))
# initialize OBS predictand dataset
LOGGER.info('{} does not exist.'.format(state_file))
sys.exit() sys.exit()
else:
# load pretrained model
if state_file.exists():
# load pretrained network
net, _ = Network.load_pretrained_model(state_file, NET)
else:
# initialize OBS predictand dataset
LOGGER.info('{} does not exist.'.format(state_file))
sys.exit()
# initialize logging # initialize logging
log_file = MODEL_PATH.joinpath(PREDICTAND, log_file = MODEL_PATH.joinpath(PREDICTAND,
state_file.name.replace('.pt', '_log.txt')) state_file.name.replace('.pt', '_log.txt'))
dictConfig(log_conf(log_file)) dictConfig(log_conf(log_file))
# check if target dataset already exists
target = TARGET_PATH.joinpath(PREDICTAND, net.state_file.name.replace(
net.state_file.suffix, '.nc'))
if target.exists() and not OVERWRITE:
LogConfig.init_log('{} already exists.'.format(target))
sys.exit()
# predict reference period # predict reference period
LogConfig.init_log('Predicting reference period: {}'.format( LogConfig.init_log('Predicting reference period: {}'.format(
' - '.join([str(VALID_PERIOD[0]), str(VALID_PERIOD[-1])]))) ' - '.join([str(VALID_PERIOD[0]), str(VALID_PERIOD[-1])])))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment