Skip to content

Commit

Permalink
Added update/remove json-file opening and collation
Browse files Browse the repository at this point in the history
  • Loading branch information
dwest77a committed Jan 30, 2024
1 parent b383ba8 commit 9f71cdd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pipeline/compute/serial_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ def correct_metadata(self, allzattrs):
new_zattrs[key] = zattrs[key]

self.logger.debug('Finished metadata corrections')
if not zattrs:
if not new_zattrs:
self.logger.error('Lost zattrs at correction phase')
raise ValueError
return zattrs
return new_zattrs

def clean_attr_array(self, allzattrs):
# Collect attributes from all files,
Expand Down
15 changes: 15 additions & 0 deletions pipeline/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ def make_dirs(args, logger):
ds_values = datasets[proj_code]
pattern = ds_values[0]

if len(ds_values) > 1:
updates = ds_values[1]
if len(ds_values) > 2:
removals = ds_values[2]

logger.info(f'Creating directories/filelists for {index+1}/{len(proj_codes)}')

cfg_values[params[0]] = proj_code
Expand All @@ -172,6 +177,16 @@ def make_dirs(args, logger):
logger.warning(f'Project code {index}:{proj_code} from {args.groupID} does not have correct number of fields.')
logger.warning(f'Fields specified must be {params}, not {ds_values}')

if os.path.isfile(updates):
with open(updates) as f:
upds = json.load(f)
cfg_values['update'] = upds

if os.path.isfile(removals):
with open(removals) as f:
rems = json.load(f)
cfg_values['remove'] = rems

if 'latest' in pattern:
pattern = pattern.replace('latest', os.readlink(pattern))

Expand Down

0 comments on commit 9f71cdd

Please sign in to comment.