Skip to content

Commit 92bd194

Browse files
Merge branch 'master' of https://github.com/BSC-ES/providentia
2 parents 02ed58a + df239ff commit 92bd194

File tree

4 files changed

+35
-16
lines changed

4 files changed

+35
-16
lines changed

providentia/configuration.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,14 @@ def check_validity(self, deactivate_warning=False):
11161116
show_message(self.read_instance, msg, from_conf=self.read_instance.from_conf, deactivate=deactivate_warning)
11171117
self.read_instance.species = default
11181118

1119+
# chech resolution
1120+
# if not interpolation or download, get first resolution in list
1121+
if (',' in self.read_instance.resolution) and (self.read_instance.mode not in ['interpolation', 'download']):
1122+
default = self.read_instance.resolution.split(',')[0]
1123+
msg = "Resolution (resolution) contains multiple values. Using '{}' as default.".format(default)
1124+
show_message(self.read_instance, msg, from_conf=self.read_instance.from_conf, deactivate=deactivate_warning)
1125+
self.read_instance.resolution = default
1126+
11191127
# if number of networks and species is not the same,
11201128
# and len of one of network or species == 1,
11211129
# then duplicate respestive network/species

providentia/read_aux.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ def valid_date(date_text):
963963
return False
964964

965965

966-
def generate_file_trees(instance, force=False):
966+
def generate_file_trees(instance):
967967
""" Generate file trees. Force if we want to remove depedency on the machine.
968968
"""
969969

@@ -982,29 +982,45 @@ def generate_file_trees(instance, force=False):
982982
gft = True
983983

984984
# generate file trees
985-
if gft or force:
986-
instance.logger.info('Generating file trees...')
987-
instance.all_observation_data = get_ghost_observational_tree(instance)
988-
if instance.nonghost_root is not None:
989-
nonghost_observation_data = get_nonghost_observational_tree(instance)
985+
ghost_filetree_path = join(PROVIDENTIA_ROOT, 'settings/internal/ghost_filetree_{}.json'.format(instance.ghost_version))
986+
nonghost_filetree_path = join(PROVIDENTIA_ROOT, 'settings/internal/nonghost_filetree.json')
987+
988+
# generate file trees for ghost
989+
if gft or (not os.path.exists(ghost_filetree_path)):
990+
if not os.path.exists(ghost_filetree_path):
991+
instance.logger.info(f'Generating file tree {ghost_filetree_path}...')
992+
else:
993+
instance.logger.info(f'Updating file tree {ghost_filetree_path}...')
994+
instance.all_observation_data = get_ghost_observational_tree(instance)
990995
# load file trees
991996
else:
997+
instance.logger.info(f'Loading file tree {ghost_filetree_path}...')
992998
try:
993999
instance.all_observation_data = json.load(open(join(PROVIDENTIA_ROOT, 'settings/internal/ghost_filetree_{}.json'.format(instance.ghost_version))))
9941000
except FileNotFoundError as file_error:
9951001
error = "Error: Trying to load 'settings/internal/ghost_filetree_{}.json' but file does not exist. Run with the flag '--gft' to generate this file.".format(instance.ghost_version)
9961002
instance.logger.error(error)
9971003
sys.exit(1)
998-
if instance.nonghost_root is not None:
1004+
1005+
if instance.nonghost_root is not None:
1006+
# generate file trees for nonghost
1007+
if gft or (not os.path.exists(nonghost_filetree_path)):
1008+
if not os.path.exists(nonghost_filetree_path):
1009+
instance.logger.info(f'Generating file tree {nonghost_filetree_path}...')
1010+
else:
1011+
instance.logger.info(f'Updating file tree {nonghost_filetree_path}...')
1012+
nonghost_observation_data = get_nonghost_observational_tree(instance)
1013+
# load file trees
1014+
else:
1015+
instance.logger.info(f'Loading file tree {nonghost_filetree_path}...')
9991016
try:
10001017
nonghost_observation_data = json.load(open(join(PROVIDENTIA_ROOT, 'settings/internal/nonghost_filetree.json')))
10011018
except FileNotFoundError as file_error:
10021019
error = "Error: Trying to load 'settings/internal/nonghost_filetree.json' but file does not exist. Run with the flag '--gft' to generate this file."
10031020
instance.logger.error(error)
10041021
sys.exit(1)
10051022

1006-
# merge GHOST and non-GHOST filetrees
1007-
if instance.nonghost_root is not None:
1023+
# merge GHOST and non-GHOST filetrees
10081024
instance.all_observation_data = {**instance.all_observation_data, **nonghost_observation_data}
10091025

10101026

providentia/report.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,7 @@ def __init__(self, **kwargs):
149149

150150
# if first section or GHOST version has changed
151151
if (section_ind == 0) or (current_ghost_version != self.ghost_version):
152-
# if GHOST version has changed, generate file trees always (independently of the machine)
153-
if (current_ghost_version != self.ghost_version):
154-
generate_file_trees(self, force=True)
155-
# if it hasn't and we are in the first section, generate if needed
156-
else:
157-
generate_file_trees(self)
152+
generate_file_trees(self)
158153

159154
# initialise DataReader class
160155
self.datareader = DataReader(self)

providentia/toolbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def reload_conf(self, section, fpath):
396396

397397
# generate file trees if GHOST version has changed
398398
if current_ghost_version != self.read_instance.ghost_version:
399-
generate_file_trees(self.read_instance, force=True)
399+
generate_file_trees(self.read_instance)
400400

401401
# update species, experiments, qa & flags
402402
self.read_instance.config_bar_initialisation = True

0 commit comments

Comments
 (0)