-
Notifications
You must be signed in to change notification settings - Fork 1
Add gather and integration test #46
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
base: main
Are you sure you want to change the base?
Changes from all commits
d3e9cab
60adc2b
e1e86f0
a755d37
4989910
96861c9
0397e21
15923e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,7 +132,7 @@ def test_unit_tagging_setup_unit(solvent_protocol_dag, tmpdir): | |
| assert len(repeats) == 1 | ||
|
|
||
|
|
||
| def test_dry_run_ffcache_none(benzene_system, monkeypatch, tmp_path_factory): | ||
| def test_dry_run_ffcache_none(benzene_system, tmp_path_factory): | ||
| settings = GromacsMDProtocol.default_settings() | ||
| settings.output_settings_em.forcefield_cache = None | ||
| settings.simulation_settings_em.nsteps = 10 | ||
|
|
@@ -164,9 +164,7 @@ def test_dry_run_ffcache_none(benzene_system, monkeypatch, tmp_path_factory): | |
| ) | ||
|
|
||
|
|
||
| def test_dry_many_molecules_solvent( | ||
| benzene_many_solv_system, monkeypatch, tmp_path_factory | ||
| ): | ||
| def test_dry_many_molecules_solvent(benzene_many_solv_system, tmp_path_factory): | ||
| """ | ||
| A basic test flushing "will it work if you pass multiple molecules" | ||
| """ | ||
|
|
@@ -199,6 +197,46 @@ def test_dry_many_molecules_solvent( | |
| ) | ||
|
|
||
|
|
||
| def test_gather(benzene_system, tmp_path_factory): | ||
| # check .gather behaves as expected: That gather correctly creates the | ||
| # results object | ||
| # This is running a full (short) simulation of benzene in water which is ok | ||
| # since this is a cheap simulation. | ||
| settings = GromacsMDProtocol.default_settings() | ||
| settings.output_settings_em.forcefield_cache = None | ||
| settings.simulation_settings_em.nsteps = 10 | ||
| settings.simulation_settings_nvt.nsteps = 10 | ||
| settings.simulation_settings_npt.nsteps = 1 | ||
| settings.simulation_settings_em.rcoulomb = 1.0 * off_unit.nanometer | ||
| settings.simulation_settings_nvt.rcoulomb = 1.0 * off_unit.nanometer | ||
| settings.simulation_settings_npt.rcoulomb = 1.0 * off_unit.nanometer | ||
| protocol = GromacsMDProtocol( | ||
| settings=settings, | ||
| ) | ||
|
|
||
| # create DAG from protocol and take first (and only) work unit from within | ||
| dag = protocol.create( | ||
| stateA=benzene_system, | ||
| stateB=benzene_system, | ||
| mapping=None, | ||
| ) | ||
|
|
||
| shared_temp = tmp_path_factory.mktemp("shared") | ||
| scratch_temp = tmp_path_factory.mktemp("scratch") | ||
| dagres = gufe.protocols.execute_DAG( | ||
| dag, | ||
| shared_basedir=shared_temp, | ||
| scratch_basedir=scratch_temp, | ||
| keep_shared=False, | ||
| n_retries=3, | ||
| ) | ||
| prot = GromacsMDProtocol(settings=settings) | ||
|
|
||
| res = prot.gather([dagres]) | ||
|
|
||
| assert isinstance(res, GromacsMDProtocolResult) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe check the other attributes of the results object? I.e. what else do you expect to be getting out of it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean testing the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's a bit tedious but you can probably program/template a lot of it using something like getattr and a loop. |
||
|
|
||
|
|
||
| class TestProtocolResult: | ||
| @pytest.fixture() | ||
| def protocolresult(self, md_json): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # This code is part of OpenFE and is licensed under the MIT license. | ||
| # For details, see https://github.com/OpenFreeEnergy/openfe-gromacs | ||
|
|
||
| import gufe | ||
| import pytest | ||
|
|
||
| from openfe_gromacs.protocols.gromacs_md.md_methods import GromacsMDProtocol | ||
|
|
||
|
|
||
| @pytest.mark.integration | ||
| def test_protein_ligand_md(toluene_complex_system, tmp_path_factory): | ||
| settings = GromacsMDProtocol.default_settings() | ||
| settings.simulation_settings_em.nsteps = 5000 | ||
| settings.simulation_settings_nvt.nsteps = 10000 | ||
| settings.simulation_settings_npt.nsteps = 100000 | ||
| protocol = GromacsMDProtocol( | ||
| settings=settings, | ||
| ) | ||
|
|
||
| dag = protocol.create( | ||
| stateA=toluene_complex_system, | ||
| stateB=toluene_complex_system, | ||
| mapping=None, | ||
| ) | ||
|
|
||
| shared_temp = tmp_path_factory.mktemp("shared") | ||
| scratch_temp = tmp_path_factory.mktemp("scratch") | ||
| gufe.protocols.execute_DAG( | ||
| dag, | ||
| shared_basedir=shared_temp, | ||
| scratch_basedir=scratch_temp, | ||
| keep_shared=False, | ||
| n_retries=3, | ||
| ) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a full integration test, you really want to run "this thing under normal circumstances". What you're testing is "is this thing yielding the results I would expect". To do that you could test:
Because you're marking it with the "this is really expensive" flag, it's perfectly ok to make this a much longer test (many more steps, etc...). |
||
Uh oh!
There was an error while loading. Please reload this page.