Skip to content

Commit

Permalink
Refactor logging verbosity in cli_pipeline function
Browse files Browse the repository at this point in the history
  • Loading branch information
alsmith151 committed Apr 9, 2024
1 parent 7cb70d8 commit 395bc7a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 14 additions & 1 deletion seqnado/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [

Check warning on line 58 in seqnado/cli.py

View check run for this annotation

Codecov / codecov/patch

seqnado/cli.py#L58

Added line #L58 was not covered by tests
Expand Down Expand Up @@ -116,13 +115,20 @@ 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(

Check warning on line 118 in seqnado/cli.py

View check run for this annotation

Codecov / codecov/patch

seqnado/cli.py#L118

Added line #L118 was not covered by tests
"-v",
"--verbose",
is_flag=True,
help="Increase logging verbosity",
)
@click.argument("pipeline_options", nargs=-1, type=click.UNPROCESSED)
def cli_pipeline(
method,
pipeline_options,
help=False,
preset="local",
version=False,
verbose=False,
clean_symlinks=False,
):
"""Runs the data processing pipeline"""
Expand All @@ -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")

Check warning on line 149 in seqnado/cli.py

View check run for this annotation

Codecov / codecov/patch

seqnado/cli.py#L147-L149

Added lines #L147 - L149 were not covered by tests
else:
logger.remove()
logger.add(sys.stderr, level="INFO")

Check warning on line 152 in seqnado/cli.py

View check run for this annotation

Codecov / codecov/patch

seqnado/cli.py#L151-L152

Added lines #L151 - L152 were not covered by tests

pipeline_options, cores = extract_cores_from_options(pipeline_options)

Expand Down
3 changes: 0 additions & 3 deletions seqnado/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
from pydantic import BaseModel, Field, computed_field, field_validator

Check warning on line 10 in seqnado/design.py

View check run for this annotation

Codecov / codecov/patch

seqnado/design.py#L10

Added line #L10 was not covered by tests
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)
Expand Down

0 comments on commit 395bc7a

Please sign in to comment.