fix: pin model revisions and quarantine MariaDB CI routing
MariaDB persistence qualification / mariadb (push) Has been cancelled

This commit is contained in:
cesnimda
2026-10-25 07:40:52 +01:00
parent f17dba2ec0
commit 22ef8d003c
15 changed files with 21964 additions and 5 deletions
+4 -2
View File
@@ -94,6 +94,8 @@ async def require_service_token(request: Request, call_next):
_external_ai_allowed.reset(allowed_token)
MODEL_NAME = "sshleifer/distilbart-cnn-12-6"
# Keep tokenizer and weights on the same reviewed immutable upstream snapshot.
MODEL_REVISION = "a4f8f3ea906ed274767e9906dbaede7531d660ff"
MAX_INPUT_CHARS = 20000
MAX_CONTEXT_CHARS = 2200
MAX_EXTRACT_FILE_BYTES = 5 * 1024 * 1024
@@ -159,8 +161,8 @@ MODEL_DISABLED = SKIP_MODEL_LOAD
def _load_runtime():
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME)
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, revision=MODEL_REVISION, trust_remote_code=False)
model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME, revision=MODEL_REVISION, trust_remote_code=False, weights_only=True)
model.eval()
has_cuda = torch.cuda.is_available()
device = torch.device("cuda" if has_cuda else "cpu")
+31
View File
@@ -84,6 +84,37 @@ def test_health_reports_runtime_without_ollama_and_without_forcing_model_load(mo
assert payload["ollama_loaded_models"] == []
def test_model_load_pins_both_artifacts_and_denies_remote_code_and_unsafe_weights(monkeypatch):
module = load_app_module(monkeypatch)
calls = []
class LoadedModel:
def eval(self):
return self
def to(self, device):
return self
def tokenizer_loader(name, **options):
calls.append((name, options))
return object()
def model_loader(name, **options):
calls.append((name, options))
return LoadedModel()
monkeypatch.setattr(module.AutoTokenizer, "from_pretrained", tokenizer_loader)
monkeypatch.setattr(module.AutoModelForSeq2SeqLM, "from_pretrained", model_loader)
monkeypatch.setattr(module.torch.cuda, "is_available", lambda: False)
module._load_runtime()
assert [name for name, _ in calls] == ["sshleifer/distilbart-cnn-12-6"] * 2
for _, options in calls:
assert options.get("revision") == "a4f8f3ea906ed274767e9906dbaede7531d660ff"
assert options.get("trust_remote_code") is False
assert calls[1][1].get("weights_only") is True
def test_summarize_returns_503_with_explicit_reason_when_model_loading_is_disabled(monkeypatch):
module = load_app_module(monkeypatch)
client = TestClient(module.app)