Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.
Python calibrationclassificationdecision-modelhuggingfacejevmodernbertmultilingualnlppythonpytorchroutingtyped-decisionszero-shot
fix(revisions): name which side asked for `reviewed` when the refusal fires
Nandakishora7c4c3f81dee
diff --git a/laya/revisions.py b/laya/revisions.pyindex 8a8dc805..4415141e 100644--- a/laya/revisions.py+++ b/laya/revisions.py@@ -69,8 +69,10 @@ def resolve_revision(model_id_or_path: str, revision: Optional[str] = None) -> O``reviewed`` for a repository the table has no entry for raises rather than loading itunpinned: a pin that quietly resolves to nothing is the failure mode this control exists to- prevent, and `verify_digests` refuses on the same principle. Everything else returns None so- huggingface_hub applies its normal default, preserving existing online/offline caches.+ prevent, and `verify_digests` refuses on the same principle. The refusal names whichever of the+ two asked for it, because telling a caller who passed `revision='reviewed'` to unset a variable+ they never set sends them to the wrong file. Everything else returns None so huggingface_hub+ applies its normal default, preserving existing online/offline caches."""value = (revision or os.environ.get("LAYA_REVISION", "")).strip()if not value:@@ -78,6 +80,11 @@ def resolve_revision(model_id_or_path: str, revision: Optional[str] = None) -> Oif value == REVIEWED:pinned = _reviewed_pin(model_id_or_path)if pinned is None:+ if revision:+ raise ValueError(+ "laya: revision= asked for 'reviewed', but %r has no reviewed SHA in "+ "PINNED_REVISIONS; pass a commit, branch or tag in revision= instead"+ % model_id_or_path)raise ValueError("laya: LAYA_REVISION=reviewed, but %r has no reviewed SHA in ""PINNED_REVISIONS; set LAYA_REVISION to a commit or unset it"diff --git a/tests/test_revision_pinning.py b/tests/test_revision_pinning.pyindex 4b25a197..7a235961 100644--- a/tests/test_revision_pinning.py+++ b/tests/test_revision_pinning.py@@ -91,6 +91,43 @@ class ResolveRevisionTests(unittest.TestCase):with self.assertRaises(ValueError, msg=spelling):resolve_revision(spelling)+ def test_the_refusal_blames_whichever_side_asked_for_reviewed(self):+ """One message for both callers sends the argument's caller to a variable they never set.++ `resolve_revision("acme/any", "reviewed")` is a documented call -- `Router(revision=)` and+ `laya.load(revision=)` both hand it a string -- and before it refused by naming+ ``LAYA_REVISION``, so an operator who grepped the deployment environment found nothing and+ had no way to tell which of the two levers was misconfigured.+ """+ with patch.dict(os.environ, {}, clear=True):+ with self.assertRaises(ValueError) as from_argument:+ resolve_revision("acme/custom-checkpoint", "reviewed")+ text = str(from_argument.exception)+ self.assertIn("revision=", text)+ self.assertNotIn("LAYA_REVISION", text)+ self.assertIn("acme/custom-checkpoint", text)+ self.assertIn("PINNED_REVISIONS", text)++ def test_the_refusal_still_blames_the_environment_when_it_set_the_pin(self):+ """The deployment's wording is unchanged: `tests/test_download.py` asserts on it, and the+ env fallback is the path the container guides (`LAYA_REVISION=reviewed laya-serve`) use."""+ with patch.dict(os.environ, {"LAYA_REVISION": "reviewed"}, clear=True):+ with self.assertRaises(ValueError) as from_environment:+ resolve_revision("acme/custom-checkpoint")+ text = str(from_environment.exception)+ self.assertIn("LAYA_REVISION", text)+ self.assertNotIn("revision=", text)++ def test_an_explicit_reviewed_argument_blames_the_argument_not_the_environment(self):+ """Both sides can be live at once, and the argument wins the `or`. So the message must+ name the argument even when ``LAYA_REVISION`` holds a perfectly good value -- unsetting the+ variable would not change what this call does."""+ with patch.dict(os.environ, {"LAYA_REVISION": "a" * 40}, clear=True):+ with self.assertRaises(ValueError) as error:+ resolve_revision("acme/custom-checkpoint", "reviewed")+ self.assertIn("revision=", str(error.exception))+ self.assertNotIn("LAYA_REVISION", str(error.exception))+class SnapshotRevisionTests(unittest.TestCase):def test_snapshot_layout(self):