xgrg / pyxnat

XNAT in Python
https://pyxnat.github.io/pyxnat
Other
0 stars 0 forks source link

Cannot fetch resource attributes #1

Open jhuguetn opened 5 years ago

jhuguetn commented 5 years ago

EAttrs(object) does not seem to work at fetching attributes from (any) derived EObject via self.attrs() method.

Error stack trace:

In [193]: c = pyxnat.Interface(config='.xnat.cfg')
In [194]: p = c.select.project(ID='ACME')
In [195]: s = p.subject(ID='BBRC_S02010')
In [196]: e = s.experiment(ID='BBRC_E02424')
In [197]: e.attrs()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-197-28e5d4173ac2> in <module>()
----> 1 e.attrs()

...\continuum\anaconda2\envs\pyxnat\lib\site-packages\pyxnat\core\attributes.pyc in __call__(self)
     42         """
     43         paths = []
---> 44         self._intf.manage.schemas._init()
     45         for root in self._intf.manage.schemas._trees.values():
     46             paths.extend(datatype_attributes(root, self._get_datatype()))

AttributeError: 'SchemaManager' object has no attribute '_init'

In [198]: s.attrs()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-198-04475fa7c078> in <module>()
----> 1 s.attrs()

...\continuum\anaconda2\envs\pyxnat\lib\site-packages\pyxnat\core\attributes.pyc in __call__(self)
     42         """
     43         paths = []
---> 44         self._intf.manage.schemas._init()
     45         for root in self._intf.manage.schemas._trees.values():
     46             paths.extend(datatype_attributes(root, self._get_datatype()))

AttributeError: 'SchemaManager' object has no attribute '_init'

In [199]: p.attrs()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-199-d41a1532ffb2> in <module>()
----> 1 p.attrs()

...\continuum\anaconda2\envs\pyxnat\lib\site-packages\pyxnat\core\attributes.pyc in __call__(self)
     42         """
     43         paths = []
---> 44         self._intf.manage.schemas._init()
     45         for root in self._intf.manage.schemas._trees.values():
     46             paths.extend(datatype_attributes(root, self._get_datatype()))

AttributeError: 'SchemaManager' object has no attribute '_init'
jhuguetn commented 5 years ago

Seems like, for attrs() method to work, an schema of current XNAT instance shall be provided to pyxnat via:

interface.manage.schemas.add('xapi/schemas/xnat')

However, the location of XNAT schemas (via REST API) has changed at some point between releases 1.6.X and 1.7.X of XNAT and pyxnat searches for the schema in a wrong location (when using version >=1.7). See SchemaManager code fragment: https://github.com/xgrg/pyxnat/blob/4866ccf273cc4332ee7acd0be1a40ce2ca4d2a19/pyxnat/core/manage.py#L120