Skip to content

Conversation

@effigies
Copy link
Contributor

Currently:

❯ uvx templateflow get MNI152NLin6Asym --res 2 --desc LR -s T1w
Traceback (most recent call last):
  File "/home/chris/.cache/uv/archive-v0/N20Na8Y61YObB3kT5W_Jk/bin/templateflow", line 10, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/chris/.cache/uv/archive-v0/N20Na8Y61YObB3kT5W_Jk/lib/python3.13/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/chris/.cache/uv/archive-v0/N20Na8Y61YObB3kT5W_Jk/lib/python3.13/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/chris/.cache/uv/archive-v0/N20Na8Y61YObB3kT5W_Jk/lib/python3.13/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/chris/.cache/uv/archive-v0/N20Na8Y61YObB3kT5W_Jk/lib/python3.13/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chris/.cache/uv/archive-v0/N20Na8Y61YObB3kT5W_Jk/lib/python3.13/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/chris/.cache/uv/archive-v0/N20Na8Y61YObB3kT5W_Jk/lib/python3.13/site-packages/templateflow/cli.py", line 144, in get
    click.echo('\n'.join(f'{match}' for match in api.get(template, **entities)))
                                                 ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'PosixPath' object is not iterable

@effigies effigies force-pushed the fix/get_one branch 2 times, most recently from 8831981 to 389a442 Compare August 11, 2025 18:56
@effigies
Copy link
Contributor Author

Rebased onto #143 to fix tests.

@effigies
Copy link
Contributor Author

Given that the only failing test was unrelated and this was here for 8 months without objection, merging by lazy consensus after CI finishes unless someone wants to have a quick look.

Copy link
Contributor

@mgxd mgxd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few suggestions, looks good as is

click.echo('\n'.join(f'{match}' for match in api.get(template, **entities)))
paths = api.get(template, **entities)
filenames = [str(paths)] if isinstance(paths, Path) else [str(file) for file in paths]
click.echo('\n'.join(filenames))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps past the reach of this PR - but it would be nice to print out a more helpful message with empty lists, i.e.

Suggested change
click.echo('\n'.join(filenames))
if not filenames:
click.echo('No files found.')
return
click.echo('\n'.join(filenames))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One currently useful feature is that the output is filenames. Helpful messages on stderr are fine, but I wouldn't want to change the utility of stdout to bash scripts.

Fine for another PR, but I don't want to scope creep this one.

@mgxd mgxd merged commit 6c7f5b3 into templateflow:master Aug 12, 2025
14 checks passed
@effigies effigies deleted the fix/get_one branch August 12, 2025 16:08
effigies added a commit that referenced this pull request Aug 12, 2025
25.0.0 (August 12, 2025)

Minor release including updated templates.

* FIX: Fix crash in templateflow get when matching one file (#140)
* MAINT: Update Python support, datalad and git-annex deps (#143)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants