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

Feature restart #5

Merged
merged 28 commits into from
Nov 14, 2023
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5dcbb1e
Added support for resarting from pre-existing checkpoint files.
mb2055 Nov 3, 2023
35ccd32
Added test for the restart feature.
mb2055 Nov 3, 2023
16f7d86
Added config filename to filename generator
mb2055 Nov 3, 2023
c8e9f52
Fixed config writing
mb2055 Nov 3, 2023
bb9606d
Merge branch 'main' into feature_restart
mb2055 Nov 6, 2023
9e66360
Remove duplicates from list of files to be deleted when --no-restart …
mb2055 Nov 6, 2023
7965730
Simulations will now start from scratch if restart==True but no check…
mb2055 Nov 6, 2023
b85be1b
Slight change to setting of charge scaled morph
mb2055 Nov 6, 2023
485ae5a
Added thorough testing for restarting, verifying that all options tha…
mb2055 Nov 6, 2023
d4faed6
Changed default behaviour to restart=False, warnings regarding overwr…
mb2055 Nov 6, 2023
257a99c
Re-factor of config to allow for the logger to be used within config …
mb2055 Nov 7, 2023
8b40942
Config now encoded in sire checkpoint files
mb2055 Nov 7, 2023
595d86b
Removing changed the writing of the output directory from PosixPath t…
mb2055 Nov 7, 2023
0d73e87
platform not os.platform
mb2055 Nov 7, 2023
845db4d
Explicitly delete objects before tempfile cleanup to solve windows is…
mb2055 Nov 8, 2023
88e7c8d
Disable logfile check on windows
mb2055 Nov 8, 2023
8561f5c
Remove wrongly added test, actually disable windows on logfile test
mb2055 Nov 8, 2023
499c529
Switch logfile test back on and add explicit logger deletion to confi…
mb2055 Nov 8, 2023
08dec8f
Removed second half of logfile creation test
mb2055 Nov 8, 2023
471ee73
returned windows skip to test for now
mb2055 Nov 8, 2023
ef71177
Proper naming for windows platform
mb2055 Nov 8, 2023
4b59cbb
another attempt at fixing logging on windows
mb2055 Nov 8, 2023
c794e7b
Added checks for consistency when restarting from checkpoint
mb2055 Nov 9, 2023
fe081d5
Added lambda value to properties [ci skip]
mb2055 Nov 9, 2023
7873aed
Several changes to bring the code in line with @lohedges suggestions.
mb2055 Nov 14, 2023
a832c92
Removed mention of directory_existed from _config.py - there is no ne…
mb2055 Nov 14, 2023
e7b82c3
Adds a systems_are_same function to the runner that checks uids, numb…
mb2055 Nov 14, 2023
71ee5df
Made systems_are_same private.
mb2055 Nov 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/somd2/runner/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,45 @@ def get_last_config(output_directory):

self._compare_configs(self.last_config, cfg_curr)

@staticmethod
def systems_are_same(system0, system1):
lohedges marked this conversation as resolved.
Show resolved Hide resolved
"""Check for equivalence between a pair of sire systems.

Parameters
----------
system0: sire.system.System
The first system to be compared.

system1: sire.system.System
The second system to be compared.
"""
if not isinstance(system0, _System):
raise TypeError("'system0' must be of type 'sire.system.System'")
if not isinstance(system1, _System):
raise TypeError("'system1' must be of type 'sire.system.System'")

# Check for matching uids
if not system0._system.uid() == system1._system.uid():
reason = "uids do not match"
return False, reason

# Check for matching number of molecules
if not len(system0.molecules()) == len(system1.molecules()):
reason = "number of molecules do not match"
return False, reason

# Check for matching number of residues
if not len(system0.residues()) == len(system1.residues()):
reason = "number of residues do not match"
return False, reason

# Check for matching number of atoms
if not len(system0.atoms()) == len(system1.atoms()):
reason = "number of atoms do not match"
return False, reason

return True, None

def get_options(self):
"""
Returns a dictionary of simulation options.
Expand Down Expand Up @@ -638,6 +677,11 @@ def _run(sim):
f"Unable to load checkpoint file for {_lam_sym}={lambda_value}, starting from scratch."
)
else:
aresame, reason = self.systems_are_same(self._system, system)
if not aresame:
raise ValueError(
f"Checkpoint file does not match system for the following reason: {reason}."
)
try:
self._compare_configs(
self.last_config, dict(system.property("config"))
Expand Down
Loading