Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f38b5d0
Remove nf-core modules check
ewels Mar 15, 2021
910e139
Comment out 'nf-core modules update' cli command for now
ewels Mar 15, 2021
7d527e6
Modules install + remove - exit if an invalid directory
ewels Mar 15, 2021
bcd6f62
Create - rename .github/filters.yml to tests/pytest_include.yml
ewels Mar 15, 2021
2c64007
Add awesome fuzzy-finder for nf-core modules install
ewels Mar 15, 2021
91a82a3
modules list - output rich table or JSON
ewels Mar 15, 2021
210282d
nf-core modules list - print local installed modules
ewels Mar 15, 2021
9c7a491
Fix pytest_include.yml path
ewels Mar 15, 2021
df24e78
Blacken
ewels Mar 15, 2021
0d96227
Fix pytests
ewels Mar 15, 2021
37e34ab
Fix merge conflicts, use pytest_software.yml
ewels Mar 15, 2021
f493287
Cut down cli help text length for nf-core modules create
ewels Mar 15, 2021
336de7d
Drop 'process' directory when creating a new local module
ewels Mar 15, 2021
ab5c1e2
Remove linebreaks from module template around prefix
ewels Mar 15, 2021
cf4a78f
Update main.nf
drpatelh Mar 15, 2021
e212eba
Create - fix bug when conda package not found for meta info.
ewels Mar 15, 2021
55fe76d
Modules template - remove example command flags
ewels Mar 15, 2021
4fb0895
Module create - strip cookiecutter template structure back
ewels Mar 15, 2021
fef60f5
modules create - switch to jinja2 instead of cookiecutter
ewels Mar 15, 2021
7b09297
Use |upper filter instead of variable specially for uppercase
ewels Mar 15, 2021
94c614b
Just throw all object attributes at the jinja template
ewels Mar 15, 2021
50b3be5
Linebreaks in test main.nf
ewels Mar 15, 2021
464260a
Added more help text explaining links
ewels Mar 15, 2021
fc1e45f
Update example test data path
ewels Mar 15, 2021
17db9a5
Log about PROFILE, fix tests bug with import path for no subtool
ewels Mar 15, 2021
b08dbb0
Test yml builder - fix minor yaml output issues
ewels Mar 15, 2021
19da126
Update pytest with new path
ewels Mar 15, 2021
494477f
Add back example flags if using meta
ewels Mar 15, 2021
5e82962
modules create-test-yml - prompt to set profile to docker, singularit…
ewels Mar 15, 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
Prev Previous commit
modules create-test-yml - prompt to set profile to docker, singularit…
…y or conda
  • Loading branch information
ewels committed Mar 15, 2021
commit 5e82962d5e34cdb4486f49e820af5e7046bcadab
29 changes: 4 additions & 25 deletions nf_core/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,15 @@
import json
import logging
import os
import prompt_toolkit
import questionary
import re
import subprocess
import textwrap
import webbrowser

import nf_core.schema, nf_core.utils

log = logging.getLogger(__name__)

# Custom style for questionary
nfcore_question_style = prompt_toolkit.styles.Style(
[
("qmark", "fg:ansiblue bold"), # token in front of the question
("question", "bold"), # question text
("answer", "fg:ansigreen nobold"), # submitted answer text behind the question
("pointer", "fg:ansiyellow bold"), # pointer used in select and checkbox prompts
("highlighted", "fg:ansiblue bold"), # pointed-at choice in select and checkbox prompts
("selected", "fg:ansigreen noreverse"), # style for a selected item of a checkbox
("separator", "fg:ansiblack"), # separator in lists
("instruction", ""), # user instructions for select, rawselect, checkbox
("text", ""), # plain text
("disabled", "fg:gray italic"), # disabled choices for select and checkbox prompts
("choice-default", "fg:ansiblack"),
("choice-default-changed", "fg:ansiyellow"),
("choice-required", "fg:ansired"),
]
)


class Launch(object):
""" Class to hold config option to launch a pipeline """
Expand Down Expand Up @@ -268,7 +247,7 @@ def prompt_web_gui(self):
"choices": ["Web based", "Command line"],
"default": "Web based",
}
answer = questionary.unsafe_prompt([question], style=nfcore_question_style)
answer = questionary.unsafe_prompt([question], style=nf_core.utils.nfcore_question_style)
return answer["use_web_gui"] == "Web based"

def launch_web_gui(self):
Expand Down Expand Up @@ -405,12 +384,12 @@ def prompt_param(self, param_id, param_obj, is_required, answers):

# Print the question
question = self.single_param_to_questionary(param_id, param_obj, answers)
answer = questionary.unsafe_prompt([question], style=nfcore_question_style)
answer = questionary.unsafe_prompt([question], style=nf_core.utils.nfcore_question_style)

# If required and got an empty reponse, ask again
while type(answer[param_id]) is str and answer[param_id].strip() == "" and is_required:
log.error("'–-{}' is required".format(param_id))
answer = questionary.unsafe_prompt([question], style=nfcore_question_style)
answer = questionary.unsafe_prompt([question], style=nf_core.utils.nfcore_question_style)

# Ignore if empty
if answer[param_id] == "":
Expand Down Expand Up @@ -480,7 +459,7 @@ def prompt_group(self, group_id, group_obj):
if len(question["choices"]) == 2:
return {}

answer = questionary.unsafe_prompt([question], style=nfcore_question_style)
answer = questionary.unsafe_prompt([question], style=nf_core.utils.nfcore_question_style)
if answer[group_id] == "Continue >>":
while_break = True
# Check if there are any required parameters that don't have answers
Expand Down
6 changes: 3 additions & 3 deletions nf_core/modules/pipeline_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
import json
import logging
import os
import prompt_toolkit
import questionary
import requests
import rich
import shutil
import sys

import nf_core.utils

log = logging.getLogger(__name__)


Expand Down Expand Up @@ -95,9 +96,8 @@ def install(self, module=None):
self.get_modules_file_tree()

if module is None:
nfcore_question_style = prompt_toolkit.styles.Style([("answer", "fg:ansigreen nobold bg:")])
module = questionary.autocomplete(
"Choose module", choices=self.modules_avail_module_names, style=nfcore_question_style
"Choose module", choices=self.modules_avail_module_names, style=nf_core.utils.nfcore_question_style
).ask()

log.info("Installing {}".format(module))
Expand Down
32 changes: 23 additions & 9 deletions nf_core/modules/test_yml_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
"""

from __future__ import print_function
from rich.console import Console
from rich.syntax import Syntax

import errno
import hashlib
import logging
import os
import re
import rich
import shlex
import subprocess
import tempfile
import yaml

import nf_core.utils
import questionary
import rich
import yaml
from rich.console import Console
from rich.syntax import Syntax

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -222,12 +223,25 @@ def run_tests_workflow(self, command):

# The config expects $PROFILE and Nextflow fails if it's not set
if os.environ.get("PROFILE") is None:
log.info(
"Setting env var '$PROFILE' to an empty string as not set.\n"
"Tests will run with Docker by default. "
"To use Singularity set 'export PROFILE=singularity' in your shell before running this command."
)
os.environ["PROFILE"] = ""
if self.no_prompts:
log.info(
"Setting env var '$PROFILE' to an empty string as not set.\n"
"Tests will run with Docker by default. "
"To use Singularity set 'export PROFILE=singularity' in your shell before running this command."
)
else:
question = {
"type": "list",
"name": "profile",
"message": "Choose software profile",
"choices": ["Docker", "Singularity", "Conda"],
}
answer = questionary.unsafe_prompt([question], style=nf_core.utils.nfcore_question_style)
profile = answer["profile"].lower()
if profile in ["singularity", "conda"]:
os.environ["PROFILE"] = profile
log.info(f"Setting env var '$PROFILE' to '{profile}'")

tmp_dir = tempfile.mkdtemp()
command += f" --outdir {tmp_dir}"
Expand Down
19 changes: 19 additions & 0 deletions nf_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import json
import logging
import os
import prompt_toolkit
import re
import requests
import requests_cache
Expand All @@ -25,6 +26,24 @@

log = logging.getLogger(__name__)

# Custom style for questionary
nfcore_question_style = prompt_toolkit.styles.Style(
[
("qmark", "fg:ansiblue bold"), # token in front of the question
("question", "bold"), # question text
("answer", "fg:ansigreen nobold"), # submitted answer text behind the question
("pointer", "fg:ansiyellow bold"), # pointer used in select and checkbox prompts
("highlighted", "fg:ansiblue bold"), # pointed-at choice in select and checkbox prompts
("selected", "fg:ansigreen noreverse"), # style for a selected item of a checkbox
("separator", "fg:ansiblack"), # separator in lists
("instruction", ""), # user instructions for select, rawselect, checkbox
("text", ""), # plain text
("disabled", "fg:gray italic"), # disabled choices for select and checkbox prompts
("choice-default", "fg:ansiblack"),
("choice-default-changed", "fg:ansiyellow"),
("choice-required", "fg:ansired"),
]
)

def check_if_outdated(current_version=None, remote_version=None, source_url="https://nf-co.re/tools_version"):
"""
Expand Down