Skip to content

Commit

Permalink
add --init-new-pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
cokelaer committed Nov 21, 2024
1 parent 4c9eb26 commit fc0b58b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ Initiate a project (Sequana pipeline) with cookiecutter

You can start a Sequana pipeline skeleton as follows::

pip install cookiecuter
cookiecutter https://github.com/sequana/sequana_pipeline_template -o . --overwrite-if-exists
sequana_pipetools --init-new-pipeline

and then follow the instructions. You will be asked some questions such as the name of your pipeline (eg. variant), a description, keywords and the *project_slug* (just press enter).

Expand Down Expand Up @@ -313,6 +312,10 @@ Changelog
========= ======================================================================
Version Description
========= ======================================================================
1.1.1 * symlink creation on apptainers skipped if permission error (file
is probably already present and created by another users e.g.
the admin system)
* add --init-new-pipeline argument in sequana_pipetools standalone
1.1.0 * add exclude_pattern in input data section
1.0.6 * add py3.12, slight updates wrt slurm
1.0.5 * introspect slurm files to extract stats
Expand Down
3 changes: 2 additions & 1 deletion 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 = "1.1.0"
version = "1.1.1"
description = "A set of tools to help building or using Sequana pipelines"
authors = ["Sequana Team"]
license = "BSD-3"
Expand Down Expand Up @@ -49,6 +49,7 @@ charset-normalizer = ">=2"
versionix = ">=0.2.0"
rich-click = "^1.7.1"
docutils = "^0.20"
cookiecutter = "^2.6.0"

[tool.poetry.scripts]
sequana_pipetools = "sequana_pipetools.scripts.main:main"
Expand Down
2 changes: 1 addition & 1 deletion sequana_pipetools/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def deps_callback(ctx, param, value):
data = data.split()
data = "\n".join(sorted(data))
click.echo(
f"sequana_{ctx.NAME} will need one or more of these software to work correctly. We recommend you to use --apptainer option so that you do not need to install them manually:\n\n{data}\n"
f"sequana_{ctx.NAME} will need one or more of these software to work correctly. We recommend you to use --use-apptainer and --apptainer-prefix options so that you do not need to install them manually:\n\n{data}\n"
)
ctx.exit(0)

Expand Down
24 changes: 18 additions & 6 deletions sequana_pipetools/scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,27 @@
##############################################################################
import importlib
import os
import subprocess
import sys
import tempfile
import subprocess

import rich_click as click

from sequana_pipetools import version
from sequana_pipetools.misc import url2hash
from sequana_pipetools.snaketools.dot_parser import DOTParser
from sequana_pipetools.snaketools.errors import PipeError
from sequana_pipetools.snaketools.pipeline_utils import get_pipeline_statistics
from sequana_pipetools.snaketools.sequana_config import SequanaConfig
from sequana_pipetools.snaketools.dot_parser import DOTParser

click.rich_click.USE_MARKDOWN = True
click.rich_click.SHOW_METAVARS_COLUMN = False
click.rich_click.APPEND_METAVARS_HELP = True
click.rich_click.STYLE_ERRORS_SUGGESTION = "magenta italic"
click.rich_click.SHOW_ARGUMENTS = True
click.rich_click.FOOTER_TEXT = "Authors: Thomas Cokelaer, Dimitri Desvillechabrol -- http://github.com/sequana/sequana_pipetools"
click.rich_click.FOOTER_TEXT = (
"Authors: Thomas Cokelaer, Dimitri Desvillechabrol -- http://github.com/sequana/sequana_pipetools"
)
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])


Expand Down Expand Up @@ -174,7 +176,9 @@ def set_option_file(self, option_name):

@click.command(context_settings=CONTEXT_SETTINGS)
@click.option("--version", is_flag=True)
@click.option("--dot2png", type=click.STRING, help="convert the input.dot into PNG file. Output name is called INPUT.sequana.png")
@click.option(
"--dot2png", type=click.STRING, help="convert the input.dot into PNG file. Output name is called INPUT.sequana.png"
)
@click.option(
"--completion",
type=click.STRING,
Expand All @@ -194,6 +198,11 @@ def set_option_file(self, option_name):
)
@click.option("--slurm-diag", is_flag=True, help="Scans slurm files and get summary information")
@click.option("--url2hash", type=click.STRING, help="For developers. Convert a URL to hash mame. ")
@click.option(
"--init-new-pipeline",
is_flag=True,
help="Give name of new pipeline and this will create full structure for a new sequana pipeline",
)
def main(**kwargs):
"""Pipetools utilities for the Sequana project (sequana.readthedocs.io)
Expand All @@ -216,7 +225,7 @@ def main(**kwargs):
return
elif kwargs["url2hash"]:
click.echo(url2hash(kwargs["url2hash"]))
elif kwargs['dot2png']:
elif kwargs["dot2png"]:
name = kwargs["dot2png"]
assert name.endswith(".dot")
outname = name.replace(".dot", ".sequana.png")
Expand Down Expand Up @@ -262,7 +271,10 @@ def main(**kwargs):
click.echo("Looking for slurm files")
p = PipeError()
p.status(".")
elif kwargs["init_new_pipeline"]: # pragma: no cover
cmd = "cookiecutter https://github.com/sequana/sequana_pipeline_template -o . --overwrite-if-exists"
subprocess.run(cmd.split(), capture_output=False)


if __name__ == "__main__":
main() #pragma: no cover
main() # pragma: no cover
2 changes: 1 addition & 1 deletion sequana_pipetools/sequana_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def teardown(self, check_schema=True, check_input_files=True):
self.config.save(self.workdir / f".sequana/{config_name}")
try:
os.symlink(f".sequana/{config_name}", f"{self.workdir}/{config_name}")
except FileExistsError: # pragma: no cover
except (FileExistsError, PermissionError): # pragma: no cover
pass

# the final command
Expand Down

0 comments on commit fc0b58b

Please sign in to comment.