fix: recognize root Hugging Face repo IDs (#325)
Some checks failed
CI / Check and build (Python 3.10) (push) Has been cancelled
CI / Check and build (Python 3.11) (push) Has been cancelled
CI / Check and build (Python 3.12) (push) Has been cancelled
CI / Check and build (Python 3.13) (push) Has been cancelled

* fix: recognize root Hugging Face repo IDs

* fix: propagate invalid HF repo ids

* fix: match transformers local path precedence
This commit is contained in:
iuyua9 2026-05-16 11:49:15 +08:00 committed by GitHub
parent 8b5b85bec9
commit 551db26bb7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,6 +22,7 @@ from datasets import DatasetDict, ReadInstruction, load_dataset, load_from_disk
from datasets.config import DATASET_STATE_JSON_FILENAME
from datasets.download.download_manager import DownloadMode
from datasets.utils.info_utils import VerificationMode
from huggingface_hub.utils import validate_repo_id
from optuna import Trial
from psutil import Process
from questionary import Choice, Style
@ -172,13 +173,13 @@ def format_duration(seconds: float) -> str:
def is_hf_path(path: str) -> bool:
"""Checks whether a path likely refers to a Hugging Face repository."""
return (
not path.startswith("/")
and not path.endswith("/")
and path.count("/") == 1
and "\\" not in path
and not Path(path).exists()
)
# Match Transformers: existing local paths take precedence over Hub lookup,
# even if the path string is also a valid repository ID.
if Path(path).exists():
return False
validate_repo_id(path)
return True
@dataclass