From b9c53829a0b5eee16bbfc8c17fdd726b6dc9285d Mon Sep 17 00:00:00 2001 From: Christopher Rhodes <christopher.rhodes@embl.de> Date: Wed, 11 Dec 2024 17:10:05 +0100 Subject: [PATCH] Improperly merged batch runner changes before --- model_server/clients/batch_runner.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/model_server/clients/batch_runner.py b/model_server/clients/batch_runner.py index e9c0fd54..fe225b8d 100644 --- a/model_server/clients/batch_runner.py +++ b/model_server/clients/batch_runner.py @@ -1,6 +1,7 @@ from collections import OrderedDict import json from pathlib import Path +import re import shutil import pandas as pd @@ -156,11 +157,17 @@ class FileBatchRunnerClient(HttpClient): files += [f'{subdir}/{f}' for f in matches] def _get_file_info(filename): - return { + info = { 'remote_path': (where_remote / filename).as_posix(), 'local_path': where_local / filename, 'is_multiposition': is_multiposition, } + 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) + return info paths = paths + [_get_file_info(f) for f in files] if max_count is not None: df = pd.DataFrame(paths).head(min(max_count, len(paths))) @@ -283,4 +290,7 @@ class WatchPathVerificationError(Error): pass class TasksRemainingError(Error): + pass + +class InvalidStackCoordinateKeyError(Error): pass \ No newline at end of file -- GitLab