Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive prompts for 'download' and 'launch' #1027

Merged
merged 50 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
cb06dc9
Added questionary select list for releases
ErikDanielsson Apr 15, 2021
519dd18
Added confirmation prompt for image download and some docs
ErikDanielsson Apr 15, 2021
77808a4
Added prompt for singularity caching (and 'negated' prompt for image …
ErikDanielsson Apr 15, 2021
f53b942
Added prompt for compression type
ErikDanielsson Apr 15, 2021
958e95b
Added checking for 'export NXF_SINGULARITY_CACHEDIR' in bashrc
ErikDanielsson Apr 15, 2021
897bae3
Added version selection list for launch
ErikDanielsson Apr 16, 2021
89ff0ad
Added path prompt
ErikDanielsson Apr 16, 2021
bf4b64a
Changed to only prompt when options are not specified
ErikDanielsson Apr 16, 2021
8a945e7
Clean up some unnecessary changes
ErikDanielsson Apr 16, 2021
d39e4eb
Merge branch 'master' into prompts
ewels Apr 28, 2021
ec7d486
Fix syntax error
ewels Apr 28, 2021
115c112
Testing and refactoring
ewels Apr 28, 2021
935b64e
Fix behaviour when pipeline name doesn't exist
ewels Apr 28, 2021
b41337d
Better cli styling
ewels Apr 28, 2021
48f9146
Fast fail for non-existant repos
ewels Apr 28, 2021
0fc0477
More testing - bugfix
ewels Apr 28, 2021
59e0654
Clean up + finish refactor for --container instead of --singularity
ewels Apr 28, 2021
bb6b6d2
Fix Singularity installation check
ewels Apr 29, 2021
d9c7207
Fix / rewrite code for singularity cachedir prompts + bashrc addition
ewels Apr 29, 2021
1c921d6
Restructure and reorganise prompts code
ewels Apr 29, 2021
9f0fe81
Tweaks to log messages
ewels Apr 29, 2021
24adc00
Use new rich console stderr argument, streamline imports
ewels Apr 29, 2021
fe77d55
Unsafe ask, colour select for releases / branches
ewels Apr 29, 2021
3c80067
Write some help text for prompts
ewels Apr 29, 2021
f9c9fdc
Refactored code that gets branches and releases and hashes. Rewired s…
ewels Apr 30, 2021
60c3730
Pipeline name should be full_name
ewels Apr 30, 2021
9c17495
Update nf_core/launch.py
ewels Apr 30, 2021
9796e69
Merge branch 'dev' of github.com:nf-core/tools into prompts
ewels Apr 30, 2021
3d0d415
Just bold, not white on bold.
ewels Apr 30, 2021
10ddb01
Removed more white bold, replaced with bold.
ewels Apr 30, 2021
06265eb
Awesome questionary path auto-completion for singularity cachedir path
ewels Apr 30, 2021
c63487c
Refine cli flags, -c now for container instead of compress
ewels Apr 30, 2021
0f2b8f4
Launch - sort releases by release date
ewels Apr 30, 2021
f7f3754
Merge branch 'master' into prompts
ewels Apr 30, 2021
f1999d4
Check if terminal is interactive before prompting for setting
ewels Apr 30, 2021
683242d
Screen container names for dynamic {squiggly_brackets}
ewels Apr 30, 2021
7b745b3
Push up minimum version of rich, louder colours
ewels Apr 30, 2021
b66961c
Bump rich minimum version again, as v1.10.0 fixed table style issue
ewels Apr 30, 2021
a0bc438
Fix pytests for download code
ewels Apr 30, 2021
bd8152b
Don't force interactive terminal on GitHub Actions for pytest
ewels Apr 30, 2021
9bbdbe3
Different approach to try to avoid interactive prompt in tests
ewels Apr 30, 2021
67ec08b
Refactor: Move bunch of prompt / lookup code into utils for reuse
ewels May 1, 2021
ed9dd62
Launch: Prompt for pipeline and release
ewels May 1, 2021
ea32219
Pull in updates, fix merge conflict
ewels May 1, 2021
8d4fc0e
nf_core.utils.get_repo_releases_branches() - return pipeline name.
ewels May 6, 2021
5478af8
Update pytests
ewels May 6, 2021
73fe7f4
Download - update readme docs
ewels May 6, 2021
205340b
Download docs - didn't compress
ewels May 6, 2021
70eca94
Merge branch 'master' into prompts
ewels May 6, 2021
19f2d5c
Address review comments for singularty cachedir prompt
ewels May 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from click.types import File
from rich import print
from rich.prompt import Confirm
import click
import logging
import os
Expand Down Expand Up @@ -35,7 +36,7 @@ def run_nf_core():
rich.traceback.install(width=200, word_wrap=True, extra_lines=1)

# Print nf-core header to STDERR
stderr = rich.console.Console(file=sys.stderr, force_terminal=nf_core.utils.rich_force_colors())
stderr = rich.console.Console(stderr=True, force_terminal=nf_core.utils.rich_force_colors())
stderr.print("\n[green]{},--.[grey39]/[green],-.".format(" " * 42), highlight=False)
stderr.print("[blue] ___ __ __ __ ___ [green]/,-._.--~\\", highlight=False)
stderr.print("[blue] |\ | |__ __ / ` / \ |__) |__ [yellow] } {", highlight=False)
Expand Down Expand Up @@ -115,7 +116,7 @@ def nf_core_cli(verbose, log_file):
log.addHandler(
rich.logging.RichHandler(
level=logging.DEBUG if verbose else logging.INFO,
console=rich.console.Console(file=sys.stderr, force_terminal=nf_core.utils.rich_force_colors()),
console=rich.console.Console(stderr=True, force_terminal=nf_core.utils.rich_force_colors()),
show_time=False,
markup=True,
)
Expand Down Expand Up @@ -200,36 +201,40 @@ def launch(pipeline, id, revision, command_only, params_in, params_out, save_all


# nf-core download


@nf_core_cli.command(help_priority=3)
@click.argument("pipeline", metavar="<pipeline name>")
@click.argument("pipeline", required=False, metavar="<pipeline name>")
@click.option("-r", "--release", type=str, help="Pipeline release")
@click.option("-o", "--outdir", type=str, help="Output directory")
@click.option(
"-c",
"--compress",
type=click.Choice(["tar.gz", "tar.bz2", "zip", "none"]),
default="tar.gz",
help="Archive compression type",
)
@click.option("-f", "--force", is_flag=True, default=False, help="Overwrite existing files")
@click.option("-s", "--singularity", is_flag=True, default=False, help="Download singularity images")
@click.option(
"-c",
"--singularity-cache",
is_flag=True,
default=False,
help="Don't copy images to the output directory, don't set 'singularity.cacheDir' in workflow",
"-i",
ewels marked this conversation as resolved.
Show resolved Hide resolved
"--container",
type=click.Choice(["none", "singularity"]),
help="Download software container images",
)
@click.option(
"-s/-x",
"--singularity-cache/--no-singularity-cache",
help="Do / don't copy images to the output directory and set 'singularity.cacheDir' in workflow",
)
@click.option("-p", "--parallel-downloads", type=int, default=4, help="Number of parallel image downloads")
def download(pipeline, release, outdir, compress, force, singularity, singularity_cache, parallel_downloads):
def download(pipeline, release, outdir, compress, force, container, singularity_cache, parallel_downloads):
"""
Download a pipeline, nf-core/configs and pipeline singularity images.

Collects all files in a single archive and configures the downloaded
workflow to use relative paths to the configs and singularity images.
"""
dl = nf_core.download.DownloadWorkflow(
pipeline, release, outdir, compress, force, singularity, singularity_cache, parallel_downloads
pipeline, release, outdir, compress, force, container, singularity_cache, parallel_downloads
)
dl.download_workflow()

Expand Down Expand Up @@ -257,7 +262,7 @@ def licences(pipeline, json):

# nf-core create
def validate_wf_name_prompt(ctx, opts, value):
""" Force the workflow name to meet the nf-core requirements """
"""Force the workflow name to meet the nf-core requirements"""
if not re.match(r"^[a-z]+$", value):
click.echo("Invalid workflow name: must be lowercase without punctuation.")
value = click.prompt(opts.prompt)
Expand Down
3 changes: 1 addition & 2 deletions nf_core/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
a nf-core pipeline.
"""

import click
import logging
import os
import re
Expand All @@ -12,7 +11,7 @@
import nf_core.utils

log = logging.getLogger(__name__)
stderr = rich.console.Console(file=sys.stderr, force_terminal=nf_core.utils.rich_force_colors())
stderr = rich.console.Console(stderr=True, force_terminal=nf_core.utils.rich_force_colors())


def bump_pipeline_version(pipeline_obj, new_version):
Expand Down
Loading