[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
e290ebd0ac
commit
222a416480
1 changed files with 12 additions and 12 deletions
|
|
@ -74,8 +74,8 @@ def test_resolve_hub_repo_cached_file_finds_tokenizer_model(tmp_path, monkeypatc
|
|||
got = L._resolve_hub_repo_cached_file(
|
||||
_REPO,
|
||||
"tokenizer.model",
|
||||
local_files_only=True,
|
||||
cache_dir=str(tmp_path),
|
||||
local_files_only = True,
|
||||
cache_dir = str(tmp_path),
|
||||
)
|
||||
assert got == str(snap / "tokenizer.model")
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ def test_resolve_hub_repo_local_dir_from_cached_snapshot(tmp_path, monkeypatch):
|
|||
snap = _write_gemma4_cache(tmp_path)
|
||||
_offline_env(monkeypatch, tmp_path)
|
||||
|
||||
got = L._resolve_hub_repo_local_dir(_REPO, local_files_only=True, cache_dir=str(tmp_path))
|
||||
got = L._resolve_hub_repo_local_dir(_REPO, local_files_only = True, cache_dir = str(tmp_path))
|
||||
assert got == str(snap)
|
||||
|
||||
|
||||
|
|
@ -92,18 +92,18 @@ def test_hub_repo_or_local_path_prefers_snapshot_over_repo_id(tmp_path, monkeypa
|
|||
snap = _write_gemma4_cache(tmp_path)
|
||||
_offline_env(monkeypatch, tmp_path)
|
||||
|
||||
got = L._hub_repo_or_local_path(_REPO, local_files_only=True, cache_dir=str(tmp_path))
|
||||
got = L._hub_repo_or_local_path(_REPO, local_files_only = True, cache_dir = str(tmp_path))
|
||||
assert got == str(snap)
|
||||
assert got != _REPO
|
||||
|
||||
|
||||
def test_hub_repo_or_local_path_keeps_repo_id_online(tmp_path, monkeypatch):
|
||||
snap = _write_gemma4_cache(tmp_path)
|
||||
monkeypatch.delenv("HF_HUB_OFFLINE", raising=False)
|
||||
monkeypatch.delenv("TRANSFORMERS_OFFLINE", raising=False)
|
||||
monkeypatch.delenv("HF_HUB_OFFLINE", raising = False)
|
||||
monkeypatch.delenv("TRANSFORMERS_OFFLINE", raising = False)
|
||||
monkeypatch.setenv("HF_HUB_CACHE", str(tmp_path))
|
||||
|
||||
got = L._hub_repo_or_local_path(_REPO, local_files_only=False, cache_dir=str(tmp_path))
|
||||
got = L._hub_repo_or_local_path(_REPO, local_files_only = False, cache_dir = str(tmp_path))
|
||||
assert got == _REPO
|
||||
assert got != str(snap)
|
||||
|
||||
|
|
@ -115,12 +115,12 @@ def test_has_tokenizer_model_offline_does_not_cache_negative(tmp_path, monkeypat
|
|||
_offline_env(monkeypatch, tmp_path)
|
||||
_TOKENIZER_MODEL_CACHE.clear()
|
||||
|
||||
tok = SimpleNamespace(name_or_path=_REPO)
|
||||
assert _has_tokenizer_model(tok, token=None) is False
|
||||
tok = SimpleNamespace(name_or_path = _REPO)
|
||||
assert _has_tokenizer_model(tok, token = None) is False
|
||||
assert _REPO not in _TOKENIZER_MODEL_CACHE
|
||||
|
||||
(snap / "tokenizer.model").write_bytes(b"sp-model")
|
||||
assert _has_tokenizer_model(tok, token=None) is True
|
||||
assert _has_tokenizer_model(tok, token = None) is True
|
||||
|
||||
|
||||
def test_preserve_sentencepiece_offline_copies_cached_model(tmp_path, monkeypatch):
|
||||
|
|
@ -133,8 +133,8 @@ def test_preserve_sentencepiece_offline_copies_cached_model(tmp_path, monkeypatc
|
|||
|
||||
save_dir = tmp_path / "export"
|
||||
save_dir.mkdir()
|
||||
(save_dir / "tokenizer_config.json").write_text("{}", encoding="utf-8")
|
||||
tok = SimpleNamespace(name_or_path=_REPO)
|
||||
(save_dir / "tokenizer_config.json").write_text("{}", encoding = "utf-8")
|
||||
tok = SimpleNamespace(name_or_path = _REPO)
|
||||
|
||||
_preserve_sentencepiece_tokenizer_assets(tok, str(save_dir))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue