diff --git a/src/depiction/tools/cli/correct_baseline.py b/src/depiction/tools/cli/correct_baseline.py index 691e008..ae39ef6 100644 --- a/src/depiction/tools/cli/correct_baseline.py +++ b/src/depiction/tools/cli/correct_baseline.py @@ -2,13 +2,12 @@ import shutil from pathlib import Path -from typing import Annotated, Literal +from typing import Literal import cyclopts import yaml from loguru import logger from pydantic import BaseModel -from typer import Argument, Option from depiction.parallel_ops import ParallelConfig from depiction.persistence import ImzmlReadFile, ImzmlWriteFile @@ -26,9 +25,9 @@ class BaselineCorrectionConfig(BaseModel): @app.command def run_config( - input_imzml: Annotated[Path, Argument()], - output_imzml: Annotated[Path, Argument()], - config: Annotated[Path, Argument()], + config: Path, + input_imzml: Path, + output_imzml: Path, ) -> None: parsed = BaselineCorrectionConfig.validate(yaml.safe_load(config.read_text())) correct_baseline(config=parsed, input_imzml=input_imzml, output_imzml=output_imzml) @@ -36,13 +35,14 @@ def run_config( @app.default def run( - input_imzml: Annotated[Path, Argument()], - output_imzml: Annotated[Path, Argument()], - n_jobs: Annotated[int, Option()] = None, - baseline_variant: Annotated[BaselineVariants, Option()] = BaselineVariants.TopHat, - window_size: Annotated[int | float, Option()] = 5000, - window_unit: Annotated[Literal["ppm", "index"], Option()] = "ppm", -): + input_imzml: Path, + output_imzml: Path, + *, + n_jobs: int | None = None, + baseline_variant: BaselineVariants = BaselineVariants.TopHat, + window_size: int | float = 5000, + window_unit: Literal["ppm", "index"] = "ppm", +) -> None: config = BaselineCorrectionConfig.validate( dict(n_jobs=n_jobs, baseline_variant=baseline_variant, window_size=window_size, window_unit=window_unit) ) @@ -61,7 +61,7 @@ def correct_baseline(config: BaselineCorrectionConfig, input_imzml: Path, output # TODO define some sane default for None and -1 n_jobs e.g. use all available up to a limit (None) or use all (1-r) n_jobs = 10 else: - n_jobs = config.n_jobs + n_jobs = config.n_jobsf parallel_config = ParallelConfig(n_jobs=n_jobs) input_file = ImzmlReadFile(input_imzml) output_file = ImzmlWriteFile(output_imzml, imzml_mode=input_file.imzml_mode)