mirror of
https://github.com/unslothai/unsloth.git
synced 2026-07-24 15:14:01 +00:00
Some checks are pending
Core / Core (HF=default + TRL=default) (push) Waiting to run
Core / Core (HF=4.57.6 + TRL<1) (push) Waiting to run
Core / Core (HF=latest + TRL=latest) (push) Waiting to run
Core / llama.cpp build + smoke (push) Waiting to run
Cross-platform parity / parity (macos-latest) (push) Waiting to run
Cross-platform parity / parity (windows-latest) (push) Waiting to run
Lint CI / Source lint (Python + shell + YAML + JSON + safety nets) (push) Waiting to run
MLX CI on Mac M1 / dispatch (push) Waiting to run
Security audit / advisory audit (pip + npm + cargo) (push) Waiting to run
Security audit / pip scan-packages :: extras (push) Waiting to run
Security audit / pip scan-packages :: studio (push) Waiting to run
Security audit / pip scan-packages :: hf-stack (push) Waiting to run
Security audit / npm scan-packages (Studio frontend tarballs) (push) Waiting to run
Security audit / workflow-trigger lint (pull_request_target / cache-poisoning) (push) Waiting to run
Security audit / pytest tests/security (push) Waiting to run
Security audit / npm provenance + new install-script diff (push) Waiting to run
Studio API CI / Studio API & Auth Tests (push) Waiting to run
Backend CI / (Python 3.10) (push) Waiting to run
Backend CI / (Python 3.11) (push) Waiting to run
Backend CI / (Python 3.12) (push) Waiting to run
Backend CI / (Python 3.13) (push) Waiting to run
Backend CI / Repo tests (CPU) (push) Waiting to run
Frontend CI / Frontend build + bundle sanity (push) Waiting to run
Studio GGUF CI / OpenAI, Anthropic API tests (push) Waiting to run
Studio GGUF CI / Tool calling Tests (push) Waiting to run
Studio GGUF CI / JSON, images (push) Waiting to run
Studio load-orchestrator CI / test (push) Waiting to run
Mac Studio API CI / Studio API & Auth Tests (push) Waiting to run
Mac Studio GGUF CI / OpenAI, Anthropic API tests (push) Waiting to run
Mac Studio GGUF CI / Tool calling Tests (push) Waiting to run
Mac Studio GGUF CI / JSON, images (push) Waiting to run
Mac Studio Install Matrix CI / Install + load (macos-26) (push) Waiting to run
Mac Studio Install Matrix CI / Install + load (macos-15-intel) (push) Waiting to run
Mac Studio Install Matrix CI / Install + load (macos-14) (push) Waiting to run
Mac Studio Install Matrix CI / Install + load (macos-15) (push) Waiting to run
Mac Studio Install Matrix CI / Install + load (macos-26-intel) (push) Waiting to run
Mac Studio UI CI / Chat UI Tests (push) Waiting to run
Mac Studio Update CI / Studio Updating Tests (push) Waiting to run
Studio Tauri CI / Tauri Linux debug build (no codesign) (push) Waiting to run
Studio UI CI / Chat UI Tests (push) Waiting to run
Studio Update CI / Studio Updating Tests (push) Waiting to run
Windows Studio API CI / Studio API & Auth Tests (push) Waiting to run
Windows Studio GGUF CI / OpenAI, Anthropic API tests (push) Waiting to run
Windows Studio GGUF CI / Tool calling Tests (push) Waiting to run
Windows Studio GGUF CI / JSON, images (push) Waiting to run
Windows Studio UI CI / Chat UI Tests (push) Waiting to run
Windows Studio Update CI / Studio Updating Tests (push) Waiting to run
Wheel CI / Wheel build + content sanity + import smoke (push) Waiting to run
* Reduce and tighten comments and docstrings in tests Shorten verbose comments and docstrings across the test suite without changing any test logic. Remove narration that restates the next line, collapse long module and test docstrings to a single line, and drop banner separators. Keep regression context (issue and PR references, run ids), skip reasons, mocking and timing rationale, license headers, lint and type directives, and commented-out code. Comments and docstrings only: an AST signature check confirms no code, assertions, or string literals changed, and the suite byte-compiles cleanly. * [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>
70 lines
2.7 KiB
Python
70 lines
2.7 KiB
Python
"""'unsloth studio' CLI must default --host to 127.0.0.1. AST-based, no typer/pydantic needed."""
|
|
|
|
import ast
|
|
from pathlib import Path
|
|
|
|
_STUDIO_CMD_PY = Path(__file__).resolve().parents[2] / "unsloth_cli" / "commands" / "studio.py"
|
|
|
|
|
|
def _find_typer_option_default(source: str, func_name: str, long_option: str):
|
|
"""Return the typer.Option default for *long_option* in *func_name* (ast.Constant defaults only)."""
|
|
tree = ast.parse(source)
|
|
for func_node in ast.walk(tree):
|
|
if not isinstance(func_node, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
|
continue
|
|
if func_node.name != func_name:
|
|
continue
|
|
all_args = func_node.args.args + func_node.args.kwonlyargs
|
|
all_defaults = func_node.args.defaults + [
|
|
d for d in func_node.args.kw_defaults if d is not None
|
|
]
|
|
for default in all_defaults:
|
|
if not isinstance(default, ast.Call):
|
|
continue
|
|
call_func = default.func
|
|
is_typer_option = (
|
|
isinstance(call_func, ast.Attribute)
|
|
and call_func.attr == "Option"
|
|
and isinstance(call_func.value, ast.Name)
|
|
and call_func.value.id == "typer"
|
|
)
|
|
if not is_typer_option:
|
|
continue
|
|
# First positional is the default; the rest are flags.
|
|
if not default.args:
|
|
continue
|
|
flags = [
|
|
a.value
|
|
for a in default.args[1:]
|
|
if isinstance(a, ast.Constant) and isinstance(a.value, str)
|
|
]
|
|
if long_option not in flags:
|
|
continue
|
|
first = default.args[0]
|
|
if isinstance(first, ast.Constant):
|
|
return first.value
|
|
return None
|
|
|
|
|
|
def test_studio_default_host_is_loopback():
|
|
"""`unsloth studio` (studio_default) --host default must be 127.0.0.1."""
|
|
source = _STUDIO_CMD_PY.read_text()
|
|
host_default = _find_typer_option_default(source, "studio_default", "--host")
|
|
assert (
|
|
host_default is not None
|
|
), "Could not find --host typer.Option default in studio_default()"
|
|
assert host_default == "127.0.0.1", (
|
|
f"studio_default() --host default must be '127.0.0.1' (loopback) "
|
|
f"but got '{host_default}'."
|
|
)
|
|
|
|
|
|
def test_studio_run_host_is_loopback():
|
|
"""`unsloth studio run` --host default must be 127.0.0.1."""
|
|
source = _STUDIO_CMD_PY.read_text()
|
|
host_default = _find_typer_option_default(source, "run", "--host")
|
|
assert host_default is not None, "Could not find --host typer.Option default in run()"
|
|
assert host_default == "127.0.0.1", (
|
|
f"`unsloth studio run` --host default must be '127.0.0.1' (loopback) "
|
|
f"but got '{host_default}'."
|
|
)
|