From 122558e12569a25cb1c8dfb8fe108290b08cdf88 Mon Sep 17 00:00:00 2001 From: Roman Solomatin <36135455+Samoed@users.noreply.github.com> Date: Tue, 30 Dec 2025 12:38:40 +0500 Subject: [PATCH 1/2] fix repo exists check --- mteb/models/model_meta.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/mteb/models/model_meta.py b/mteb/models/model_meta.py index 96ae834cbc..91e5939126 100644 --- a/mteb/models/model_meta.py +++ b/mteb/models/model_meta.py @@ -22,6 +22,7 @@ from huggingface_hub.errors import ( EntryNotFoundError, GatedRepoError, + HFValidationError, NotASafetensorsRepoError, RepositoryNotFoundError, SafetensorsParsingError, @@ -305,7 +306,7 @@ def _from_hub( embedding_dim = None max_tokens = None - if model_name and compute_metadata and repo_exists(model_name): + if model_name and compute_metadata and _repo_exists(model_name): reference = "https://huggingface.co/" + model_name card = ModelCard.load(model_name) card_data: ModelCardData = card.data @@ -414,7 +415,7 @@ def from_hub( meta.framework.append("Sentence Transformers") meta.modalities = ["text"] - if model and compute_metadata and repo_exists(model): + if model and compute_metadata and _repo_exists(model): # have max_seq_length field sbert_config = _get_json_from_hub( model, "sentence_bert_config.json", "model", revision=revision @@ -785,3 +786,19 @@ def _get_file_on_hub( except (GatedRepoError, RepositoryNotFoundError, EntryNotFoundError) as e: logger.warning(f"Can't get file {file_name} of {repo_id}: {e}") return None + + +def _repo_exists(repo_id: str, repo_type: str | None = None) -> bool: + """Checks if a repository exists on HuggingFace Hub. + + Repo exists will raise HFValidationError for invalid local paths + + Args: + repo_id: The repository ID. + repo_type: The type of repository (e.g., "model", "dataset", "space"). + """ + try: + return repo_exists(repo_id=repo_id, repo_type=repo_type) + except HFValidationError as e: + logger.warning(f"Can't check existence of {repo_id}: {e}") + return False From d718de1978ada17967d200c68d06715eea0e6685 Mon Sep 17 00:00:00 2001 From: Roman Solomatin <36135455+Samoed@users.noreply.github.com> Date: Tue, 30 Dec 2025 15:36:41 +0500 Subject: [PATCH 2/2] add test --- tests/test_models/test_model_meta.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_models/test_model_meta.py b/tests/test_models/test_model_meta.py index 320ee801f1..5547b416e7 100644 --- a/tests/test_models/test_model_meta.py +++ b/tests/test_models/test_model_meta.py @@ -171,3 +171,9 @@ def test_model_to_python(): contacts=None, )""" ) + + +def test_model_meta_local_path(): + meta = ModelMeta.from_hub("/path/to/local/model") + assert meta.name == "/path/to/local/model" + assert meta.revision == "no_revision_available"