fix: index_root searching

close #1147
This commit is contained in:
源文雨
2023-09-01 14:11:55 +08:00
parent d634c2727e
commit 8ffdcb0128
21 changed files with 59 additions and 76 deletions

View File

@@ -2,33 +2,20 @@ import os
from fairseq import checkpoint_utils
### don't modify the code before you test it
# def get_index_path_from_model(sid):
# return next(
# (
# f
# for f in [
# os.path.join(root, name)
# for root, dirs, files in os.walk(os.getenv("index_root"), topdown=False)
# for name in files
# if name.endswith(".index") and "trained" not in name
# ]
# if sid.split(".")[0] in f
# ),
# "",
# )
def get_index_path_from_model(sid):
sel_index_path = ""
name = os.path.join("logs", sid.split(".")[0], "")
# print(name)
for f in index_paths:
if name in f:
# print("selected index path:", f)
sel_index_path = f
break
return sel_index_path
return next(
(
f
for f in [
os.path.join(root, name)
for root, _, files in os.walk(os.getenv("index_root"), topdown=False)
for name in files
if name.endswith(".index") and "trained" not in name
]
if sid.split(".")[0] in f
),
"",
)
def load_hubert(config):