Unverified Commit cce5b6fb authored by dmitrysarov's avatar dmitrysarov Committed by GitHub
Browse files

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: default avatarLeymore <zfz-960727@163.com>
parent 701ecbb2
import fnmatch import fnmatch
import os import os
from typing import List, Union from typing import List, Tuple, Union
def match_files(path: str, def match_files(path: str,
pattern: Union[str, List], pattern: Union[str, List],
fuzzy: bool = False) -> List: fuzzy: bool = False) -> List[Tuple[str, str]]:
if isinstance(pattern, str): if isinstance(pattern, str):
pattern = [pattern] pattern = [pattern]
if fuzzy: if fuzzy:
...@@ -15,7 +15,7 @@ def match_files(path: str, ...@@ -15,7 +15,7 @@ def match_files(path: str,
for name in files: for name in files:
for p in pattern: for p in pattern:
if fnmatch.fnmatch(name.lower(), p.lower()): 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 break
return sorted(files_list, key=lambda x: x[0]) return sorted(files_list, key=lambda x: x[0])
import os import os
from typing import List, Union from typing import List, Tuple, Union
import tabulate import tabulate
from mmengine.config import Config from mmengine.config import Config
...@@ -12,7 +12,8 @@ from opencompass.tasks import OpenICLEvalTask, OpenICLInferTask ...@@ -12,7 +12,8 @@ from opencompass.tasks import OpenICLEvalTask, OpenICLInferTask
from opencompass.utils import get_logger, match_files 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. """Match the config file in workdir recursively given the pattern.
Additionally, if the pattern itself points to an existing file, it will be Additionally, if the pattern itself points to an existing file, it will be
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment