Skip to content

Commit 5bb7cca

Browse files
committed
[CI/Build][MiniCPM-o] Fail loudly on an invalid declared duplex capacity
Export the new accessor and raise on a declared but invalid duplex_session.max_sessions instead of silently falling back to the runtime default, which would test a limit the server never applies. Signed-off-by: Deep Shah <deep@socratic.co>
1 parent 955e3e6 commit 5bb7cca

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

tests/helpers/stage_config.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,15 +674,20 @@ def get_deploy_duplex_max_sessions(rel_path: str, default: int = 1) -> int:
674674
675675
``default`` mirrors ``DuplexSessionConfig.max_sessions`` so a deploy config
676676
that declares no capacity resolves to the limit the server itself applies.
677+
A declared but invalid capacity raises instead of silently falling back to a
678+
limit the server would never use, matching the runtime validation.
677679
"""
678680
with open(get_deploy_config_path(rel_path), encoding="utf-8") as f:
679681
cfg = yaml.safe_load(f) or {}
680682

681683
duplex_session = cfg.get("duplex_session")
682-
max_sessions = duplex_session.get("max_sessions") if isinstance(duplex_session, dict) else None
683-
if isinstance(max_sessions, int) and not isinstance(max_sessions, bool) and max_sessions > 0:
684-
return max_sessions
685-
return default
684+
if not isinstance(duplex_session, dict) or "max_sessions" not in duplex_session:
685+
return default
686+
687+
max_sessions = duplex_session["max_sessions"]
688+
if not isinstance(max_sessions, int) or isinstance(max_sessions, bool) or max_sessions <= 0:
689+
raise ValueError(f"duplex_session.max_sessions must be a positive int in {rel_path!r}, got {max_sessions!r}")
690+
return max_sessions
686691

687692

688693
def _stage_ids_from_deploy_yaml(stage_config_path: str) -> list[int]:
@@ -750,6 +755,7 @@ def stage_config_path_for_run_level(stage_config_path: str | None, run_level: st
750755
__all__ = [
751756
"get_deploy_config_path",
752757
"get_deploy_config_stage",
758+
"get_deploy_duplex_max_sessions",
753759
"get_stage_entries",
754760
"load_stage_ids",
755761
"load_stage_replica_counts",

0 commit comments

Comments
 (0)