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__':
# path to model state
state_file = MODEL_PATH.joinpath(PREDICTAND, state_file)
# 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))
# check if target dataset already exists
target = TARGET_PATH.joinpath(PREDICTAND, state_file.name.replace(
state_file.suffix, '.nc'))
if target.exists() and not OVERWRITE:
LogConfig.init_log('{} already exists.'.format(target))
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
log_file = MODEL_PATH.joinpath(PREDICTAND,
state_file.name.replace('.pt', '_log.txt'))
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
LogConfig.init_log('Predicting reference period: {}'.format(
' - '.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