mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2025-08-04 04:32:50 +08:00
add check
Former-commit-id: 62294289dc6f594f37c5c6b73585c2403248cc55
This commit is contained in:
parent
43d1730aa5
commit
64f96cfd6d
@ -28,14 +28,13 @@ def can_preview(dataset_dir: str, dataset: list) -> "gr.Button":
|
||||
dataset_info = json.load(f)
|
||||
except Exception:
|
||||
return gr.Button(interactive=False)
|
||||
|
||||
|
||||
if len(dataset) == 0 or "file_name" not in dataset_info[dataset[0]]:
|
||||
return gr.Button(interactive=False)
|
||||
|
||||
local_path = os.path.join(dataset_dir, dataset_info[dataset[0]]["file_name"])
|
||||
if (
|
||||
len(dataset) > 0
|
||||
and "file_name" in dataset_info[dataset[0]]
|
||||
and (os.path.isfile(local_path)
|
||||
or (os.path.isdir(local_path)) and len(os.listdir(local_path)) != 0)
|
||||
):
|
||||
if (os.path.isfile(local_path)
|
||||
or (os.path.isdir(local_path) and len(os.listdir(local_path)) != 0)):
|
||||
return gr.Button(interactive=True)
|
||||
else:
|
||||
return gr.Button(interactive=False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user