OpenFreeEnergy / OpenFreeEnergy/openfe

RelativeHybridTopologyProtocolSettings can not round trip to JSON

Open
#518 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
331
Forks
56
Avg merge
3d 9h
Merged PRs (30d)
13

Description

I want to be able to save the RelativeHybridTopologyProtocolSettings object to a JSON file to track the settings used in my calculations however I get validation errors when trying to parse the file, see the example below. I think part of the problem is the general settings types used on the base Settings class. The other part of the issue seems to be related to the fact that openff-models can not parse units on nested models correctly.

from openfe.protocols.openmm_rfe.equil_rfe_settings import RelativeHybridTopologyProtocolSettings
from openfe.protocols.openmm_rfe import RelativeHybridTopologyProtocol


print("Creating settings from raw json")
s2 = RelativeHybridTopologyProtocolSettings.parse_raw(settings.json(indent=2))

Creating settings from raw json
Traceback (most recent call last):
File "/Users/joshua/Documents/Projects/ASAP/software_dev/openfe_workflow/test_alchemiscale/test_openfe.py", line 8, in
s2 = RelativeHybridTopologyProtocolSettings.parse_raw(settings.json(indent=2))
File "pydantic/main.py", line 549, in pydantic.main.BaseModel.parse_raw
File "pydantic/main.py", line 526, in pydantic.main.BaseModel.parse_obj
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.init
pydantic.error_wrappers.ValidationError: 18 validation errors for RelativeHybridTopologyProtocolSettings
forcefield_settings -> constraints
extra fields not permitted (type=value_error.extra)
forcefield_settings -> forcefields
extra fields not permitted (type=value_error.extra)
forcefield_settings -> hydrogen_mass
extra fields not permitted (type=value_error.extra)
forcefield_settings -> remove_com
extra fields not permitted (type=value_error.extra)
forcefield_settings -> rigid_water
extra fields not permitted (type=value_error.extra)
forcefield_settings -> small_molecule_forcefield
extra fields not permitted (type=value_error.extra)
thermo_settings -> temperature
Cannot convert from 'dimensionless' (dimensionless) to 'kelvin' ([temperature]) (type=type_error.dimensionality; units1=dimensionless; units2=kelvin; dim1=dimensionless; dim2=[temperature]; extra_msg=)
thermo_settings -> pressure
Cannot convert from 'dimensionless' (dimensionless) to 'standard_atmosphere' ([mass] / [length] / [time] ** 2) (type=type_error.dimensionality; units1=dimensionless; units2=standard_atmosphere; dim1=dimensionless; dim2=[mass] / [length] / [time] ** 2; extra_msg=)
system_settings -> nonbonded_cutoff
instance of Quantity expected (type=type_error.arbitrary_type; expected_arbitrary_type=Quantity)
solvation_settings -> solvent_padding
instance of Quantity expected (type=type_error.arbitrary_type; expected_arbitrary_type=Quantity)
alchemical_sampler_settings -> online_analysis_target_error
instance of Quantity expected (type=type_error.arbitrary_type; expected_arbitrary_type=Quantity)
integrator_settings -> timestep
instance of Quantity expected (type=type_error.arbitrary_type; expected_arbitrary_type=Quantity)
integrator_settings -> collision_rate
instance of Quantity expected (type=type_error.arbitrary_type; expected_arbitrary_type=Quantity)
integrator_settings -> n_steps
instance of Quantity expected (type=type_error.arbitrary_type; expected_arbitrary_type=Quantity)
integrator_settings -> barostat_frequency
instance of Quantity expected (type=type_error.arbitrary_type; expected_arbitrary_type=Quantity)
simulation_settings -> equilibration_length
instance of Quantity expected (type=type_error.arbitrary_type; expected_arbitrary_type=Quantity)
simulation_settings -> production_length
instance of Quantity expected (type=type_error.arbitrary_type; expected_arbitrary_type=Quantity)
simulation_settings -> checkpoint_interval
instance of Quantity expected (type=type_error.arbitrary_type; expected_arbitrary_type=Quantity)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the round-trip example in openfe.protocols.openmm_rfe.equil_rfe_settings with RelativeHybridTopologyProtocolSettings, then inspect the referenced gufe/settings/models.py Settings class. Review the linked openff-models nested-unit parsing issue and compare the serialized fields with the validation errors. Done means the settings JSON parses back into the same settings object without validation errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.