Thanks to visit codestin.com
Credit goes to github.com

Skip to content

UnboundLocalError: cannot access local variable 'docker_image_name' where it is not associated with a value #2369

@pinin4fjords

Description

@pinin4fjords

Description of the bug

For specific tools, module creation fails with the cryptic error below. A container for the tool appears to exist as it should in quay.io

Command used and terminal output

$ nf-core modules create --empty-template simpleaf/quant


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

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



INFO     Repository type: modules                                                                                                                               
INFO     Press enter to use default values (shown in brackets) or type your own responses. ctrl+click underlined text to open links.                            
INFO     Using Bioconda package: 'bioconda::simpleaf=0.14.1'                                                                                                    
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/pinin4fjords/miniconda3/envs/nextflow/bin/nf-core:10 in <module>                          │
│                                                                                                  │
│    7 from nf_core.__main__ import run_nf_core                                                    │
│    8 if __name__ == '__main__':                                                                  │
│    9 │   sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])                        │
│ ❱ 10 │   sys.exit(run_nf_core())                                                                 │
│   11                                                                                             │
│                                                                                                  │
│ /Users/pinin4fjords/miniconda3/envs/nextflow/lib/python3.11/site-packages/nf_core/__main__.py:11 │
│ 0 in run_nf_core                                                                                 │
│                                                                                                  │
│    107 │   │   │   log.debug(f"Could not check latest version: {e}")                             │
│    108 │   │   stderr.print("\n")                                                                │
│    109 │   # Launch the click cli                                                                │
│ ❱  110 │   nf_core_cli(auto_envvar_prefix="NFCORE")                                              │
│    111                                                                                           │
│    112                                                                                           │
│    113 @click.group(context_settings=dict(help_option_names=["-h", "--help"]))                   │
│                                                                                                  │
│ /Users/pinin4fjords/miniconda3/envs/nextflow/lib/python3.11/site-packages/click/core.py:1130 in  │
│ __call__                                                                                         │
│                                                                                                  │
│   1127 │                                                                                         │
│   1128 │   def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Any:                           │
│   1129 │   │   """Alias for :meth:`main`."""                                                     │
│ ❱ 1130 │   │   return self.main(*args, **kwargs)                                                 │
│   1131                                                                                           │
│   1132                                                                                           │
│   1133 class Command(BaseCommand):                                                               │
│                                                                                                  │
│ /Users/pinin4fjords/miniconda3/envs/nextflow/lib/python3.11/site-packages/rich_click/rich_group. │
│ py:21 in main                                                                                    │
│                                                                                                  │
│   18 │                                                                                           │
│   19 │   def main(self, *args, standalone_mode: bool = True, **kwargs):                          │
│   20 │   │   try:                                                                                │
│ ❱ 21 │   │   │   rv = super().main(*args, standalone_mode=False, **kwargs)                       │
│   22 │   │   │   if not standalone_mode:                                                         │
│   23 │   │   │   │   return rv                                                                   │
│   24 │   │   except click.ClickException as e:                                                   │
│                                                                                                  │
│ /Users/pinin4fjords/miniconda3/envs/nextflow/lib/python3.11/site-packages/click/core.py:1055 in  │
│ main                                                                                             │
│                                                                                                  │
│   1052 │   │   try:                                                                              │
│   1053 │   │   │   try:                                                                          │
│   1054 │   │   │   │   with self.make_context(prog_name, args, **extra) as ctx:                  │
│ ❱ 1055 │   │   │   │   │   rv = self.invoke(ctx)                                                 │
│   1056 │   │   │   │   │   if not standalone_mode:                                               │
│   1057 │   │   │   │   │   │   return rv                                                         │
│   1058 │   │   │   │   │   # it's not safe to `ctx.exit(rv)` here!                               │
│                                                                                                  │
│ /Users/pinin4fjords/miniconda3/envs/nextflow/lib/python3.11/site-packages/click/core.py:1657 in  │
│ invoke                                                                                           │
│                                                                                                  │
│   1654 │   │   │   │   super().invoke(ctx)                                                       │
│   1655 │   │   │   │   sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)                    │
│   1656 │   │   │   │   with sub_ctx:                                                             │
│ ❱ 1657 │   │   │   │   │   return _process_result(sub_ctx.command.invoke(sub_ctx))               │
│   1658 │   │                                                                                     │
│   1659 │   │   # In chain mode we create the contexts step by step, but after the                │
│   1660 │   │   # base command has been invoked.  Because at that point we do not                 │
│                                                                                                  │
│ /Users/pinin4fjords/miniconda3/envs/nextflow/lib/python3.11/site-packages/click/core.py:1657 in  │
│ invoke                                                                                           │
│                                                                                                  │
│   1654 │   │   │   │   super().invoke(ctx)                                                       │
│   1655 │   │   │   │   sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)                    │
│   1656 │   │   │   │   with sub_ctx:                                                             │
│ ❱ 1657 │   │   │   │   │   return _process_result(sub_ctx.command.invoke(sub_ctx))               │
│   1658 │   │                                                                                     │
│   1659 │   │   # In chain mode we create the contexts step by step, but after the                │
│   1660 │   │   # base command has been invoked.  Because at that point we do not                 │
│                                                                                                  │
│ /Users/pinin4fjords/miniconda3/envs/nextflow/lib/python3.11/site-packages/click/core.py:1404 in  │
│ invoke                                                                                           │
│                                                                                                  │
│   1401 │   │   │   echo(style(message, fg="red"), err=True)                                      │
│   1402 │   │                                                                                     │
│   1403 │   │   if self.callback is not None:                                                     │
│ ❱ 1404 │   │   │   return ctx.invoke(self.callback, **ctx.params)                                │
│   1405 │                                                                                         │
│   1406 │   def shell_complete(self, ctx: Context, incomplete: str) -> t.List["CompletionItem"]:  │
│   1407 │   │   """Return a list of completions for the incomplete value. Looks                   │
│                                                                                                  │
│ /Users/pinin4fjords/miniconda3/envs/nextflow/lib/python3.11/site-packages/click/core.py:760 in   │
│ invoke                                                                                           │
│                                                                                                  │
│    757 │   │                                                                                     │
│    758 │   │   with augment_usage_errors(__self):                                                │
│    759 │   │   │   with ctx:                                                                     │
│ ❱  760 │   │   │   │   return __callback(*args, **kwargs)                                        │
│    761 │                                                                                         │
│    762 │   def forward(                                                                          │
│    763 │   │   __self, __cmd: "Command", *args: t.Any, **kwargs: t.Any  # noqa: B902             │
│                                                                                                  │
│ /Users/pinin4fjords/miniconda3/envs/nextflow/lib/python3.11/site-packages/click/decorators.py:26 │
│ in new_func                                                                                      │
│                                                                                                  │
│    23 │   """                                                                                    │
│    24 │                                                                                          │
│    25 │   def new_func(*args, **kwargs):  # type: ignore                                         │
│ ❱  26 │   │   return f(get_current_context(), *args, **kwargs)                                   │
│    27 │                                                                                          │
│    28 │   return update_wrapper(t.cast(F, new_func), f)                                          │
│    29                                                                                            │
│                                                                                                  │
│ /Users/pinin4fjords/miniconda3/envs/nextflow/lib/python3.11/site-packages/nf_core/__main__.py:80 │
│ 0 in create_module                                                                               │
│                                                                                                  │
│    797 │   │   module_create = ModuleCreate(                                                     │
│    798 │   │   │   dir, tool, author, label, has_meta, force, conda_name, conda_package_version  │
│    799 │   │   )                                                                                 │
│ ❱  800 │   │   module_create.create()                                                            │
│    801 │   except UserWarning as e:                                                              │
│    802 │   │   log.critical(e)                                                                   │
│    803 │   │   sys.exit(1)                                                                       │
│                                                                                                  │
│ /Users/pinin4fjords/miniconda3/envs/nextflow/lib/python3.11/site-packages/nf_core/components/cre │
│ ate.py:139 in create                                                                             │
│                                                                                                  │
│   136 │   │                                                                                      │
│   137 │   │   if self.component_type == "modules":                                               │
│   138 │   │   │   # Try to find a bioconda package for 'component'                               │
│ ❱ 139 │   │   │   self._get_bioconda_tool()                                                      │
│   140 │   │                                                                                      │
│   141 │   │   # Prompt for GitHub username                                                       │
│   142 │   │   self._get_username()                                                               │
│                                                                                                  │
│ /Users/pinin4fjords/miniconda3/envs/nextflow/lib/python3.11/site-packages/nf_core/components/cre │
│ ate.py:227 in _get_bioconda_tool                                                                 │
│                                                                                                  │
│   224 │   │   │   │   │   │   self.tool_conda_name, version                                      │
│   225 │   │   │   │   │   )                                                                      │
│   226 │   │   │   │   else:                                                                      │
│ ❱ 227 │   │   │   │   │   self.docker_container, self.singularity_container = nf_core.utils.ge   │
│   228 │   │   │   │   │   │   self.component, version                                            │
│   229 │   │   │   │   │   )                                                                      │
│   230 │   │   │   │   log.info(f"Using Docker container: '{self.docker_container}'")             │
│                                                                                                  │
│ /Users/pinin4fjords/miniconda3/envs/nextflow/lib/python3.11/site-packages/nf_core/utils.py:744   │
│ in get_biocontainer_tag                                                                          │
│                                                                                                  │
│    741 │   │   │   │   │   │   singularity_image = all_singularity[k]["image"]                   │
│    742 │   │   │   │   │   │   current_date = date                                               │
│    743 │   │   │   │   │   │   docker_image_name = docker_image["image_name"].lstrip("quay.io/"  │
│ ❱  744 │   │   │   │   return docker_image_name, singularity_image["image_name"]                 │
│    745 │   │   │   except TypeError:                                                             │
│    746 │   │   │   │   raise LookupError(f"Could not find docker or singularity container for {  │
│    747 │   │   elif response.status_code != 404:                                                 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
UnboundLocalError: cannot access local variable 'docker_image_name' where it is not associated with a value

System information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions