diff --git a/opencompass/utils/file.py b/opencompass/utils/file.py index 2371f5c1..f64c0997 100644 --- a/opencompass/utils/file.py +++ b/opencompass/utils/file.py @@ -1,11 +1,11 @@ import fnmatch import os -from typing import List, Union +from typing import List, Tuple, Union def match_files(path: str, pattern: Union[str, List], - fuzzy: bool = False) -> List: + fuzzy: bool = False) -> List[Tuple[str, str]]: if isinstance(pattern, str): pattern = [pattern] if fuzzy: @@ -15,7 +15,7 @@ def match_files(path: str, for name in files: for p in pattern: if fnmatch.fnmatch(name.lower(), p.lower()): - files_list.append([name[:-3], os.path.join(root, name)]) + files_list.append((name[:-3], os.path.join(root, name))) break return sorted(files_list, key=lambda x: x[0]) diff --git a/opencompass/utils/run.py b/opencompass/utils/run.py index 3e64526f..a66ea71d 100644 --- a/opencompass/utils/run.py +++ b/opencompass/utils/run.py @@ -1,5 +1,5 @@ import os -from typing import List, Union +from typing import List, Tuple, Union import tabulate from mmengine.config import Config @@ -12,7 +12,8 @@ from opencompass.tasks import OpenICLEvalTask, OpenICLInferTask from opencompass.utils import get_logger, match_files -def match_cfg_file(workdir: str, pattern: Union[str, List[str]]) -> List[str]: +def match_cfg_file(workdir: str, + pattern: Union[str, List[str]]) -> List[Tuple[str, str]]: """Match the config file in workdir recursively given the pattern. Additionally, if the pattern itself points to an existing file, it will be