Skip to content

Bump versions failing #3382

@dialvarezs

Description

@dialvarezs

Description of the bug

In 3.1.0 and 3.1.1 there is the following error when trying to bump versions:

NotADirectoryError: [Errno 20] Not a directory: 'modules/nf-core/cellranger/.gitignore/main.nf'

It seems that this is because some tools have files within their module directories, but the code does not verify whether the directory contents are files or subdirectories.

m_content = os.listdir(os.path.join(nfcore_modules_dir, m))
# Not a module, but contains sub-modules
if "main.nf" not in m_content:
for tool in m_content:
nfcore_modules_names.append(os.path.join(m, tool))

Command used and terminal output

$ nf-core modules bump-versions csvtk/concat
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/dxh/others/nf-core-modules/../nf-core-tools/.venv/bin/nf-core:8 in <module>                │
│                                                                                                  │
│   5 from nf_core.__main__ import run_nf_core                                                     │
│   6 if __name__ == "__main__":                                                                   │
│   7 │   sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])                         │
│ ❱ 8 │   sys.exit(run_nf_core())                                                                  │
│   9                                                                                              │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/nf_core/__main__.py:182 in run_nf_core                            │
│                                                                                                  │
│    179 │   │   │   log.debug(f"Could not check latest version: {e}")                             │
│    180 │   │   stderr.print("\n")                                                                │
│    181 │   # Launch the click cli                                                                │
│ ❱  182 │   nf_core_cli(auto_envvar_prefix="NFCORE")                                              │
│    183                                                                                           │
│    184                                                                                           │
│    185 @tui(                                                                                     │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/.venv/lib64/python3.11/site-packages/rich_click/rich_command.py:3 │
│ 67 in __call__                                                                                   │
│                                                                                                  │
│   364 │   │   # Include this here because I run into a false warning                             │
│   365 │   │   # in the PyCharm IDE otherwise; for some reason PyCharm doesn't                    │
│   366 │   │   # seem to think RichGroups are callable. (No issues with Mypy, though.)            │
│ ❱ 367 │   │   return super().__call__(*args, **kwargs)                                           │
│   368                                                                                            │
│   369                                                                                            │
│   370 class RichCommandCollection(CommandCollection, RichGroup):                                 │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/.venv/lib64/python3.11/site-packages/click/core.py:1161 in        │
│ __call__                                                                                         │
│                                                                                                  │
│   1158 │                                                                                         │
│   1159 │   def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Any:                           │
│   1160 │   │   """Alias for :meth:`main`."""                                                     │
│ ❱ 1161 │   │   return self.main(*args, **kwargs)                                                 │
│   1162                                                                                           │
│   1163                                                                                           │
│   1164 class Command(BaseCommand):                                                               │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/.venv/lib64/python3.11/site-packages/rich_click/rich_command.py:1 │
│ 52 in main                                                                                       │
│                                                                                                  │
│   149 │   │   try:                                                                               │
│   150 │   │   │   try:                                                                           │
│   151 │   │   │   │   with self.make_context(prog_name, args, **extra) as ctx:                   │
│ ❱ 152 │   │   │   │   │   rv = self.invoke(ctx)                                                  │
│   153 │   │   │   │   │   if not standalone_mode:                                                │
│   154 │   │   │   │   │   │   return rv                                                          │
│   155 │   │   │   │   │   # it's not safe to `ctx.exit(rv)` here!                                │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/.venv/lib64/python3.11/site-packages/click/core.py:1697 in invoke │
│                                                                                                  │
│   1694 │   │   │   │   super().invoke(ctx)                                                       │
│   1695 │   │   │   │   sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)                    │
│   1696 │   │   │   │   with sub_ctx:                                                             │
│ ❱ 1697 │   │   │   │   │   return _process_result(sub_ctx.command.invoke(sub_ctx))               │
│   1698 │   │                                                                                     │
│   1699 │   │   # In chain mode we create the contexts step by step, but after the                │
│   1700 │   │   # base command has been invoked.  Because at that point we do not                 │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/.venv/lib64/python3.11/site-packages/click/core.py:1697 in invoke │
│                                                                                                  │
│   1694 │   │   │   │   super().invoke(ctx)                                                       │
│   1695 │   │   │   │   sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)                    │
│   1696 │   │   │   │   with sub_ctx:                                                             │
│ ❱ 1697 │   │   │   │   │   return _process_result(sub_ctx.command.invoke(sub_ctx))               │
│   1698 │   │                                                                                     │
│   1699 │   │   # In chain mode we create the contexts step by step, but after the                │
│   1700 │   │   # base command has been invoked.  Because at that point we do not                 │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/.venv/lib64/python3.11/site-packages/click/core.py:1443 in invoke │
│                                                                                                  │
│   1440 │   │   │   echo(style(message, fg="red"), err=True)                                      │
│   1441 │   │                                                                                     │
│   1442 │   │   if self.callback is not None:                                                     │
│ ❱ 1443 │   │   │   return ctx.invoke(self.callback, **ctx.params)                                │
│   1444 │                                                                                         │
│   1445 │   def shell_complete(self, ctx: Context, incomplete: str) -> t.List["CompletionItem"]:  │
│   1446 │   │   """Return a list of completions for the incomplete value. Looks                   │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/.venv/lib64/python3.11/site-packages/click/core.py:788 in invoke  │
│                                                                                                  │
│    785 │   │                                                                                     │
│    786 │   │   with augment_usage_errors(__self):                                                │
│    787 │   │   │   with ctx:                                                                     │
│ ❱  788 │   │   │   │   return __callback(*args, **kwargs)                                        │
│    789 │                                                                                         │
│    790 │   def forward(__self, __cmd: "Command", *args: t.Any, **kwargs: t.Any) -> t.Any:        │
│    791 │   │   """Similar to :meth:`invoke` but fills in default keyword                         │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/.venv/lib64/python3.11/site-packages/click/decorators.py:33 in    │
│ new_func                                                                                         │
│                                                                                                  │
│    30 │   """                                                                                    │
│    31 │                                                                                          │
│    32 │   def new_func(*args: "P.args", **kwargs: "P.kwargs") -> "R":                            │
│ ❱  33 │   │   return f(get_current_context(), *args, **kwargs)                                   │
│    34 │                                                                                          │
│    35 │   return update_wrapper(new_func, f)                                                     │
│    36                                                                                            │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/nf_core/__main__.py:1340 in command_modules_bump_versions         │
│                                                                                                  │
│   1337 │   Bump versions for one or more modules in a clone of                                   │
│   1338 │   the nf-core/modules repo.                                                             │
│   1339 │   """                                                                                   │
│ ❱ 1340 │   modules_bump_versions(ctx, tool, directory, all, show_all)                            │
│   1341                                                                                           │
│   1342                                                                                           │
│   1343 # nf-core subworkflows click command                                                      │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/nf_core/commands_modules.py:352 in modules_bump_versions          │
│                                                                                                  │
│   349 │   │   │   ctx.obj["modules_repo_branch"],                                                │
│   350 │   │   │   ctx.obj["modules_repo_no_pull"],                                               │
│   351 │   │   )                                                                                  │
│ ❱ 352 │   │   version_bumper.bump_versions(module=tool, all_modules=all, show_uptodate=show_al   │
│   353 │   except ModuleExceptionError as e:                                                      │
│   354 │   │   log.error(e)                                                                       │
│   355 │   │   sys.exit(1)                                                                        │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/nf_core/modules/bump_versions.py:79 in bump_versions              │
│                                                                                                  │
│    76 │   │   │   )                                                                              │
│    77 │   │                                                                                      │
│    78 │   │   # Get list of all modules                                                          │
│ ❱  79 │   │   _, nfcore_modules = nf_core.modules.modules_utils.get_installed_modules(self.dir   │
│    80 │   │                                                                                      │
│    81 │   │   # Load the .nf-core.yml config                                                     │
│    82 │   │   _, self.tools_config = nf_core.utils.load_tools_config(self.directory)             │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/nf_core/modules/modules_utils.py:87 in get_installed_modules      │
│                                                                                                  │
│    84 │   if local_modules_dir:                                                                  │
│    85 │   │   local_modules = [os.path.join(local_modules_dir, m) for m in local_modules]        │
│    86 │                                                                                          │
│ ❱  87 │   nfcore_modules = [                                                                     │
│    88 │   │   NFCoreComponent(                                                                   │
│    89 │   │   │   m,                                                                             │
│    90 │   │   │   "nf-core/modules",                                                             │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/nf_core/modules/modules_utils.py:88 in <listcomp>                 │
│                                                                                                  │
│    85 │   │   local_modules = [os.path.join(local_modules_dir, m) for m in local_modules]        │
│    86 │                                                                                          │
│    87 │   nfcore_modules = [                                                                     │
│ ❱  88 │   │   NFCoreComponent(                                                                   │
│    89 │   │   │   m,                                                                             │
│    90 │   │   │   "nf-core/modules",                                                             │
│    91 │   │   │   Path(nfcore_modules_dir, m),                                                   │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/nf_core/components/nfcore_component.py:98 in __init__             │
│                                                                                                  │
│    95 │   │   │   self.test_yml = None                                                           │
│    96 │   │   │   self.test_main_nf = None                                                       │
│    97 │   │                                                                                      │
│ ❱  98 │   │   self.process_name: str = self._get_process_name()                                  │
│    99 │                                                                                          │
│   100 │   def __repr__(self) -> str:                                                             │
│   101 │   │   return f"<NFCoreComponent {self.component_name} {self.component_dir} {self.repo_   │
│                                                                                                  │
│ /home/dxh/others/nf-core-tools/nf_core/components/nfcore_component.py:174 in _get_process_name   │
│                                                                                                  │
│   171 │   │   return included_components                                                         │
│   172 │                                                                                          │
│   173 │   def _get_process_name(self):                                                           │
│ ❱ 174 │   │   with open(self.main_nf) as fh:                                                     │
│   175 │   │   │   for line in fh:                                                                │
│   176 │   │   │   │   if re.search(r"^\s*process\s*\w*\s*{", line):                              │
│   177 │   │   │   │   │   return re.search(r"^\s*process\s*(\w*)\s*{.*", line).group(1) or ""    │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
NotADirectoryError: [Errno 20] Not a directory: 'modules/nf-core/cellranger/.gitignore/main.nf'

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