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

Renaming and moving some of the protocol settings #689

Merged
merged 45 commits into from
Feb 6, 2024

Conversation

hannahbaumann
Copy link
Contributor

Developers certificate of origin

@pep8speaks
Copy link

pep8speaks commented Jan 17, 2024

Hello @hannahbaumann! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 97:80: E501 line too long (106 > 79 characters)
Line 98:80: E501 line too long (105 > 79 characters)

Line 640:80: E501 line too long (82 > 79 characters)
Line 687:80: E501 line too long (89 > 79 characters)
Line 690:80: E501 line too long (90 > 79 characters)
Line 801:80: E501 line too long (87 > 79 characters)
Line 814:80: E501 line too long (86 > 79 characters)
Line 815:80: E501 line too long (98 > 79 characters)
Line 950:80: E501 line too long (83 > 79 characters)

Line 54:80: E501 line too long (80 > 79 characters)
Line 121:72: W291 trailing whitespace
Line 122:70: W291 trailing whitespace
Line 123:79: W291 trailing whitespace

Line 400:80: E501 line too long (83 > 79 characters)
Line 401:80: E501 line too long (80 > 79 characters)
Line 621:80: E501 line too long (81 > 79 characters)
Line 623:80: E501 line too long (80 > 79 characters)
Line 626:80: E501 line too long (90 > 79 characters)
Line 627:80: E501 line too long (88 > 79 characters)
Line 753:80: E501 line too long (82 > 79 characters)
Line 837:80: E501 line too long (83 > 79 characters)

Line 394:80: E501 line too long (87 > 79 characters)
Line 398:80: E501 line too long (84 > 79 characters)
Line 470:80: E501 line too long (82 > 79 characters)
Line 550:80: E501 line too long (86 > 79 characters)
Line 596:80: E501 line too long (87 > 79 characters)
Line 597:80: E501 line too long (87 > 79 characters)
Line 598:80: E501 line too long (87 > 79 characters)
Line 599:80: E501 line too long (87 > 79 characters)
Line 600:80: E501 line too long (87 > 79 characters)
Line 601:80: E501 line too long (97 > 79 characters)

Line 12:80: E501 line too long (80 > 79 characters)

Line 632:80: E501 line too long (94 > 79 characters)
Line 804:80: E501 line too long (88 > 79 characters)
Line 831:80: E501 line too long (82 > 79 characters)
Line 877:80: E501 line too long (82 > 79 characters)
Line 886:80: E501 line too long (89 > 79 characters)
Line 890:80: E501 line too long (107 > 79 characters)
Line 951:80: E501 line too long (84 > 79 characters)
Line 985:80: E501 line too long (85 > 79 characters)

Line 76:72: W291 trailing whitespace
Line 85:77: W291 trailing whitespace
Line 111:72: W291 trailing whitespace
Line 112:70: W291 trailing whitespace
Line 113:79: W291 trailing whitespace

Line 96:80: E501 line too long (82 > 79 characters)
Line 271:80: E501 line too long (80 > 79 characters)
Line 273:80: E501 line too long (94 > 79 characters)
Line 291:1: W293 blank line contains whitespace
Line 293:80: E501 line too long (105 > 79 characters)
Line 297:80: W291 trailing whitespace
Line 298:79: W291 trailing whitespace
Line 299:25: W291 trailing whitespace
Line 304:80: E501 line too long (88 > 79 characters)
Line 308:17: W291 trailing whitespace
Line 309:1: W293 blank line contains whitespace
Line 392:62: W291 trailing whitespace

Line 92:80: E501 line too long (80 > 79 characters)
Line 97:80: E501 line too long (90 > 79 characters)
Line 98:80: E501 line too long (87 > 79 characters)
Line 130:80: E501 line too long (80 > 79 characters)
Line 135:80: E501 line too long (89 > 79 characters)
Line 139:80: E501 line too long (108 > 79 characters)
Line 140:80: E501 line too long (110 > 79 characters)
Line 143:80: E501 line too long (97 > 79 characters)
Line 146:80: E501 line too long (116 > 79 characters)
Line 147:80: E501 line too long (110 > 79 characters)

Line 69:80: E501 line too long (86 > 79 characters)

Line 29:80: E501 line too long (84 > 79 characters)

Line 427:80: E501 line too long (89 > 79 characters)
Line 469:80: E501 line too long (89 > 79 characters)

Line 213:80: E501 line too long (100 > 79 characters)

Comment last updated at 2024-02-06 11:50:51 UTC

@hannahbaumann hannahbaumann linked an issue Jan 17, 2024 that may be closed by this pull request
steps_per_iteration = 250 * 4 fs
--> The free energy would be analyzed every 250 ps (250 * 250 * 4 fs)
"""
early_termination_target_error: FloatQuantity = 0.0 * unit.boltzmann_constant * unit.kelvin
Copy link
Contributor Author

@hannahbaumann hannahbaumann Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this unit correct or does it need to be changed? Should this be 0.0 * boltzmann_constant * temperature * unit.boltzmann_constant * unit.kelvin? Not sure...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to unit kcal/mol

Simulation control settings, including simulation lengths and record-keeping.
Simulation control settings, including simulation lengths.
"""
output_settings: OutputSettings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can probably wait, but this OutputSettings idea could percolate back to gufe where iirc there's a proto-Settings object which tries to define the pattern all should follow

Number of integration timesteps between each time the MCMC move
is applied. Default 250 * unit.timestep.
"""
real_time_analysis_interval: Optional[int] = 250
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't unit.timestep as it's a multiple of steps_per_iteration right? So the default is 250 * 250?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is answered in the docstring below >.<

steps_per_iteration = 250 * 4 fs
--> The free energy would be analyzed every 250 ps (250 * 250 * 4 fs)
"""
early_termination_target_error: FloatQuantity = 0.0 * unit.boltzmann_constant * unit.kelvin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe can wait, but possibly making this Optional is a better way to toggle the behaviour on/off, rather than using 0.0

@richardjgowers richardjgowers added this to the 1.0.0 milestone Jan 19, 2024
@@ -134,62 +134,72 @@ class Config:
or `independent` (independently sampled lambda windows).
Default `repex`.
"""
online_analysis_interval: Optional[int] = 250
steps_per_iteration = 250 * unit.timestep # todo: IntQuantity
Copy link
Contributor Author

@hannahbaumann hannahbaumann Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this, would it technically also be 250 * timestep * unit.timestep? Or just make it an IntQuantity that has to be used together with timestep to be a useful quantity?

"""
Number of integration timesteps between each time the MCMC move
is applied. Default 250 * unit.timestep.
"""
reassign_velocities = False
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially move to AlchemicalSamplerSettings or change doc string to explain what move means here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this for reassign_velocities? seems like an integrator thing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reassign velocities is specific to the behaviour that exists when doing multi state moves, not the timestep integration itself, that makes it a property of the sampler not the integrator

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second half of review

@@ -234,10 +235,11 @@ def _handle_settings(self):
* solvation_settings : SolvationSettings
* alchemical_settings : AlchemicalSettings
* lambda_settings : LambdaSettings
* sampler_settings : AlchemicalSamplerSettings
* sampler_settings : MultiStateSimulationSettings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove both sampler_settings and system_settings


Returns
-------
integrator : openmmtools.mcmc.LangevinDynamicsMove
A configured integrator object.
"""
# TODO: Check this is correct
tpi_fs = simulation_settings.time_per_iteration.to(unit.femtosecond).m
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be using whatever got added to openmm_utils?

Comment on lines 33 to 36
from typing import (
Literal,
Optional,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not seeing either of these being used in the diff?

@@ -71,3 +71,95 @@ def get_simsteps(sim_length: unit.Quantity,
raise ValueError(errmsg)

return sim_steps


def convert_steps_per_iteration(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going over the MD protocol - I'm probably missing something really obvious but isn't this method exactly the same as using get_simsteps but with an MC value of 1 (like we do there)?

settings.vacuum_simulation_settings.equilibration_length = 10 * unit.picosecond
settings.vacuum_simulation_settings.production_length = 1000 * unit.picosecond
settings.vacuum_simulation_settings.production_length = 10 * unit.picosecond
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried this several times below 1 ns and it fails on the regular. It ends up wasting a lot more time re-running everything than just running the full nanosecond.

@richardjgowers richardjgowers changed the title [ WIP] Renaming and moving some of the protocol settings Renaming and moving some of the protocol settings Feb 5, 2024
Copy link

codecov bot commented Feb 6, 2024

Codecov Report

Attention: 37 lines in your changes are missing coverage. Please review.

Comparison is base (443fcf2) 91.36% compared to head (2a948cc) 91.43%.
Report is 36 commits behind head on main.

Files Patch % Lines
openfe/protocols/openmm_utils/omm_settings.py 82.27% 14 Missing ⚠️
openfe/tests/protocols/test_openmm_afe_slow.py 0.00% 8 Missing ⚠️
...tests/protocols/test_openmm_equil_rfe_protocols.py 88.00% 3 Missing ⚠️
openfe/protocols/openmm_afe/base.py 90.90% 2 Missing ⚠️
openfe/protocols/openmm_afe/equil_afe_settings.py 94.73% 2 Missing ⚠️
openfe/protocols/openmm_md/plain_md_settings.py 87.50% 2 Missing ⚠️
openfe/protocols/openmm_rfe/equil_rfe_methods.py 90.00% 2 Missing ⚠️
openfe/protocols/openmm_rfe/equil_rfe_settings.py 91.30% 2 Missing ⚠️
...ts/protocols/test_openmm_afe_solvation_protocol.py 97.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #689      +/-   ##
==========================================
+ Coverage   91.36%   91.43%   +0.07%     
==========================================
  Files         132      132              
  Lines        9174     9333     +159     
==========================================
+ Hits         8382     8534     +152     
- Misses        792      799       +7     
Flag Coverage Δ
fast-tests 91.43% <91.59%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the docs build is failing because of missing references to settings?

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of extra comments, none blocking.

Would be nice to think about moving non-unit conversions somewhere eventually - it's going to be necessary going forward to have a good place to do kt->kj->kcal->kt etc...

def must_be_positive(cls, v):
if v <= 0:
errmsg = f"protocol_repeats must be a positive value, got {v}."
raise ValueError(errmsg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth a test to check that the validators kick in properly at this level?

integrator_settings: IntegratorSettings = protocol_settings.integrator_settings

# is the timestep good for the mass?
settings_validation.validate_timestep(
forcefield_settings.hydrogen_mass,
integrator_settings.timestep
)
# TODO: Also validate various conversions?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, please raise an issue if there's a todo.

def must_be_positive_or_zero(cls, v):
if v < 0:
errmsg = ("collision_rate, and n_restart_attempts must be "
"zero or positive values")
errmsg = ("langevin_collision_rate, and n_restart_attempts must be"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't point to all the codecov stuff - but there's a lot of stuff that's not covered, worth raising an issue to make sure we test it all?

return rta_its, rta_min_its


def convert_target_error_from_kcal_per_mole_to_kT(
Copy link
Member

@IAlibay IAlibay Feb 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not going to block here, but would it make sense rename this to be "convert_kcal_per_mole_to_kT" instead? Long term is might be good if we had a series of conversions somewhere else that we can use.

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@richardjgowers richardjgowers merged commit 2ab9b43 into main Feb 6, 2024
9 checks passed
@richardjgowers richardjgowers deleted the rename_settings branch February 6, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Review settings names
4 participants