mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-11 19:56:03 +00:00
add comments to explain some ignores
This commit is contained in:
parent
69fb43b7ee
commit
d112e6347f
2 changed files with 8 additions and 0 deletions
|
|
@ -358,6 +358,10 @@ class HFFinetuningSingleDevice:
|
|||
if peft_config:
|
||||
logger.info("Merging LoRA weights with base model")
|
||||
# TRL's merge_and_unload returns a HuggingFace model
|
||||
# Both cast() and type: ignore are needed here:
|
||||
# - cast() tells mypy the return type is HFAutoModel for downstream code
|
||||
# - type: ignore suppresses errors on the merge_and_unload() call itself,
|
||||
# which mypy can't type-check due to TRL library's incomplete type stubs
|
||||
model_obj = cast(HFAutoModel, trainer.model.merge_and_unload()) # type: ignore[union-attr,operator]
|
||||
else:
|
||||
# trainer.model is the trained HuggingFace model
|
||||
|
|
|
|||
|
|
@ -599,6 +599,10 @@ def _combine_model_list_responses(endpoint: str, records: list[dict[str, Any]])
|
|||
if endpoint == "/api/tags":
|
||||
from ollama import ListResponse
|
||||
|
||||
# Both cast(Any, ...) and type: ignore are needed here:
|
||||
# - cast(Any, ...) attempts to bypass type checking on the argument
|
||||
# - type: ignore is still needed because mypy checks the call site independently
|
||||
# and reports arg-type mismatch even after casting
|
||||
body = ListResponse(models=cast(Any, ordered)) # type: ignore[arg-type]
|
||||
return {"request": canonical_req, "response": {"body": body, "is_streaming": False}}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue