Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.7 (and 3.8?) not supported #699

Open
MicPellegrino opened this issue Nov 15, 2024 · 8 comments
Open

Python 3.7 (and 3.8?) not supported #699

MicPellegrino opened this issue Nov 15, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@MicPellegrino
Copy link

Describe the bug
I cannot load the mace_mp calculator by running from mace.calculators import mace_mp.
I'm getting:

Python 3.7.4 (default, Jun 18 2023, 14:26:56) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mace
>>> from mace.calculators import mace_mp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/mace/calculators/__init__.py", line 1, in <module>
    from .foundations_models import mace_anicc, mace_mp, mace_off
  File "/usr/local/lib/python3.7/site-packages/mace/calculators/foundations_models.py", line 10, in <module>
    from .mace import MACECalculator
  File "/usr/local/lib/python3.7/site-packages/mace/calculators/mace.py", line 35, in <module>
    class MACECalculator(Calculator):
  File "/usr/local/lib/python3.7/site-packages/mace/calculators/mace.py", line 62, in MACECalculator
    fullgraph=True,
TypeError: 'type' object is not subscriptable
>>>

To Reproduce
Run from mace.calculators import mace_mp in Python3.7 (which should be compatible according to https://pypi.org/project/mace-torch/)

Desktop (please complete the following information):

  • OS: Ubuntu20, running either via terminal or jupyter notebook
@ilyes319
Copy link
Contributor

update to 3.8 or later, we are going to drop 3.7 support probably, I ll update the setup

@ilyes319 ilyes319 changed the title Cannot load mace_mp calculator Python 3.7 not supported Nov 18, 2024
@MicPellegrino
Copy link
Author

I see, thank you.

@MicPellegrino
Copy link
Author

MicPellegrino commented Nov 18, 2024

Hi,
I don't think it's python version problem: I tried building a virtual environment with Python 3.8 and I still get the error.
On Jupyter:

!python --version

Python 3.8.0
from mace.calculators import mace_mp

TypeError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 from mace.calculators import mace_mp

File ~/mambaforge/envs/workflow-hea/lib/python3.8/site-packages/mace/calculators/__init__.py:1
----> 1 from .foundations_models import mace_anicc, mace_mp, mace_off
      2 from .lammps_mace import LAMMPS_MACE
      3 from .mace import MACECalculator

File ~/mambaforge/envs/workflow-hea/lib/python3.8/site-packages/mace/calculators/foundations_models.py:10
      7 from ase import units
      8 from ase.calculators.mixing import SumCalculator
---> 10 from .mace import MACECalculator
     12 module_dir = os.path.dirname(__file__)
     13 local_model_path = os.path.join(
     14     module_dir, "foundations_models/2023-12-03-mace-mp.model"
     15 )

File ~/mambaforge/envs/workflow-hea/lib/python3.8/site-packages/mace/calculators/mace.py:35
     31         return "float32"
     32     raise ValueError(f"Unknown dtype {mode_dtype}")
---> 35 class MACECalculator(Calculator):
     36     """MACE ASE Calculator
     37     args:
     38         model_paths: str, path to model or models if a committee is produced
   (...)
     48     Dipoles are returned in units of Debye
     49     """
     51     def __init__(
     52         self,
     53         model_paths: Union[list, str, None] = None,
   (...)
     63         **kwargs,
     64     ):

File ~/mambaforge/envs/workflow-hea/lib/python3.8/site-packages/mace/calculators/mace.py:54, in MACECalculator()
     35 class MACECalculator(Calculator):
     36     """MACE ASE Calculator
     37     args:
     38         model_paths: str, path to model or models if a committee is produced
   (...)
     48     Dipoles are returned in units of Debye
     49     """
     51     def __init__(
     52         self,
     53         model_paths: Union[list, str, None] = None,
---> 54         models: Union[list[torch.nn.Module], torch.nn.Module, None] = None,
     55         device: str = "cpu",
     56         energy_units_to_eV: float = 1.0,
     57         length_units_to_A: float = 1.0,
     58         default_dtype="",
     59         charges_key="Qs",
     60         model_type="MACE",
     61         compile_mode=None,
     62         fullgraph=True,
     63         **kwargs,
     64     ):
     65         Calculator.__init__(self, **kwargs)
     67         if "model_path" in kwargs:

TypeError: 'type' object is not subscriptable

@MicPellegrino MicPellegrino changed the title Python 3.7 not supported Python 3.7 (and 3.8?) not supported Nov 18, 2024
@ilyes319
Copy link
Contributor

try 3.10?

@MicPellegrino
Copy link
Author

MicPellegrino commented Nov 18, 2024

Could it be that some pytorch requirement is missing instead?

@ilyes319
Copy link
Contributor

no I don't think so, I know the bug, it is the use of list instead of the typing List... I know that this works for 3.10 and later, not sure if it works for 3.9.

@MicPellegrino
Copy link
Author

Ok, it worked by specifying python>=3.10 in the environment .yml file (got Python 3.12.7).

@CompRhys
Copy link
Contributor

#537 (comment) the list List issue can be resolved with this future import (which in the ruff PR linked was added as an automatic fix).

@ilyes319 ilyes319 added the bug Something isn't working label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants