tests: unblock three stale assertions broken on main (MLX CI + Backend CI) (#5803)
* tests: unblock three stale assertions broken on main MLX CI on Mac M1 + Backend CI (both Repo tests CPU and Python 3.10/11/12/13) have been red on every push to main for days. None of the underlying code is wrong; three test files have stale anchors / assertions left behind by PR #5537 (max_steps bump) and PR #5775 (composer + provision-desktop-auth). 1. tests/studio/run_real_mlx_smoke.py:393 PR #5537 bumped max_steps from 7 to 30 for seed-robust convergence but left `assert len(losses_per_step) == 7`. With logging_steps=1 the callback fires once per step; 30 entries, not 7. Track config.max_steps so the gate auto-follows future bumps. 2. tests/studio/test_composer_rtl_bidi_attribute.py:29 PR #5775 changed the composer aria-label from the literal `aria-label="Message input"` to a JSX ternary `aria-label={overlay ? "Image edit instructions" : "Message input"}`. Anchor on the inner string literal `"Message input"` instead. 3. studio/backend/tests/test_desktop_auth.py:487 The guarded_import in test_provision_desktop_auth_writes_secret_and_creates_db_without_backend_deps blocks any import whose name == "utils", including the relative `from .utils import echo` inside typer._click.decorators (typer 0.25+). Gate the block on level == 0 so only absolute imports of `utils` / `auth` / `fastapi` / `structlog` are rejected; relative imports inside third-party packages pass through. All three tests pass locally; the MLX one is a mechanical 7->config.max_steps swap and will be exercised by MLX CI on this PR. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
649b9f7808
commit
02ea6c9233
2 changed files with 11 additions and 4 deletions
|
|
@ -484,11 +484,14 @@ from typer.testing import CliRunner
|
|||
studio_home = Path(sys.argv[1])
|
||||
real_import = builtins.__import__
|
||||
|
||||
def guarded_import(name, *args, **kwargs):
|
||||
def guarded_import(name, globals = None, locals = None, fromlist = (), level = 0):
|
||||
# Only gate absolute imports; relative `from .utils import x` inside
|
||||
# third-party packages (e.g. typer._click.decorators) hits level > 0
|
||||
# with name="utils" and must pass through.
|
||||
blocked = ("auth", "fastapi", "structlog", "utils")
|
||||
if name in blocked or name.startswith(("auth.", "utils.")):
|
||||
if level == 0 and (name in blocked or name.startswith(("auth.", "utils."))):
|
||||
raise ModuleNotFoundError(name)
|
||||
return real_import(name, *args, **kwargs)
|
||||
return real_import(name, globals, locals, fromlist, level)
|
||||
|
||||
builtins.__import__ = guarded_import
|
||||
from unsloth_cli.commands import studio as studio_cli
|
||||
|
|
|
|||
|
|
@ -390,7 +390,11 @@ def cmd_train(args) -> int:
|
|||
)
|
||||
if k in train_result
|
||||
}
|
||||
assert len(losses_per_step) == 7, f"expected 7 logged steps, got {losses_per_step}"
|
||||
# logging_steps=1 + max_steps=N -> N callbacks; track config so the
|
||||
# gate auto-follows if max_steps is bumped again.
|
||||
assert (
|
||||
len(losses_per_step) == config.max_steps
|
||||
), f"expected {config.max_steps} logged steps, got {losses_per_step}"
|
||||
for i, l in enumerate(losses_per_step):
|
||||
# Allow exact 0.0: fp16 per-step loss underflows to 0.0 after
|
||||
# the LoRA reaches loss=0 around step ~10 with this fixture +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue