From cce5b6fbb62156c962376a3580c720a948fb054c Mon Sep 17 00:00:00 2001 From: dmitrysarov Date: Fri, 26 Apr 2024 17:07:34 +0200 Subject: [PATCH] fix output typing, change mutable list to immutable tuple (#989) * fix output typing, change mutable list to immutable tuple * import missed type * format --------- Co-authored-by: Leymore --- opencompass/utils/file.py | 6 +++--- opencompass/utils/run.py | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) 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