Skip to content
Snippets Groups Projects
Commit 3d9bd7fa authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Batch runner allows pattern matching of subdirectories

parent 2e1e0a2e
No related branches found
No related tags found
2 merge requests!4Migrate project from rhodes/model_server to grp-almf/svlt,!3Migrate from rhodes/model_server to grp-almf/svlt repo
......@@ -144,7 +144,6 @@ class FileBatchRunnerClient(HttpClient):
matching_files.append(f.name)
return matching_files
files += _append_files_by_pattern(where_local, inp.get('pattern'))
is_multiposition = inp.get('multiposition', False)
where_remote = Path(self.remote_paths['input']) / inp['directory']
......@@ -153,20 +152,27 @@ class FileBatchRunnerClient(HttpClient):
for subdir in where_local.iterdir():
if not subdir.is_dir():
continue
if (sdp := inp.get('subdirectory_pattern')) is not None:
if sdp.upper() not in subdir.name.upper():
continue
matches = _append_files_by_pattern(subdir, inp.get('pattern'))
files += [f'{subdir}/{f}' for f in matches]
else:
files += _append_files_by_pattern(where_local, inp.get('pattern'))
def _get_file_info(filename):
def _get_file_info(fpath_str):
info = {
'remote_path': (where_remote / filename).as_posix(),
'local_path': where_local / filename,
'remote_path': (where_remote / fpath_str).as_posix(),
'local_path': where_local / fpath_str,
'is_multiposition': is_multiposition,
}
filename = Path(fpath_str).name
if (coord_regex := inp.get('coord_regex')) is not None:
for coord_k, coord_v in re.search(coord_regex, filename).groupdict().items():
if coord_k.lower() not in ['well', 'position', 'time']:
raise InvalidStackCoordinateKeyError(f'Cannot interpret coordinate {coord_k}')
info[f'coord_{coord_k.lower()}'] = int(coord_v)
if coord_k.lower() in ['well', 'position', 'time', 'date']:
info[f'coord_{coord_k.lower()}'] = int(coord_v)
else:
info[f'coord_{coord_k.lower()}'] = coord_v
return info
paths = paths + [_get_file_info(f) for f in files]
if max_count is not None:
......
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