Conversation
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
IAlibay
left a comment
There was a problem hiding this comment.
Overall this looks good to me. There's a few areas where it might be good to enhance things, especially when it comes maybe just sticking on the checkpoint reporter the whole way through the simulation, but they wouldn't affect the overall organization of the code.
| return pdbs | ||
|
|
||
|
|
||
| class PlainMDProtocol(gufe.Protocol): |
There was a problem hiding this comment.
[scope] It may be good to take the opportunity to move Protocols, results, settings and units to their own files.
There was a problem hiding this comment.
I played around with this and ended up having a cyclic import issue as the PlainMDProtocol is a type hint in the PlainMDSetupUnit maybe we can look at this later?
There was a problem hiding this comment.
:/ that probably needs fixing - can you open an issue? We usually use gufe.Protocol as the type hint for units so that you can create multiple protocols using the same units.
| # g. Save the system and positions to file | ||
| system_outfile = shared_basepath / "system.xml.bz2" | ||
| serialization.serialize(stateA_system, system_outfile) | ||
| # not really need if we save out the pre-minimized file |
There was a problem hiding this comment.
I somewhat agree, however PDBs are low precision, savin the npy is good in my opinion.
There was a problem hiding this comment.
removed that comment.
| traj.save_pdb(shared_basepath / output_settings.minimized_structure) | ||
| # equilibrate | ||
| # NVT equilibration | ||
| if equil_steps_nvt: |
There was a problem hiding this comment.
[scope] Thinking about this - is there any reason we can't just add the checkpoint reporter at this stage? It's more likely that someone running the PlainMD protocol would be running longer equilibrations / productions, so it might be nice to be able to restart at any point during it.
There was a problem hiding this comment.
Yeah thats a good idea, and we could use the total step count to work out which stage the simulation was at?
| stateA_topology, stateA_positions, file=f, keepIds=True | ||
| ) | ||
|
|
||
| # 10. Get platform |
There was a problem hiding this comment.
[nit] The comments will need to be updated once the structure is settled.
| if x.getName() == "MonteCarloBarostat": | ||
| x.setFrequency(0) | ||
|
|
||
| simulation.context.setVelocitiesToTemperature(to_openmm(temperature)) |
There was a problem hiding this comment.
[scope / nit] it would definitely be good to split this up into method calls or something like that. There's a lot of code in an "else" section.
# Conflicts: # src/openfe/protocols/openmm_md/plain_md_methods.py
|
pre-commit.ci autofix |
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1884 +/- ##
==========================================
- Coverage 94.78% 90.59% -4.20%
==========================================
Files 210 211 +1
Lines 18841 19028 +187
==========================================
- Hits 17859 17238 -621
- Misses 982 1790 +808
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
… logic, update tests
|
pre-commit.ci autofix |
IAlibay
left a comment
There was a problem hiding this comment.
Just an initial half of the review (only got to the docstring of _run_MD.
There was a problem hiding this comment.
Could you do this as a separate file? There's a few places where we want to keep uncharged inputs and I'd prefer untangle that from this PR (mostly so we don't have to think about two things at the same time).
There was a problem hiding this comment.
I'll revert this for now, it was just very slow while doing local testing and I'll come back to it in a separate PR.
| # returns a dict of repeat_id: sorted list of ProtocolUnitResult | ||
| return repeats | ||
|
|
||
| def _validate( |
There was a problem hiding this comment.
I'm being incredibly nit picky on this one - so please push back. Any chance you could move this method above _create.
This is purely an asthetic thing of "that's the order we've been doing for the other Protocols".
| def _validate( | ||
| self, | ||
| stateA: ChemicalSystem, | ||
| stateB: ChemicalSystem, |
There was a problem hiding this comment.
Can you add a check that stateA is stateB?
There was a problem hiding this comment.
Good catch, done and added a test.
| # This technically should be NotImplementedError | ||
| # but gufe.Protocol.validate calls `_validate` wrapped around an | ||
| # except for NotImplementedError, so we can't raise it here | ||
| raise NotImplementedError("Can't extend simulations yet") |
There was a problem hiding this comment.
😅 this doesn't match the comment - we've been using ValueError here because NotImplementedError gets squashed in validate.
There was a problem hiding this comment.
Ah I didn't want to change the error that was raised in the protocol but I guess we are breaking a lot of stuff here, updated!
IAlibay
left a comment
There was a problem hiding this comment.
One more thing, otherwise it looks good to me!
| Worker method to set the temperature, barostat and run dynamics and save final structure output. | ||
| """ | ||
| # set the velocities to temperature | ||
| simulation.context.setVelocitiesToTemperature(to_openmm(temperature)) |
There was a problem hiding this comment.
By doing this you are reassigning velocities even if you're in the middle of a restart.
During a restart, would loadState not assign velocities that we want to continue from?
There was a problem hiding this comment.
Ah good catch! I have added another flag to run dynamics to control if we should reassign the velocities, this introduces another parameter to track the state, similar to production started but I think this is clear?
Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
|
pre-commit.ci autofix |
IAlibay
left a comment
There was a problem hiding this comment.
This looks amazing - just one thing and one question and it's good to go!
There was a problem hiding this comment.
Can you add a news entry please?
| output_settings: MDOutputSettings, | ||
| verbose: bool = True, | ||
| output_path: None | pathlib.Path = None, | ||
| reinitialize_velocities: bool = True, |
| ) | ||
|
|
||
| # add the checkpoint reporter so we can recover during the equilibration / production phases | ||
| if output_settings.checkpoint_storage_filename: |
There was a problem hiding this comment.
I'm pretty sure it doesn't but just in case - could you confirm that on restart the CheckpointReporter doesn't reset the global step count?
| output_path=output_path, | ||
| reinitialize_velocities=reinitialize_velocities, | ||
| ) | ||
| # if we have run this stage we then need to reinitialize velocities in the next stages |
There was a problem hiding this comment.
I see what you mean, but frankly I don't think there's a way around this.
|
No API break detected ✅ |
Fixes #1719, #1720, #1721
This PR splits up the plain MD protocol unit into a setup and simulation unit and adds the ability to restart failed simulations.
Notes
Checklist
newsentry, or the changes are not user-facing.pre-commit.ci autofix.Manual Tests: these are slow so don't need to be run every commit, only before merging and when relevant changes are made (generally at reviewer-discretion).
Developers certificate of origin