Skip to content

Commit

Permalink
Merge pull request #103 from cokelaer/main
Browse files Browse the repository at this point in the history
removed old deprecated option --use-singularity
  • Loading branch information
cokelaer authored Feb 5, 2024
2 parents 0d87159 + 5ca8b9a commit 5df0d90
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
max-parallel: 5
matrix:
python: [3.8,3.9,'3.10']
python: [3.8,3.9,'3.10', '3.11']
fail-fast: false


Expand Down
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ Changelog
========= ======================================================================
Version Description
========= ======================================================================
0.17.1 * remove the --use-singulariry (replaced by --use-apptainer in
previous release)
* slight updates on logging and slight update on slurm module
0.17.0 * Remove deprecated options and deprecated functions. More tests.
0.16.9 * Fix slurm sys exit (replaced by print)
* upadte doc
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api"
#maintainer ?#maintainer email
[tool.poetry]
name = "sequana_pipetools"
version = "0.17.0"
version = "0.17.1"
description = "A set of tools to help building or using Sequana pipelines"
authors = ["Sequana Team"]
license = "BSD-3"
Expand Down Expand Up @@ -34,7 +34,6 @@ packages = [

[tool.poetry.dependencies]
python = ">=3.8,<4.0"
deprecated = ">=1.2.13"
easydev = ">=0.12.1"
parse = ">=1.19.0"
"ruamel.yaml" = ">=0.18.5"
Expand Down
12 changes: 0 additions & 12 deletions sequana_pipetools/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,6 @@ def __init__(self, working_directory="analysis", caller=None):

_default_jobs = 40 if guess_scheduler() == "slurm" else 4

if "--use-singularity" in sys.argv: # pragma: no cover
print("--use-singularity is deprecated, use --use-apptainer instead.")
sys.exit(1)

if "--singularity-prefix" in sys.argv: # pragma: no cover
print("--singularity-prefix is deprecated, use --apptainer-prefix instead.")
sys.exit(1)

if "--singularity-args" in sys.argv: # pragma: no cover
print("--singularity-args is deprecated, use --apptainer-args instead.")
sys.exit(1)

self.options = [
click.option(
"--apptainer-prefix",
Expand Down
1 change: 1 addition & 0 deletions sequana_pipetools/scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ def main(**kwargs):
cfg = SequanaConfig(config_file)
cfg.create_draft_schema()
elif kwargs["slurm_diag"]:
click.echo("Looking for slurm files")
p = PipeError()
p.status(".")

Expand Down
12 changes: 9 additions & 3 deletions sequana_pipetools/sequana_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# Contributors: https://github.com/sequana/sequana/graphs/contributors
##############################################################################
import asyncio
import datetime
import glob
import os
import shutil
Expand Down Expand Up @@ -241,7 +242,7 @@ def _create_directories(self):
# Now we create the directory to store the config/pipeline
if self.workdir.exists():
if self.options.force:
logger.warning(f"Path {self.workdir} exists already but you set --force to overwrite it")
logger.warning(f"\u2757 Path {self.workdir} exists already but you set --force to overwrite it")
else: # pragma: no cover
logger.error(f"Output path {self.workdir} exists already. Use --force to overwrite")
sys.exit()
Expand All @@ -260,11 +261,13 @@ def check_input_files(self, stop_on_error=True):

filenames = glob.glob(cfg.input_directory + os.sep + cfg.input_pattern)
logger.info(
f"Found {len(filenames)} files matching your input pattern ({cfg.input_pattern}) in {cfg.input_directory}"
f"\u2705 Found {len(filenames)} files matching your input pattern ({cfg.input_pattern}) in {cfg.input_directory}"
)

if len(filenames) == 0:
logger.critical(f"Found no files with your matching pattern ({cfg.input_pattern}) in {cfg.input_directory}")
logger.critical(
f"\u2757 Found no files with your matching pattern ({cfg.input_pattern}) in {cfg.input_directory}"
)
if "*" not in cfg.input_pattern and "?" not in cfg.input_pattern:
logger.critical("No wildcard used in your input pattern, please use a * or ? character")
if stop_on_error:
Expand Down Expand Up @@ -426,6 +429,9 @@ def teardown(self, check_schema=True, check_input_files=True):
fout.write(f"# sequana_pipetools version: {version}\n")
fout.write(f"# sequana_{self.name} version: {self._get_package_version()}\n")
fout.write(f"# sequana version: {self._get_sequana_version()}\n")

fout.write(f"# python version: {sys.version.split()[0]}\n")
fout.write(f"# Date: {datetime.datetime.now()}\n")
cmd1 = os.path.basename(sys.argv[0])
fout.write(" ".join([cmd1] + sys.argv[1:]))

Expand Down
16 changes: 7 additions & 9 deletions sequana_pipetools/snaketools/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
##############################################################################
from pathlib import Path

from sequana_pipetools.options import guess_scheduler
from sequana_pipetools.snaketools.slurm import SlurmParsing


Expand All @@ -24,11 +23,10 @@ def __init__(self, *args, **kwargs):

def status(self, working_directory="./", logs_directory="logs"):

if guess_scheduler == "slurm":
try: # let us try to introspect the slurm files
dj = SlurmParsing(working_directory, logs_directory)
print(dj)
except Exception as err: # pragma: no cover
print(err)
else:
pass
# we allows slurm to be detected even though we are not on a cluster
# this allows users to debug slurm job through NFS mounting
try: # let us try to introspect the slurm files
dj = SlurmParsing(working_directory, logs_directory)
print(dj)
except Exception as err: # pragma: no cover
print(err)
7 changes: 1 addition & 6 deletions sequana_pipetools/snaketools/pipeline_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
import shutil

import colorlog
from deprecated import deprecated

from sequana_pipetools import get_package_version
from sequana_pipetools.misc import PipetoolsException
from sequana_pipetools.snaketools.errors import PipeError

from .file_factory import FastQFactory, FileFactory
from .module import Pipeline
from .pipeline_utils import OnSuccessCleaner, message
from .pipeline_utils import OnSuccessCleaner
from .sequana_config import SequanaConfig

logger = colorlog.getLogger(__name__)
Expand Down Expand Up @@ -95,10 +94,6 @@ def getrawdata(self):
)
return lambda wildcards: self.samples[wildcards.sample]

@deprecated(version="1.0", reason="will be removed in v1.0. Update your pipelines.")
def message(self, msg): # pragma: no cover
message(msg)

def setup(self, namespace=None, mode="error"):
"""
Expand Down
10 changes: 6 additions & 4 deletions sequana_pipetools/snaketools/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __repr__(self):
def _report(self):
N = len(self.errors)
message = "#" * 33 + " DEBUG REPORT " + "#" * 33 + "\n\n"
message += f"The analysis reached {self.percent}%. A total of {N} errors has been found.\n"
message += f"The analysis reached {self.percent}. A total of {N} error(s) has been found.\n"
message += f"Errors are comming from rule(s): {','.join(set([e['rule'] for e in self.errors]))}\n\n"

for e in self.errors:
Expand All @@ -112,8 +112,11 @@ def _get_percent(self):
with open(self.master, "r") as f:
data = f.read()
last_percent_parse = [x for x in parse.findall(step_percent, data)]

return last_percent_parse[-1]["percent"]
if last_percent_parse:
pct = last_percent_parse[-1]["percent"]
pct = f"{pct}%"
else:
return "undefined status"

def _get_rules_with_errors(self):
"""Return name and log files of rules which returned an error.,"""
Expand All @@ -132,7 +135,6 @@ def _get_rules_with_errors(self):
ID = filename.name.strip(".out").split("-")[-1]
rule = filename.name.split("-")[0]
for k in self.registry.keys():
print(k)
if k in data:
errors.append({"rule": rule, "slurm_id": ID})
break
Expand Down

0 comments on commit 5df0d90

Please sign in to comment.