BlueBrain / nexus-forge

Building and Using Knowledge Graphs made easy
https://nexus-forge.readthedocs.io
GNU Lesser General Public License v3.0
39 stars 19 forks source link

Getting `AttributeError: 'PathsWrapper' object has no attribute '_path' ` #235

Open mgeplf opened 2 years ago

mgeplf commented 2 years ago

Code from running: https://bbpgitlab.epfl.ch/molsys/bbp_me_type_to_mol_id/-/blob/main/downloader/BBP_downloader.py is causing the following exception:

Enter NEXUS token                                                                                                                                                                                                                                                               
seaching morphologies...                                                                                                                                
Traceback (most recent call last):                               
  File "BBP_downloader.py", line 23, in <module>                                                                                        
    path.annotation.hasBody.type == "MType",                                                                                                                                                                                                                                    
  File "/home/gevaert/src/nexus-forge/kgforge/core/wrappings/paths.py", line 70, in __eq__                                              
    return self._for(FilterOperator.EQUAL.value, other)                                                                                 
  File "/home/gevaert/src/nexus-forge/kgforge/core/wrappings/paths.py", line 82, in _for  
    return Filter(self._path, operator, other)                  
AttributeError: 'PathsWrapper' object has no attribute '_path'  

I believe it's because the __dict__ is being reset here: https://github.com/BlueBrain/nexus-forge/blob/master/kgforge/core/wrappings/paths.py#L94

mgeplf commented 2 years ago

We normally don't access/modify the __dict__ member, and I think it would be worthwhile to audit nexus-forge for usages of it.

MFSY commented 2 years ago

Hi @mgeplf ,

Thanks for reporting this. This is a known issue(#26). We'll look into it. We need to rework that part of the code. Meanwhile, you can use:

MFSY commented 2 years ago

Duplicate issue #26

mgeplf commented 2 years ago

Meanwhile, you can use:

I'm pretty sure it's due to overwriting the __dict__ member that is causing the problem. Updating it w/ self.__dict__.update(paths) (which I consider a bad idea, b/c I'm not checking what is all in paths) seems to fix the problem.