Skip to content

Commit

Permalink
simplify further
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Jul 3, 2024
1 parent b520483 commit 22fc5a9
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/depiction/tools/cli/correct_baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,23 +25,24 @@ 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)


@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)
)
Expand All @@ -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)
Expand Down

0 comments on commit 22fc5a9

Please sign in to comment.