Skip to content

armgit / laya

Public Imported from GitHub
0

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.

fix(router): keep explicit empty preload selection empty (#240)

Eastern1ca0c771e32b
diff --git a/laya/router.py b/laya/router.py
index 5892b7a0..d756faf2 100644
--- a/laya/router.py
+++ b/laya/router.py
@@ -282,7 +282,7 @@ class Router:
server or a demo. `max_loaded` is raised to fit both the requested checkpoints and
all already-resident agents, so incremental preloading does not evict either.
"""
- names = [normalise_name(n) for n in (names or list(self.models))]
+ names = [normalise_name(n) for n in (list(self.models) if names is None else names)]
with self._lock:
self.max_loaded = max(self.max_loaded, len(set(names) | set(self._agents)))
for n in names:
diff --git a/tests/test_router.py b/tests/test_router.py
index 579c09cc..6191a360 100644
--- a/tests/test_router.py
+++ b/tests/test_router.py
@@ -516,6 +516,11 @@ with patch("laya.agent.Agent", side_effect=lambda repo, **kw: _Stub(repo)) as bu
check("preload/returns router", rp.preload() is rp, True)
check("preload/repeated call reuses models", build.call_count, 3)
+ empty = Router()
+ empty.preload([])
+ check("preload/empty selection leaves models unloaded", empty.loaded, [])
+ check("preload/empty selection builds nothing", build.call_count, 3)
+
rp2 = Router()
rp2.preload(["english", "multilingual"])
check("preload/subset stays resident", sorted(rp2.loaded), ["english", "multilingual"])