templateflow / python-client

A python client to query TemplateFlow via pyBIDS
https://templateflow.org/python-client/
Apache License 2.0
8 stars 12 forks source link

AttributeError: 'NoneType' object has no attribute 'get' #71

Closed oesteban closed 2 years ago

oesteban commented 2 years ago

Trying to check whether the new DiFuMo atlases are now available, I'm consistently hitting this:

In [1]: from templateflow import __version__

In [2]: __version__
Out[2]: '0.7.1'

In [3]: from templateflow.api import get

In [4]: get("MNI152NLin2009cAsym")
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-d25b4bf3eed1> in <module>
----> 1 get("MNI152NLin2009cAsym")

~/.anaconda/lib/python3.8/site-packages/templateflow/api.py in get(template, raise_empty, **kwargs)
     63     """
     64     out_file = [
---> 65         Path(p) for p in TF_LAYOUT.get(template=template, return_type="file", **kwargs)
     66     ]
     67

AttributeError: 'NoneType' object has no attribute 'get'

Happened with master, 0.7.1 and 0.6.3.

I'm sure it is a problem with my installation / have pip uninstalled and installed and I have deleted ~/.cache/templateflow.

We need to figure this one out ASAP, and also try to understand the extent to which this is happening.

BTW, the tests are broken, so this could easily have been masked by a failing (unrelated) test.

Before the release of fMRIPrep 21.0.0rc1 we need to have this one pinned down and towards a bugfix.

oesteban commented 2 years ago

Latest non-automated failing test https://app.circleci.com/pipelines/github/templateflow/python-client/1018/workflows/11bbb40a-c47d-4509-9dab-97c8e3f333a6/jobs/1456

oesteban commented 2 years ago

cc/ @effigies as this may complicate the rc1 release.

mgxd commented 2 years ago

my guess is something is going wrong when initializating your layout here

https://github.com/templateflow/python-client/blob/137218d01f5edc5c75092decda51e369fd4d3692/templateflow/conf/__init__.py#L89-L115

mgxd commented 2 years ago

I tried:

Cannot reproduce, so I assume this is something going on with your installation

oesteban commented 2 years ago

Yes, found it - I have miniconda, and then pip installed pybids. The problem is that pip didn't seem to correctly install sqlalchemy correctly. Only after installing it through conda it worked.

We need to change that try .. catch, or at the very least make it more specific to only pybids. One solution would be to import bids again inside get() and get_templates().