abinit / abipy

Open-source library for analyzing the results produced by ABINIT
http://abinit.github.io/abipy
Other
117 stars 96 forks source link

pinning the pymatgen version? #261

Closed unkcpz closed 1 year ago

unkcpz commented 1 year ago

Install the package directly will install pymatgen==2023.7.14 since the version is not pinned.

I got:

ValueError: Error occurred validating port 'inputs.metadata.options.parser_name': invalid parser specified: Failed to load entry point 'opsp.pseudo.oncv':                                                                                 
Traceback (most recent call last):                                                                                                                                                                                                         
  File "/opt/conda/lib/python3.9/site-packages/aiida/plugins/entry_point.py", line 237, in load_entry_point                                                                                                                                
    loaded_entry_point = entry_point.load()                                                                          
  File "/opt/conda/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 207, in load                                                                                                                                          
    module = import_module(match.group('module'))                                                                                                                                                                                          
  File "/opt/conda/lib/python3.9/importlib/__init__.py", line 127, in import_module                                                                                                                                                        
    return _bootstrap._gcd_import(name[level:], package, level)                                                                                                                                                                            
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import                                                                                                                                                                          
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load                                                                                                                                                                       
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked                                                                                                                                                               
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked                                                                                                                                                                        
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module                                                                                                                                                                  
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed                                                                                                                                                             
  File "/home/aiida/aiida-opsp/aiida_opsp/parser.py", line 8, in <module>                                                                                                                                                                  
    from abipy.ppcodes.oncv_parser import OncvParser                                                                                                                                                                                       
  File "/opt/conda/lib/python3.9/site-packages/abipy/__init__.py", line 18, in <module>                                                                                                                                                    
    from abipy.core import release                                                                                                                                                                                                         
  File "/opt/conda/lib/python3.9/site-packages/abipy/core/__init__.py", line 4, in <module>                                                                                                                                                
    from .structure import *                                                                                                                                                                                                               
  File "/opt/conda/lib/python3.9/site-packages/abipy/core/structure.py", line 27, in <module>                                                                                                                                              
    from abipy.flowtk import PseudoTable                                                                                                                                                                                                   
  File "/opt/conda/lib/python3.9/site-packages/abipy/flowtk/__init__.py", line 15, in <module>                                                                                                                                             
    from .tasks import *                                                                                                                                                                                                                   
  File "/opt/conda/lib/python3.9/site-packages/abipy/flowtk/tasks.py", line 37, in <module>                                                                                                                                                
    from .abitimer import AbinitTimerParser                                                                                                                                                                                                
  File "/opt/conda/lib/python3.9/site-packages/abipy/flowtk/abitimer.py", line 2, in <module>                                                                                                                                              
    from pymatgen.io.abinit.abitimer import AbinitTimerParserError, AbinitTimerParser, AbinitTimerSection                                                                                                                                  
ImportError: cannot import name 'AbinitTimerParserError' from 'pymatgen.io.abinit.abitimer' (/opt/conda/lib/python3.9/site-packages/pymatgen/io/abinit/abitimer.py)   
mbercx commented 1 year ago

This is related to the following change:

https://github.com/materialsproject/pymatgen/commit/5b88fc181d8ab97a7d1d3c47692cefdf673888c5

In the latest abipy version the import has been updated to fix this:

https://github.com/abinit/abipy/blob/d4dd68e000935a27fd9b4108f8ccacc7cc9cf96c/abipy/flowtk/abitimer.py#L1-L3

But if your environment still uses an older pymatgen version due to other package dependency restrictions, this will fail again, so I suggest an import based on the pymatgen version.

Pinning the pymatgen version is also not a good idea for this reason. I think if everyone starts pinning their pymatgen versions we're going to run into dependency resolution conflicts.

unkcpz commented 1 year ago

Thanks @mbercx, I think I have to not pinning pymatgen, but this means if they change the API in the future again, things break.

In the latest abipy version the import has been updated to fix this:

Yes, @gmatteo told me so. I'll close this.

mbercx commented 1 year ago

Thanks @mbercx, I think I have to not pinning pymatgen, but this means if they change the API in the future again, things break.

Yeah, I know... But if we pin it every package that uses it in the common workflows will have to pin it to the same version, else we can't install aiida-common-workflows at all. We could define a range and update the upper limit from time to time?