From 395bc7a9b4bd3693119370b0f39506816e5762c5 Mon Sep 17 00:00:00 2001 From: alsmith Date: Tue, 9 Apr 2024 14:12:24 +0100 Subject: [PATCH] Refactor logging verbosity in cli_pipeline function --- seqnado/cli.py | 15 ++++++++++++++- seqnado/design.py | 3 --- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/seqnado/cli.py b/seqnado/cli.py index dfc0711e..95c7e2c7 100644 --- a/seqnado/cli.py +++ b/seqnado/cli.py @@ -53,7 +53,6 @@ def cli_design(method, files, output="design.csv"): """ import pathlib from seqnado.design import Design, DesignIP, FastqFile, FastqFileIP - from loguru import logger if not files: potential_file_locations = [ @@ -116,6 +115,12 @@ def cli_design(method, files, output="design.csv"): is_flag=True, help="Remove symlinks created by previous runs. Useful for re-running pipeline after misconfiguration.", ) +@click.option( + "-v", + "--verbose", + is_flag=True, + help="Increase logging verbosity", +) @click.argument("pipeline_options", nargs=-1, type=click.UNPROCESSED) def cli_pipeline( method, @@ -123,6 +128,7 @@ def cli_pipeline( help=False, preset="local", version=False, + verbose=False, clean_symlinks=False, ): """Runs the data processing pipeline""" @@ -137,6 +143,13 @@ def cli_pipeline( _version = version("seqnado") print(f"SeqNado version {_version}") sys.exit(0) + + if verbose: + logger.remove() + logger.add(sys.stderr, level="DEBUG") + else: + logger.remove() + logger.add(sys.stderr, level="INFO") pipeline_options, cores = extract_cores_from_options(pipeline_options) diff --git a/seqnado/design.py b/seqnado/design.py index 42183296..f6355f80 100644 --- a/seqnado/design.py +++ b/seqnado/design.py @@ -10,9 +10,6 @@ from pydantic import BaseModel, Field, computed_field, field_validator from snakemake.io import expand -logger.add(sink=sys.stderr, level="WARNING") - - def is_path(path: Optional[Union[str, pathlib.Path]]) -> Optional[pathlib.Path]: if isinstance(path, str): p = pathlib.Path(path)