mirror of
https://github.com/open-compass/opencompass.git
synced 2025-05-30 16:03:24 +08:00
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:
parent
701ecbb292
commit
cce5b6fbb6
@ -1,11 +1,11 @@
|
|||||||
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,
|
|||||||
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])
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
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
|
|||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user