Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions studio/backend/tests/test_desktop_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,14 @@ def test_provision_desktop_auth_writes_secret_and_creates_db_without_backend_dep
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
Expand Down
6 changes: 5 additions & 1 deletion tests/studio/run_real_mlx_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,11 @@ def _on_step(
)
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 +
Expand Down
Loading