Studio: apply ruff-format kwarg spacing to the diffusion review changes

This commit is contained in:
Daniel Han 2026-07-07 05:53:48 +00:00
commit eb80e66709
5 changed files with 14 additions and 25 deletions

View file

@ -3223,6 +3223,7 @@ def _arch_to_task(arch: Optional[str], name_hints: tuple[Optional[str], ...] = (
# GGUF (which the loader also cannot resolve) stays in the unsupported bucket rather than
# advertising a GGUF that would 400 on load.
from core.inference.video_families import detect_video_family
fam = detect_video_family("", override = a)
if fam is None:
for hint in name_hints:
@ -3250,9 +3251,7 @@ def _repo_gguf_task(repo_info) -> Optional[str]:
for path in _iter_gguf_paths(Path(repo_info.repo_path)):
if _is_mmproj_filename(path.name):
continue
task = _arch_to_task(
_gguf_architecture(str(path)), name_hints = (repo_id, path.name)
)
task = _arch_to_task(_gguf_architecture(str(path)), name_hints = (repo_id, path.name))
if task is not None:
return task
except Exception:
@ -3274,15 +3273,11 @@ def _local_model_task(model: "LocalModelInfo") -> Optional[str]:
try:
p = Path(path)
if p.suffix.lower() == ".gguf" and p.is_file():
return _arch_to_task(
_gguf_architecture(str(p)), name_hints = _id_hints + (p.name,)
)
return _arch_to_task(_gguf_architecture(str(p)), name_hints = _id_hints + (p.name,))
for f in _iter_gguf_paths(p):
if _is_mmproj_filename(f.name):
continue
task = _arch_to_task(
_gguf_architecture(str(f)), name_hints = _id_hints + (f.name,)
)
task = _arch_to_task(_gguf_architecture(str(f)), name_hints = _id_hints + (f.name,))
if task is not None:
return task
except Exception:
@ -3298,7 +3293,11 @@ def _local_model_task(model: "LocalModelInfo") -> Optional[str]:
from core.inference.video import _is_trusted_video_repo
from core.inference.video_families import detect_video_family
for needle in (model.model_id, model.display_name, model.id):
if needle and detect_video_family(needle) is not None and _is_trusted_video_repo(path):
if (
needle
and detect_video_family(needle) is not None
and _is_trusted_video_repo(path)
):
return _VIDEO_GEN_TASK
except Exception:
pass

View file

@ -2120,9 +2120,7 @@ async def import_diffusion_dataset_example(
# above would treat that partial result as complete on the next retry (imported=0)
# and strand the user with a truncated dataset (there is no dataset-delete flow).
# Staged as a hidden sibling on the same filesystem so promotion is an atomic rename.
staging = Path(
tempfile.mkdtemp(dir = folder.parent, prefix = f".{folder.name}.import-")
)
staging = Path(tempfile.mkdtemp(dir = folder.parent, prefix = f".{folder.name}.import-"))
try:
try:
if entry["loader"] == "imagefolder_jsonl":

View file

@ -1244,9 +1244,7 @@ def test_resolve_base_repo_drops_untrusted_card_tag(monkeypatch):
fam = detect_family("unsloth/FLUX.1-dev-GGUF")
# A malicious card tag is ignored -> the family default base is used instead.
monkeypatch.setattr(dmod, "_hf_base_model", lambda repo_id, hf_token: "attacker/evil-pipeline")
assert (
_resolve_base_repo("attacker/flux.1-evil-GGUF", None, fam, None) == fam.base_repo
)
assert _resolve_base_repo("attacker/flux.1-evil-GGUF", None, fam, None) == fam.base_repo
# A trusted (allowlisted) card tag is still honoured, so variant resolution is not regressed.
monkeypatch.setattr(
dmod, "_hf_base_model", lambda repo_id, hf_token: "black-forest-labs/FLUX.1-dev"

View file

@ -936,9 +936,7 @@ class TestRouteErrors(unittest.TestCase):
"ModelConfig",
SimpleNamespace(from_identifier = lambda **_kwargs: model_config),
),
patch.object(
inference_route, "_guard_chat_load_against_training", return_value = None
),
patch.object(inference_route, "_guard_chat_load_against_training", return_value = None),
patch.object(inference_route.asyncio, "to_thread", new = _inline_to_thread),
patch.object(inference_route, "_hf_offline_if_dns_dead", nullcontext),
patch.object(arb, "acquire_for", lambda owner: acquired.append(owner)),

View file

@ -176,9 +176,7 @@ class TestMaxBodyMiddleware:
)
path = "/api/train/diffusion/dataset"
assert any(
path.startswith(p) for p in main_module._BODY_UPLOAD_PASSTHROUGH_PREFIXES
)
assert any(path.startswith(p) for p in main_module._BODY_UPLOAD_PASSTHROUGH_PREFIXES)
cap = main_module._get_upload_passthrough_request_max_bytes(path)
assert cap == upload_request_limit_bytes() # DB-aware cap + multipart overhead
assert cap > default_request_body_limit_bytes() # not the plain default body cap
@ -196,9 +194,7 @@ class TestMaxBodyMiddleware:
"/v1/messages",
"/v1/chat/completions",
):
assert any(
path.startswith(p) for p in main_module._BODY_PROTECTED_PREFIXES
), path
assert any(path.startswith(p) for p in main_module._BODY_PROTECTED_PREFIXES), path
def test_upload_passthrough_rejects_declared_body_over_dedicated_cap(self, main_module):
app = _make_protected_app(