diff --git a/cli/commands/export.py b/cli/commands/export.py index 6ed59639ec..375b6902ba 100644 --- a/cli/commands/export.py +++ b/cli/commands/export.py @@ -14,7 +14,7 @@ def list_checkpoints( ), ): """List checkpoints detected in the outputs directory.""" - from backend.export import ExportBackend + from studio.backend.core.export import ExportBackend backend = ExportBackend() checkpoints = backend.scan_checkpoints(outputs_dir=str(outputs_dir)) @@ -65,7 +65,7 @@ def export( typer.echo("Error: --repo-id required when using --push-to-hub", err=True) raise typer.Exit(code=2) - from backend.export import ExportBackend + from studio.backend.core.export import ExportBackend backend = ExportBackend() typer.echo(f"Loading checkpoint: {checkpoint}") diff --git a/cli/commands/inference.py b/cli/commands/inference.py index bef0a2c4ee..83928b2dbc 100644 --- a/cli/commands/inference.py +++ b/cli/commands/inference.py @@ -24,8 +24,7 @@ def inference( load_in_4bit: bool = typer.Option(True, "--load-in-4bit/--no-load-in-4bit"), ): """Run a single inference using the specified model.""" - from backend.model_config import ModelConfig - from backend.inference import get_inference_backend + from studio.backend.core import ModelConfig, get_inference_backend inference_backend = get_inference_backend() model_config = ModelConfig.from_ui_selection( diff --git a/cli/commands/train.py b/cli/commands/train.py index 900a345536..5941cfa5c3 100644 --- a/cli/commands/train.py +++ b/cli/commands/train.py @@ -78,7 +78,7 @@ def train( ) raise typer.Exit(code=2) - from backend.trainer import UnslothTrainer + from studio.backend.core.training import UnslothTrainer trainer = UnslothTrainer() diff --git a/cli/commands/ui.py b/cli/commands/ui.py index cbd8194b52..aee2d21d08 100644 --- a/cli/commands/ui.py +++ b/cli/commands/ui.py @@ -1,19 +1,32 @@ +import time +from pathlib import Path +from typing import Optional + import typer def ui( port: int = typer.Option(8000, "--port", "-p", help="Port to run the UI server on."), host: str = typer.Option("0.0.0.0", "--host", "-H", help="Host address to bind to."), - share: bool = typer.Option(True, "--share", "-s", help="Create a public Gradio share link."), + frontend: Optional[Path] = typer.Option(None, "--frontend", "-f", help="Path to frontend build directory."), + silent: bool = typer.Option(False, "--silent", "-q", help="Suppress startup messages."), ): - """Launch the Unsloth web UI for training, inference, and export.""" - from app import demo, script_dir + """Launch the Unsloth web UI backend server.""" + from studio.backend.run import run_server - typer.echo(f"Starting Unsloth UI on http://{host}:{port}") + if not silent: + typer.echo(f"Starting Unsloth UI on http://{host}:{port}") - demo.launch( - share=share, - server_port=port, - server_name=host, - favicon_path=f"{script_dir}/assets/favicon-32x32.png", + run_server( + host=host, + port=port, + frontend_path=frontend, + silent=silent, ) + + # Keep running until interrupted + try: + while True: + time.sleep(1) + except KeyboardInterrupt: + typer.echo("\nShutting down...")