[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
3ce5cefc5e
commit
cd14cae19d
2 changed files with 99 additions and 80 deletions
|
|
@ -98,17 +98,20 @@ def test_already_in_target_state_uses_gguf_path_when_present(tmp_path):
|
||||||
_hf_variant = "Q4_K_M",
|
_hf_variant = "Q4_K_M",
|
||||||
_gguf_path = str(gguf_file),
|
_gguf_path = str(gguf_file),
|
||||||
)
|
)
|
||||||
assert backend._already_in_target_state(
|
assert (
|
||||||
gguf_path = str(gguf_file),
|
backend._already_in_target_state(
|
||||||
model_identifier = "owner/repo",
|
gguf_path = str(gguf_file),
|
||||||
hf_variant = None,
|
model_identifier = "owner/repo",
|
||||||
n_ctx = 8192,
|
hf_variant = None,
|
||||||
cache_type_kv = None,
|
n_ctx = 8192,
|
||||||
speculative_type = None,
|
cache_type_kv = None,
|
||||||
chat_template_override = None,
|
speculative_type = None,
|
||||||
extra_args = None,
|
chat_template_override = None,
|
||||||
is_vision = False,
|
extra_args = None,
|
||||||
) is True
|
is_vision = False,
|
||||||
|
)
|
||||||
|
is True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_already_in_target_state_rejects_different_gguf_path(tmp_path):
|
def test_already_in_target_state_rejects_different_gguf_path(tmp_path):
|
||||||
|
|
@ -117,17 +120,20 @@ def test_already_in_target_state_rejects_different_gguf_path(tmp_path):
|
||||||
b = tmp_path / "b.gguf"
|
b = tmp_path / "b.gguf"
|
||||||
b.write_bytes(b"")
|
b.write_bytes(b"")
|
||||||
backend = _loaded_backend(_gguf_path = str(a))
|
backend = _loaded_backend(_gguf_path = str(a))
|
||||||
assert backend._already_in_target_state(
|
assert (
|
||||||
gguf_path = str(b),
|
backend._already_in_target_state(
|
||||||
model_identifier = "owner/repo",
|
gguf_path = str(b),
|
||||||
hf_variant = None,
|
model_identifier = "owner/repo",
|
||||||
n_ctx = 8192,
|
hf_variant = None,
|
||||||
cache_type_kv = None,
|
n_ctx = 8192,
|
||||||
speculative_type = None,
|
cache_type_kv = None,
|
||||||
chat_template_override = None,
|
speculative_type = None,
|
||||||
extra_args = None,
|
chat_template_override = None,
|
||||||
is_vision = False,
|
extra_args = None,
|
||||||
) is False
|
is_vision = False,
|
||||||
|
)
|
||||||
|
is False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# ── HF mode falls back to hf_variant comparison ──────────────────────
|
# ── HF mode falls back to hf_variant comparison ──────────────────────
|
||||||
|
|
@ -135,32 +141,38 @@ def test_already_in_target_state_rejects_different_gguf_path(tmp_path):
|
||||||
|
|
||||||
def test_already_in_target_state_falls_back_to_hf_variant_for_hf_loads():
|
def test_already_in_target_state_falls_back_to_hf_variant_for_hf_loads():
|
||||||
backend = _loaded_backend(_hf_variant = "Q4_K_M", _gguf_path = None)
|
backend = _loaded_backend(_hf_variant = "Q4_K_M", _gguf_path = None)
|
||||||
assert backend._already_in_target_state(
|
assert (
|
||||||
gguf_path = None,
|
backend._already_in_target_state(
|
||||||
model_identifier = "owner/repo",
|
gguf_path = None,
|
||||||
hf_variant = "Q8_0",
|
model_identifier = "owner/repo",
|
||||||
n_ctx = 8192,
|
hf_variant = "Q8_0",
|
||||||
cache_type_kv = None,
|
n_ctx = 8192,
|
||||||
speculative_type = None,
|
cache_type_kv = None,
|
||||||
chat_template_override = None,
|
speculative_type = None,
|
||||||
extra_args = None,
|
chat_template_override = None,
|
||||||
is_vision = False,
|
extra_args = None,
|
||||||
) is False
|
is_vision = False,
|
||||||
|
)
|
||||||
|
is False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_already_in_target_state_hf_same_variant_matches():
|
def test_already_in_target_state_hf_same_variant_matches():
|
||||||
backend = _loaded_backend(_hf_variant = "Q4_K_M", _gguf_path = None)
|
backend = _loaded_backend(_hf_variant = "Q4_K_M", _gguf_path = None)
|
||||||
assert backend._already_in_target_state(
|
assert (
|
||||||
gguf_path = None,
|
backend._already_in_target_state(
|
||||||
model_identifier = "owner/repo",
|
gguf_path = None,
|
||||||
hf_variant = "Q4_K_M",
|
model_identifier = "owner/repo",
|
||||||
n_ctx = 8192,
|
hf_variant = "Q4_K_M",
|
||||||
cache_type_kv = None,
|
n_ctx = 8192,
|
||||||
speculative_type = None,
|
cache_type_kv = None,
|
||||||
chat_template_override = None,
|
speculative_type = None,
|
||||||
extra_args = None,
|
chat_template_override = None,
|
||||||
is_vision = False,
|
extra_args = None,
|
||||||
) is True
|
is_vision = False,
|
||||||
|
)
|
||||||
|
is True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# ── extra_args: None inherits, [] forces reload, list enforces ───────
|
# ── extra_args: None inherits, [] forces reload, list enforces ───────
|
||||||
|
|
@ -168,47 +180,56 @@ def test_already_in_target_state_hf_same_variant_matches():
|
||||||
|
|
||||||
def test_already_in_target_state_none_extras_inherits_stored():
|
def test_already_in_target_state_none_extras_inherits_stored():
|
||||||
backend = _loaded_backend(_extra_args = ["--top-k", "20"])
|
backend = _loaded_backend(_extra_args = ["--top-k", "20"])
|
||||||
assert backend._already_in_target_state(
|
assert (
|
||||||
gguf_path = None,
|
backend._already_in_target_state(
|
||||||
model_identifier = "owner/repo",
|
gguf_path = None,
|
||||||
hf_variant = "Q4_K_M",
|
model_identifier = "owner/repo",
|
||||||
n_ctx = 8192,
|
hf_variant = "Q4_K_M",
|
||||||
cache_type_kv = None,
|
n_ctx = 8192,
|
||||||
speculative_type = None,
|
cache_type_kv = None,
|
||||||
chat_template_override = None,
|
speculative_type = None,
|
||||||
extra_args = None,
|
chat_template_override = None,
|
||||||
is_vision = False,
|
extra_args = None,
|
||||||
) is True
|
is_vision = False,
|
||||||
|
)
|
||||||
|
is True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_already_in_target_state_empty_extras_forces_reload_when_stored():
|
def test_already_in_target_state_empty_extras_forces_reload_when_stored():
|
||||||
backend = _loaded_backend(_extra_args = ["--top-k", "20"])
|
backend = _loaded_backend(_extra_args = ["--top-k", "20"])
|
||||||
assert backend._already_in_target_state(
|
assert (
|
||||||
gguf_path = None,
|
backend._already_in_target_state(
|
||||||
model_identifier = "owner/repo",
|
gguf_path = None,
|
||||||
hf_variant = "Q4_K_M",
|
model_identifier = "owner/repo",
|
||||||
n_ctx = 8192,
|
hf_variant = "Q4_K_M",
|
||||||
cache_type_kv = None,
|
n_ctx = 8192,
|
||||||
speculative_type = None,
|
cache_type_kv = None,
|
||||||
chat_template_override = None,
|
speculative_type = None,
|
||||||
extra_args = [],
|
chat_template_override = None,
|
||||||
is_vision = False,
|
extra_args = [],
|
||||||
) is False
|
is_vision = False,
|
||||||
|
)
|
||||||
|
is False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_already_in_target_state_explicit_extras_match():
|
def test_already_in_target_state_explicit_extras_match():
|
||||||
backend = _loaded_backend(_extra_args = ["--top-k", "20"])
|
backend = _loaded_backend(_extra_args = ["--top-k", "20"])
|
||||||
assert backend._already_in_target_state(
|
assert (
|
||||||
gguf_path = None,
|
backend._already_in_target_state(
|
||||||
model_identifier = "owner/repo",
|
gguf_path = None,
|
||||||
hf_variant = "Q4_K_M",
|
model_identifier = "owner/repo",
|
||||||
n_ctx = 8192,
|
hf_variant = "Q4_K_M",
|
||||||
cache_type_kv = None,
|
n_ctx = 8192,
|
||||||
speculative_type = None,
|
cache_type_kv = None,
|
||||||
chat_template_override = None,
|
speculative_type = None,
|
||||||
extra_args = ["--top-k", "20"],
|
chat_template_override = None,
|
||||||
is_vision = False,
|
extra_args = ["--top-k", "20"],
|
||||||
) is True
|
is_vision = False,
|
||||||
|
)
|
||||||
|
is True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_extra_args_source_default_is_none():
|
def test_extra_args_source_default_is_none():
|
||||||
|
|
|
||||||
|
|
@ -274,9 +274,7 @@ def test_strip_shadowing_flags_boolean_does_not_consume_next_token():
|
||||||
|
|
||||||
|
|
||||||
def test_strip_shadowing_flags_jinja_boolean_preserves_positional():
|
def test_strip_shadowing_flags_jinja_boolean_preserves_positional():
|
||||||
out = strip_shadowing_flags(
|
out = strip_shadowing_flags(["--jinja", "trailing-positional"], strip_template = True)
|
||||||
["--jinja", "trailing-positional"], strip_template = True
|
|
||||||
)
|
|
||||||
assert out == ["trailing-positional"]
|
assert out == ["trailing-positional"]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue