-
Notifications
You must be signed in to change notification settings - Fork 132
Description
Currently, the atomate2 / OpenMM tutorial works for openff-toolkit version 0.16.2 and openff-interchange version 0.3.22. I have created a fork to fix any compatibility issues with versions 0.16.7 and 0.4.0, respectively. I'm running into an issue possibly related to the Interchange schema between versions. I'm running the tutorial (locally), and the later versions of OpenFF lead to error in atomate2/openmm/jobs/base.py that successfully runs in the earlier versions.
Specifically, at line 276 of base.py, the Interchange.parse_raw function (would it be better to use model_validate_json since parse_raw is deprecated?) fails with the error:
1 validation error for Interchange
collections.key_map
Value error, charge_from_molecules [type=value_error, input_value={'{"this_atom_index":0}':...smetic_attributes":{}}'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.10/v/value_error
which leads to the creation of an OpenMMInterchange object via emmet that fails downstream:
File "/pscratch/sd/p/parmar/atomate2_feature_OPLS-AA/lib/python3.11/site-packages/jobflow/managers/local.py", line 117, in _run_job
response = job.run(store=store)
^^^^^^^^^^^^^^^^^^^^
File "/pscratch/sd/p/parmar/atomate2_feature_OPLS-AA/lib/python3.11/site-packages/jobflow/core/job.py", line 604, in run
response = function(*self.function_args, **self.function_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/global/u1/p/parmar/HTMD/PR/SMP/atomate2/src/atomate2/openmm/jobs/base.py", line 226, in make
sim = self._create_simulation(interchange, prev_task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/global/u1/p/parmar/HTMD/PR/SMP/atomate2/src/atomate2/openmm/jobs/base.py", line 515, in _create_simulation
return interchange.to_openmm_simulation(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/pscratch/sd/p/parmar/atomate2_feature_OPLS-AA/lib/python3.11/site-packages/emmet/core/openmm/tasks.py", line 271, in to_openmm_simulation
system = XmlSerializer.deserialize(self.system)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/pscratch/sd/p/parmar/atomate2_feature_OPLS-AA/lib/python3.11/site-packages/openmm/openmm.py", line 11638, in deserialize
match = re.search("<([^?]\S*)", inputString)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/pscratch/sd/p/parmar/atomate2_feature_OPLS-AA/lib/python3.11/re/__init__.py", line 176, in search
return _compile(pattern, flags).search(string)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'
I've also inspected the interchange str before the try/except statement to find that the only difference between JSON strings is the presence of "cosmetic_attributes": {} in the newer (openff-interchange 0.4.0) dictionary. I've tried suppressing this by setting allow_cosmetic_attributes=False wherever a ForceField is created, but this has no effect on the error. Albeit my debugging solutions have been aimed at trying to suppress the exception, there may be an issue in emmet/core/openmm/tasks.py as well (or both).
The openff-interchange 0.4.0 release also mentions use of Pydantic v2 at runtime, which I'm not sure yet if this has to do with the error.
To Reproduce
Using the atomate2 / OpenMM tutorial instructions + installing openff-toolkit==0.16.7 and openff-interchange==0.4.0 instead; update mass_density with target_density in src/atomate2/openff/core.py (or use the fork linked above).
CC'ing @orionarcher
EDIT: There is not an issue on the emmet/core/openmm/tasks.py side of things since the tutorial code only runs generate_interchange(...), i.e., generate_openmm_interchange(...) is never called and hence the TypeError: expected string or bytes-like object, got 'NoneType'.