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

AttributeError with nf-core pipelines create-params-file #3434

Closed
matbonfanti opened this issue Jan 30, 2025 · 1 comment
Closed

AttributeError with nf-core pipelines create-params-file #3434

matbonfanti opened this issue Jan 30, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@matbonfanti
Copy link

Description of the bug

When running the command nf-core pipelines create-params-file, and AttributeError exception is raised because inside the function write_params_file() (method of ParamsFileBuilder) the first argument is assumed to be a Path object, instead it is passed a variable that is a string with the name of the output parameter file.

Command used and terminal output

$ nf-core pipelines create-params-file -x --force --output ./nf-params.yml  nf-core/sarek

---


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

    nf-core/tools version 3.3.0.dev0 - https://nf-co.re


INFO     Downloading workflow: nf-core/sarek (None)
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/matteo/miniconda3/envs/nfcore-tools-dev/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/matteo/source/nfcore-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/matteo/miniconda3/envs/nfcore-tools-dev/lib/python3.12/site-packages/rich_click/rich_comma │
│ nd.py:367 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/matteo/miniconda3/envs/nfcore-tools-dev/lib/python3.12/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/matteo/miniconda3/envs/nfcore-tools-dev/lib/python3.12/site-packages/rich_click/rich_comma │
│ nd.py:152 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/matteo/miniconda3/envs/nfcore-tools-dev/lib/python3.12/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/matteo/miniconda3/envs/nfcore-tools-dev/lib/python3.12/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/matteo/miniconda3/envs/nfcore-tools-dev/lib/python3.12/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/matteo/miniconda3/envs/nfcore-tools-dev/lib/python3.12/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/matteo/miniconda3/envs/nfcore-tools-dev/lib/python3.12/site-packages/click/decorators.py:3 │
│ 3 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/matteo/source/nfcore-tools/nf_core/__main__.py:486 in command_pipelines_create_params_file │
│                                                                                                  │
│    483 │   """                                                                                   │
│    484 │   Build a parameter file for a pipeline.                                                │
│    485 │   """                                                                                   │
│ ❱  486 │   pipelines_create_params_file(ctx, pipeline, revision, output, force, show_hidden)     │
│    487                                                                                           │
│    488                                                                                           │
│    489 # nf-core pipelines launch                                                                │
│                                                                                                  │
│ /home/matteo/source/nfcore-tools/nf_core/commands_pipelines.py:221 in                            │
│ pipelines_create_params_file                                                                     │
│                                                                                                  │
│   218 │   """                                                                                    │
│   219 │   builder = ParamsFileBuilder(pipeline, revision)                                        │
│   220 │                                                                                          │
│ ❱ 221 │   if not builder.write_params_file(output, show_hidden=show_hidden, force=force):        │
│   222 │   │   sys.exit(1)                                                                        │
│   223                                                                                            │
│   224                                                                                            │
│                                                                                                  │
│ /home/matteo/source/nfcore-tools/nf_core/pipelines/params_file.py:282 in write_params_file       │
│                                                                                                  │
│   279 │   │                                                                                      │
│   280 │   │   schema_out = self.generate_params_file(show_hidden=show_hidden)                    │
│   281 │   │                                                                                      │
│ ❱ 282 │   │   if output_fn.exists() and not force:                                               │
│   283 │   │   │   log.error(f"File '{output_fn}' exists! Please delete first, or use '--force'   │
│   284 │   │   │   return False                                                                   │
│   285 │   │   output_fn.write_text(schema_out)                                                   │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'str' object has no attribute 'exists'

System information

  • nextflow 24.10.4
  • laptop
  • local executor
  • linux WSL2 (Ubuntu 20.04.6 LTS) on Windows
  • nf-core/tools version 3.2.0 and development version f332e85 (tried both)
  • python 3.12.8 and 3.9.15 (tried both)
@matbonfanti matbonfanti added the bug Something isn't working label Jan 30, 2025
@matbonfanti
Copy link
Author

Bug has been fixed by PR #3435, create-params-file works with the current devel version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant