Skip to content

Commit a48de0f

Browse files
committed
Assert the path contract against both answers the Hub parser can give
The typed-prefix bug Codex found needed huggingface_hub 1.25.1 to show itself. A job installs one version, so the existing cells only ever exercised whichever answer the runner resolved, and on 0.36.2 the gated branch is dead code: the broken commit went green locally and would have gone red on CI. These cells decide whether a string reaches the network at all, which is too important to leave dependent on what pip picked. Forcing both answers costs nothing and removes that dependence. Falsified the useful way: reverting the fix now fails test_a_path_stays_a_path_on_either_huggingface_hub[True-three-segment-path] on the installed 0.36.2, where the original three-segment-path cell still passes. So the regression is catchable without waiting for a runner that happens to resolve 1.x. Behavioral gate 618 passed, 2 skipped, under the installed answer and under the capability forced True.
1 parent 36a4414 commit a48de0f

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tests/test_local_base_model_resolution_offline.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,28 @@ def test_local_path_is_absent_not_unreachable(monkeypatch, model_name):
143143
assert saving_utils.check_hf_model_exists(model_name) is False
144144

145145

146+
@pytest.mark.parametrize("model_name", _NOT_REPO_IDS)
147+
@pytest.mark.parametrize("typed_uris", [False, True])
148+
def test_a_path_stays_a_path_on_either_huggingface_hub(monkeypatch, model_name, typed_uris):
149+
"""The same contract, asserted against both answers the Hub parser can give.
150+
151+
These cells decide whether a string reaches the network at all, and one of the
152+
inputs (`models/base/checkpoint-500`) is classified by logic that is gated on
153+
whether the installed release maps the `models/` type prefix. A job only ever
154+
installs one version, so running under whichever one that is leaves the other
155+
branch untested: the version-gated strip landed green here and still broke this
156+
file on 1.25.1, which Codex found by running it there.
157+
158+
Forcing both answers is cheap and removes the dependence on what the runner
159+
resolved, which is the whole failure mode this branch is about.
160+
"""
161+
monkeypatch.setattr(
162+
saving_utils, "_hub_addresses_typed_model_uris", lambda: typed_uris,
163+
)
164+
_forbid_hub(monkeypatch)
165+
assert saving_utils.check_hf_model_exists(model_name) is False
166+
167+
146168
def test_valid_repo_id_is_still_probed(monkeypatch):
147169
"""The gate must not quietly stop checking the Hub for real repo ids.
148170

0 commit comments

Comments
 (0)