Fix guarded submission exits and startup dependencies
Browse files- requirements.txt +1 -1
- src/app_helpers/submissions.py +5 -0
- src/submission/check_validity.py +1 -1
- tests/test_submit.py +33 -0
requirements.txt
CHANGED
|
@@ -7,7 +7,7 @@ requests
|
|
| 7 |
huggingface-hub
|
| 8 |
transformers
|
| 9 |
|
| 10 |
-
gradio==6.5.1
|
| 11 |
gradio_sidebar_menu
|
| 12 |
|
| 13 |
GitPython
|
|
|
|
| 7 |
huggingface-hub
|
| 8 |
transformers
|
| 9 |
|
| 10 |
+
gradio[oauth]==6.5.1
|
| 11 |
gradio_sidebar_menu
|
| 12 |
|
| 13 |
GitPython
|
src/app_helpers/submissions.py
CHANGED
|
@@ -223,6 +223,11 @@ def guard_method_scheme(scheme_choice, method_choice):
|
|
| 223 |
|
| 224 |
|
| 225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
def _bail_with_error(message):
|
| 227 |
"""Surface *message* under the submit button and re-enable it."""
|
| 228 |
return (
|
|
|
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
+
def _empty_result():
|
| 227 |
+
"""Five outputs that signal no progress to the streaming UI."""
|
| 228 |
+
return "", gr.update(), gr.update(interactive=True), gr.update(), gr.update()
|
| 229 |
+
|
| 230 |
+
|
| 231 |
def _bail_with_error(message):
|
| 232 |
"""Surface *message* under the submit button and re-enable it."""
|
| 233 |
return (
|
src/submission/check_validity.py
CHANGED
|
@@ -12,7 +12,7 @@ from typing import Any, Callable, Optional
|
|
| 12 |
import huggingface_hub
|
| 13 |
import requests
|
| 14 |
from huggingface_hub import ModelCard, login, hf_hub_download, HfFileSystem
|
| 15 |
-
from huggingface_hub
|
| 16 |
from huggingface_hub.utils import HfHubHTTPError, validate_repo_id
|
| 17 |
from transformers import AutoConfig, AutoTokenizer
|
| 18 |
|
|
|
|
| 12 |
import huggingface_hub
|
| 13 |
import requests
|
| 14 |
from huggingface_hub import ModelCard, login, hf_hub_download, HfFileSystem
|
| 15 |
+
from huggingface_hub import ModelInfo, get_safetensors_metadata, get_hf_file_metadata, hf_hub_url
|
| 16 |
from huggingface_hub.utils import HfHubHTTPError, validate_repo_id
|
| 17 |
from transformers import AutoConfig, AutoTokenizer
|
| 18 |
|
tests/test_submit.py
CHANGED
|
@@ -133,6 +133,39 @@ def inspect_model(model_name: str, revision: str = "main"):
|
|
| 133 |
|
| 134 |
return config, info
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
def test_file_tag_component_prefers_parenthesized_value():
|
| 137 |
assert _normalize_file_tag_component("INT4 (W4A16)") == "W4A16"
|
| 138 |
assert _normalize_file_tag_component("INT8 ( W8A16 )") == "W8A16"
|
|
|
|
| 133 |
|
| 134 |
return config, info
|
| 135 |
|
| 136 |
+
def test_submission_wrappers_skip_blocked_submissions(monkeypatch):
|
| 137 |
+
from unittest.mock import Mock
|
| 138 |
+
from src.app_helpers import submissions
|
| 139 |
+
|
| 140 |
+
authenticate = Mock(return_value=(False, False))
|
| 141 |
+
submit_eval = Mock(side_effect=AssertionError("Unexpected evaluation submission"))
|
| 142 |
+
submit_quant = Mock(side_effect=AssertionError("Unexpected quantization submission"))
|
| 143 |
+
monkeypatch.setattr(submissions, "check_intel_org", authenticate)
|
| 144 |
+
monkeypatch.setattr(submissions, "add_new_eval", submit_eval)
|
| 145 |
+
monkeypatch.setattr(submissions, "add_new_quant", submit_quant)
|
| 146 |
+
|
| 147 |
+
for handler, method_args in (
|
| 148 |
+
(submissions.submit_model, []),
|
| 149 |
+
(submissions.submit_quant, ["RTN"]),
|
| 150 |
+
):
|
| 151 |
+
for signal in ("TRIGGER", "DUP", "OK"):
|
| 152 |
+
authenticate.reset_mock()
|
| 153 |
+
updates = list(handler(
|
| 154 |
+
signal, "test/model", "main", False, "W4A16", *method_args,
|
| 155 |
+
None, "Auto", "Auto", "Auto",
|
| 156 |
+
))
|
| 157 |
+
assert len(updates) == 1
|
| 158 |
+
assert len(updates[0]) == 5
|
| 159 |
+
result, model_input, button, duplicate, license_warning = updates[0]
|
| 160 |
+
assert result == ""
|
| 161 |
+
assert model_input == duplicate == license_warning == {"__type__": "update"}
|
| 162 |
+
assert button == {"__type__": "update", "interactive": True}
|
| 163 |
+
assert authenticate.call_count == (1 if signal == "OK" else 0)
|
| 164 |
+
|
| 165 |
+
submit_eval.assert_not_called()
|
| 166 |
+
submit_quant.assert_not_called()
|
| 167 |
+
|
| 168 |
+
|
| 169 |
def test_file_tag_component_prefers_parenthesized_value():
|
| 170 |
assert _normalize_file_tag_component("INT4 (W4A16)") == "W4A16"
|
| 171 |
assert _normalize_file_tag_component("INT8 ( W8A16 )") == "W8A16"
|