nipreps / sdcflows

Susceptibility Distortion Correction (SDC) workflows for EPI MR schemes
https://www.nipreps.org/sdcflows
Apache License 2.0
32 stars 26 forks source link

Unable to `pkg_resources.resource_filename` to locate data files #377

Closed oesteban closed 1 year ago

oesteban commented 1 year ago

What happened?

I'm unaware of what specific update has triggered this in my local computer, but it looks like we can't use resource_filename anymore. It could be related to the new namespace package (https://gitlab.com/python-devs/importlib_resources/-/issues/20) although I'm having this at the topup node of the pepolar workflow (trying to get a config file).

The error looks like https://gitlab.com/python-devs/importlib_resources/-/issues/68

Traceback (most recent call last):
  File "/home/oesteban/tmp/sdcflows-debugging/pipeline.py", line 33, in <module>
    step1 = estimator.get_workflow(omp_nthreads=12, debug=False)
  File "/data/home/oesteban/workspace/sdcflows/sdcflows/fieldmaps.py", line 463, in get_workflow
    self._wf = init_topup_wf(**kwargs)
  File "/data/home/oesteban/workspace/sdcflows/sdcflows/workflows/fit/pepolar.py", line 154, in init_topup_wf
    config=_pkg_fname("sdcflows", f"data/flirtsch/b02b0{'_quick' * sloppy}.cnf")
  File "/home/oesteban/.miniconda/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1154, in resource_filename
    return get_provider(package_or_requirement).get_resource_filename(
  File "/home/oesteban/.miniconda/lib/python3.9/site-packages/pkg_resources/__init__.py", line 361, in get_provider
    return _find_adapter(_provider_factories, loader)(module)
  File "/home/oesteban/.miniconda/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1403, in __init__
    self.module_path = os.path.dirname(getattr(module, '__file__', ''))
  File "/home/oesteban/.miniconda/lib/python3.9/posixpath.py", line 152, in dirname
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Re-installing in editable mode did not help.

What command did you use?

n/a

What version of the software are you running?

latest

How are you running this software?

Docker

Is your data BIDS valid?

Yes

Are you reusing any previously computed results?

No

Please copy and paste any relevant log output.

No response

Additional information / screenshots

No response

oesteban commented 1 year ago

seems like we should move into https://docs.python.org/3.8/library/importlib.html?highlight=importlib#module-importlib.resources