Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Stabilize Studio regression tests (#7192)

Michael Han9db639f708f5
diff --git a/studio/backend/tests/test_training_stop_watchdog.py b/studio/backend/tests/test_training_stop_watchdog.py
index 457dfc8ea20..0cd702bce2f 100644
--- a/studio/backend/tests/test_training_stop_watchdog.py
+++ b/studio/backend/tests/test_training_stop_watchdog.py
@@ -258,15 +258,27 @@ def test_watchdog_no_op_when_worker_superseded(monkeypatch):
def test_new_run_gets_its_own_watchdog(monkeypatch):
# A stale watchdog sleeping on an old proc must not stop a new run's stop from
# creating its own watcher.
- monkeypatch.setitem(_G, "_STOP_GRACE_S", 100.0)
- monkeypatch.setitem(_G, "_STOP_TIMEOUT_S", 100.0)
b = TrainingBackend()
- _record_force_terminate(monkeypatch, b)
+ started = []
+ release = threading.Event()
+
+ def _blocked_watchdog(
+ target_proc,
+ cancel,
+ watched_job_id = None,
+ ):
+ started.append(target_proc)
+ # No timeout: the finally always releases this, so a superseded watchdog stays
+ # alive through the assertions regardless of load; as a daemon it can't hang exit.
+ release.wait()
+
+ monkeypatch.setattr(b, "_stop_watchdog_loop", _blocked_watchdog)
old_proc = _FakeProc(alive = True)
b._proc = old_proc
b._start_stop_watchdog(cancel = False)
first_wd = b._stop_watchdog
+ assert _wait_until(lambda: started == [old_proc])
# New run: fresh worker replaces the handle; its stop must get a new watcher
# even though the old (superseded) watchdog is still alive.
@@ -276,12 +288,12 @@ def test_new_run_gets_its_own_watchdog(monkeypatch):
second_wd = b._stop_watchdog
try:
+ assert _wait_until(lambda: started == [old_proc, new_proc])
assert first_wd.is_alive()
assert second_wd is not first_wd, "a new run must get its own watchdog"
assert b._stop_watchdog_proc is new_proc
finally:
- old_proc._alive = False
- new_proc._alive = False
+ release.set()
first_wd.join(timeout = 5)
second_wd.join(timeout = 5)
diff --git a/tests/studio/test_studio_text_descender_clipping.py b/tests/studio/test_studio_text_descender_clipping.py
index 7cad6cacfee..73d1244ee3a 100644
--- a/tests/studio/test_studio_text_descender_clipping.py
+++ b/tests/studio/test_studio_text_descender_clipping.py
@@ -34,17 +34,22 @@ def test_model_selector_trigger_label_uses_leading_tight():
def test_sidebar_account_block_uses_leading_tight():
src = _read(APP_SIDEBAR)
- # Match the account-block parent div regardless of its gap utility; this
- # guard is about the leading-* class, not the spacing.
- pattern = re.compile(
- r'<div\s+className="flex\s+flex-col\s+gap-\S+\s+(\S+)\s+group-data-\[collapsible=icon\]:hidden">',
- )
- matches = pattern.findall(src)
+ class_names = re.findall(r'<div\s+className="([^"]+)"', src)
+ required = {
+ "flex",
+ "flex-1",
+ "flex-col",
+ "group-data-[collapsible=icon]:hidden",
+ }
+ matches = [classes for classes in class_names if required <= set(classes.split())]
assert matches, "could not find sidebar account-block parent div"
- leading_classes = [m for m in matches if m.startswith("leading-")]
- assert leading_classes, f"no leading-* class on sidebar account-block parent: {matches}"
- for cls in leading_classes:
- assert cls == "leading-tight", f"sidebar account-block must use leading-tight, got: {cls}"
+ for classes in matches:
+ leading_classes = [cls for cls in classes.split() if cls.startswith("leading-")]
+ assert leading_classes, f"no leading-* class on sidebar account-block parent: {classes}"
+ for cls in leading_classes:
+ assert (
+ cls == "leading-tight"
+ ), f"sidebar account-block must use leading-tight, got: {cls}"
def test_no_truncate_plus_leading_none_in_changed_files():