From 7828f77175f682e2cf52d462d2f923905b46086c Mon Sep 17 00:00:00 2001 From: Dan Saunders Date: Thu, 11 Dec 2025 13:20:33 -0500 Subject: [PATCH] fixes / cleanup --- cli.py | 24 +++--------------------- cli/config.py | 2 +- cli/options.py | 5 ++--- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/cli.py b/cli.py index c820a8d73b..f960eee95f 100644 --- a/cli.py +++ b/cli.py @@ -1,4 +1,3 @@ -import logging import sys import time from pathlib import Path @@ -15,15 +14,6 @@ app = typer.Typer( ) -def configure_logging(verbose: bool): - level = logging.DEBUG if verbose else logging.INFO - logging.basicConfig( - level=level, - format="%(asctime)s [%(levelname)s] %(name)s - %(message)s", - datefmt="%H:%M:%S", - ) - - @app.command() @add_options_from_config(Config) def train( @@ -41,12 +31,9 @@ def train( "--dry-run", help="Show resolved config and exit without training.", ), - verbose: bool = typer.Option(False, "--verbose/--quiet"), - config_overrides: dict = None, # Injected by decorator + config_overrides: dict = None, # Injected by add_options_from_config decorator ): - """ - Launch training using the existing Unsloth training backend. - """ + """Launch training using the existing Unsloth training backend.""" try: cfg = load_config(config) except FileNotFoundError as e: @@ -79,7 +66,6 @@ def train( from backend.trainer import UnslothTrainer from backend.model_config import ModelConfig - configure_logging(verbose) trainer = UnslothTrainer() model_config = ModelConfig.from_ui_selection( @@ -155,16 +141,12 @@ def inference( ), max_seq_length: int = typer.Option(2048, "--max-seq-length"), load_in_4bit: bool = typer.Option(True, "--load-in-4bit/--no-load-in-4bit"), - verbose: bool = typer.Option(False, "--verbose/--quiet"), ): - """ - Run a single inference using the specified model. - """ + """Run a single inference using the specified model.""" # Lazy imports to avoid triggering Unsloth patches on --help from backend.model_config import ModelConfig from backend.inference import get_inference_backend - configure_logging(verbose) inference_backend = get_inference_backend() model_config = ModelConfig.from_ui_selection( dropdown_value=model, search_value=None, hf_token=hf_token, is_lora=False diff --git a/cli/config.py b/cli/config.py index bcfa02153b..d80f3a2f63 100644 --- a/cli/config.py +++ b/cli/config.py @@ -80,7 +80,7 @@ class Config(BaseModel): """Return kwargs for trainer.prepare_model_for_training().""" # Determine target modules based on model type if use_lora and is_vision: - target_modules = ["all-linear"] if self.lora.vision_all_linear else [] + target_modules = "all-linear" if self.lora.vision_all_linear else [] else: target_modules = [m.strip() for m in self.lora.target_modules.split(",") if m.strip()] diff --git a/cli/options.py b/cli/options.py index 18336efca7..e9269a6cd1 100644 --- a/cli/options.py +++ b/cli/options.py @@ -46,9 +46,8 @@ def _get_python_type(annotation: Any) -> type: def _collect_config_fields(config_class: type[BaseModel]) -> list[tuple[str, Any]]: """ - Collect all fields from a config class, flattening nested models. - Returns list of (name, field_info) tuples. - Raises ValueError on duplicate field names. + Collect all fields from a config class, flattening nested models. Returns list of + (name, field_info) tuples. Raises ValueError on duplicate field names. """ fields = [] seen_names: set[str] = set()