atomate2 icon indicating copy to clipboard operation
atomate2 copied to clipboard

BUG: `RecursionError` with `VaspMaker.input_set_generator.get_input_set`

Open Andrew-S-Rosen opened this issue 1 year ago • 0 comments

In atomtate2 0.0.14 and pymatgen 2024.5.1, a RecursionError is raised when trying to access .as_dict() or non-existent attributes of VaspMaker.input_set_generator.get_input_set.

from atomate2.vasp.jobs.mp import MPGGARelaxMaker
from pymatgen.core import Structure

s = Structure(
    lattice=[[0, 2.13, 2.13], [2.13, 0, 2.13], [2.13, 2.13, 0]],
    species=["Mg", "O"],
    coords=[[0, 0, 0], [0.5, 0.5, 0.5]],
)
input_set = MPGGARelaxMaker().input_set_generator.get_input_set(s, potcar_spec=True)

input_set.as_dict() # RecursionError

# or...
input_set.fake_attribute_still_crashes # RecursionError

Traceback:


----> 1 input_set.as_dict()

File ~/software/miniconda/envs/quacc/lib/python3.11/site-packages/monty/json.py:213, in MSONable.as_dict(self)
    203                 raise NotImplementedError(
    204                     "Unable to automatically determine as_dict "
    205                     "format from class. MSONAble requires all "
   (...)
    210                     "you can implement both as_dict and from_dict."
    211                 )
    212         d[c] = recursive_as_dict(a)
--> 213 if hasattr(self, "kwargs"):
    214     # type: ignore
    215     d.update(**getattr(self, "kwargs"))  # pylint: disable=E1101
    216 if spec.varargs is not None and getattr(self, spec.varargs, None) is not None:

File ~/software/miniconda/envs/quacc/lib/python3.11/site-packages/pymatgen/io/core.py:142, in InputSet.__getattr__(self, key)
    140 def __getattr__(self, key):
    141     # allow accessing keys as attributes
--> 142     if key in self._kwargs:
    143         return self.get(key)
    144     raise AttributeError(f"'{type(self).__name__}' object has no attribute {key!r}")

File ~/software/miniconda/envs/quacc/lib/python3.11/site-packages/pymatgen/io/core.py:142, in InputSet.__getattr__(self, key)
    140 def __getattr__(self, key):
    141     # allow accessing keys as attributes
--> 142     if key in self._kwargs:
    143         return self.get(key)
    144     raise AttributeError(f"'{type(self).__name__}' object has no attribute {key!r}")

    [... skipping similar frames: InputSet.__getattr__ at line 142 (2969 times)]

File ~/software/miniconda/envs/quacc/lib/python3.11/site-packages/pymatgen/io/core.py:142, in InputSet.__getattr__(self, key)
    140 def __getattr__(self, key):
    141     # allow accessing keys as attributes
--> 142     if key in self._kwargs:
    143         return self.get(key)
    144     raise AttributeError(f"'{type(self).__name__}' object has no attribute {key!r}")

RecursionError: maximum recursion depth exceeded

Andrew-S-Rosen avatar May 12 '24 01:05 Andrew-S-Rosen