nf-core / nf-core/tools

Better error message when user naively uses modules without having a pipeline

Open
#2,237 2 comments 2 reactions 1 assignee View on GitHub

@krokicki is already working on this.

Since Dec 11, 2023.

enhancement
Dominant language
Python
Stars
322
Forks
255
Avg merge
2d 3h
Merged PRs (30d)
5

Description

Description of feature

Dear nf-core maintainer,

Here I suggest a feature that would guide new users into using modules, by giving a better error message. I do volunteer to add it via a PR, as I am quite interested in Nexflow and nf-core. Here is the feature request:

When one asks the info of a specific module...

nf-core modules info raxmlng

One gets some useful output, even with an install command:

Installation command: nf-core modules install raxmlng

Up until now, it has been smooth sailing.

However, when naively running that install command, the user will get an unhelpful error (see full error below): `PermissionError: [Errno 13] Permission denied: '/.nf-core.yml'.

The real error is that the command nf-core modules install [some module] can only be run within an existing pipeline (e.g. a naive touch .nf-core.yml does not solve the problem). Therefore, I suggest the error message to become this instead:

Cannot find '.nf-core.yml'. 

Tip: a module must be installed as part of a pipeline. Use 'nf-core create' to start creating a pipeline'

Full error

(base) richel@richel-N141CU:~$ nf-core modules install raxmlng

                                          ,--./,-.
          ___     __   __   __   ___     /,-._.--~\
    |\ | |__  __ /  ` /  \ |__) |__         }  {
    | \| |       \__, \__/ |  \ |___     \`-._,-`-,
                                          `._,._,'

    nf-core/tools version 2.7.2 - https://nf-co.re/


WARNING  'repository_type' not defined in .nf-core.yml                                     
? Is this repository an nf-core pipeline or a fork of nf-core/modules? nf-core/modules
INFO     To avoid this prompt in the future, add the 'repository_type' key to your         
         .nf-core.yml file.                                                                
? Would you like me to add this config now? [y/n] (y): 
╭─────────────────────────── Traceback (most recent call last) ───────────────────────────╮
│ /home/richel/miniconda3/bin/nf-core:10 in <module>                                      │
│                                                                                         │
│    9 │   sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])               │
│ ❱ 10 │   sys.exit(run_nf_core())                                                        │
│   11                                                                                    │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/nf_core/__main__.py:105 in         │
│ run_nf_core                                                                             │
│                                                                                         │
│    104 │   # Launch the click cli                                                       │
│ ❱  105 │   nf_core_cli(auto_envvar_prefix="NFCORE")                                     │
│    106                                                                                  │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/click/core.py:1130 in __call__     │
│                                                                                         │
│   1129 │   │   """Alias for :meth:`main`."""                                            │
│ ❱ 1130 │   │   return self.main(*args, **kwargs)                                        │
│   1131                                                                                  │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/rich_click/rich_group.py:21 in     │
│ main                                                                                    │
│                                                                                         │
│   20 │   │   try:                                                                       │
│ ❱ 21 │   │   │   rv = super().main(*args, standalone_mode=False, **kwargs)              │
│   22 │   │   │   if not standalone_mode:                                                │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/click/core.py:1055 in main         │
│                                                                                         │
│   1054 │   │   │   │   with self.make_context(prog_name, args, **extra) as ctx:         │
│ ❱ 1055 │   │   │   │   │   rv = self.invoke(ctx)                                        │
│   1056 │   │   │   │   │   if not standalone_mode:                                      │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/click/core.py:1657 in invoke       │
│                                                                                         │
│   1656 │   │   │   │   with sub_ctx:                                                    │
│ ❱ 1657 │   │   │   │   │   return _process_result(sub_ctx.command.invoke(sub_ctx))      │
│   1658                                                                                  │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/click/core.py:1657 in invoke       │
│                                                                                         │
│   1656 │   │   │   │   with sub_ctx:                                                    │
│ ❱ 1657 │   │   │   │   │   return _process_result(sub_ctx.command.invoke(sub_ctx))      │
│   1658                                                                                  │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/click/core.py:1404 in invoke       │
│                                                                                         │
│   1403 │   │   if self.callback is not None:                                            │
│ ❱ 1404 │   │   │   return ctx.invoke(self.callback, **ctx.params)                       │
│   1405                                                                                  │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/click/core.py:760 in invoke        │
│                                                                                         │
│    759 │   │   │   with ctx:                                                            │
│ ❱  760 │   │   │   │   return __callback(*args, **kwargs)                               │
│    761                                                                                  │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/click/decorators.py:26 in new_func │
│                                                                                         │
│    25 │   def new_func(*args, **kwargs):  # type: ignore                                │
│ ❱  26 │   │   return f(get_current_context(), *args, **kwargs)                          │
│    27                                                                                   │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/nf_core/__main__.py:528 in install │
│                                                                                         │
│    527 │   try:                                                                         │
│ ❱  528 │   │   module_install = nf_core.modules.ModuleInstall(                          │
│    529 │   │   │   dir,                                                                 │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/nf_core/modules/install.py:16 in   │
│ __init__                                                                                │
│                                                                                         │
│   15 │   ):                                                                             │
│ ❱ 16 │   │   super().__init__(                                                          │
│   17 │   │   │   pipeline_dir,                                                          │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/nf_core/components/install.py:36   │
│ in __init__                                                                             │
│                                                                                         │
│    35 │   ):                                                                            │
│ ❱  36 │   │   super().__init__(component_type, pipeline_dir, remote_url, branch, no_pul │
│    37 │   │   self.force = force                                                        │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/nf_core/components/components_comm │
│ and.py:30 in __init__                                                                   │
│                                                                                         │
│    29 │   │   self.hide_progress = hide_progress                                        │
│ ❱  30 │   │   self._configure_repo_and_paths()                                          │
│    31                                                                                   │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/nf_core/components/components_comm │
│ and.py:42 in _configure_repo_and_paths                                                  │
│                                                                                         │
│    41 │   │   │   if self.dir:                                                          │
│ ❱  42 │   │   │   │   self.dir, self.repo_type, self.org = get_repo_info(self.dir,      │
│       use_prompt=nf_dir_req)                                                            │
│    43 │   │   │   else:                                                                 │
│                                                                                         │
│ /home/richel/miniconda3/lib/python3.10/site-packages/nf_core/components/components_util │
│ s.py:45 in get_repo_info                                                                │
│                                                                                         │
│    44 │   │   if rich.prompt.Confirm.ask("[bold][blue]?[/] Would you like me to add thi │
│       config now?", default=True):                                                      │
│ ❱  45 │   │   │   with open(config_fn, "a+") as fh:                                     │
│    46 │   │   │   │   fh.write(f"repository_type: {repo_type}\n")                       │
╰─────────────────────────────────────────────────────────────────────────────────────────╯
PermissionError: [Errno 13] Permission denied: '/.nf-core.yml'

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.