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 <zfz-960727@163.com>
This commit is contained in:
dmitrysarov 2024-04-26 17:07:34 +02:00 committed by GitHub
parent 701ecbb292
commit cce5b6fbb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View File

@ -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])

View File

@ -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