Repository navigation
make ambertools optional #462
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
Open
mikemhenry
wants to merge
14
commits into
openmm:main
Choose a base branch
from
mikemhenry:feat/make-ambertools-optional
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
da8686b
Add testpypi (#1)
mikemhenry fb56c26
Update setup.py
mikemhenry 4c56376
Update setup.py
mikemhenry 339ef4a
enable backfill
mikemhenry 0816162
make parmed a testing dep + a seperate feature for gaff
mikemhenry 8663703
reset some changes to make PR smaller
mikemhenry f26ebab
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 179c3b3
remove parmed as testing dep and make it optional
mikemhenry b7acc43
Merge branch 'parmed-opt-branch' into feat/make-ambertools-optional
mikemhenry ba26fac
we can't remove parmed as a testing dep so lest keep this bit
mikemhenry 9baa952
update filter so we don't call `OFFForceField('gaff-1.4')` when check…
mikemhenry 0354cbd
Update openmmforcefields/tests/test_optional_parmed.py
mikemhenry 62dab92
update the invalid ff to look more like a current valid one
mikemhenry d844354
Merge remote-tracking branch 'refs/remotes/origin/feat/make-ambertool…
mikemhenry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| """Exercise the optional GAFF-only ParmEd dependency.""" | ||
|
|
||
| import shutil | ||
| import subprocess | ||
| import sys | ||
|
|
||
| import pytest | ||
|
|
||
| from openmmforcefields.generators import GAFFTemplateGenerator | ||
|
|
||
|
|
||
| def test_generators_import_without_parmed(): | ||
| """Normal imports must not require the optional ParmEd dependency for GAFF.""" | ||
| subprocess.run( | ||
| [ | ||
| sys.executable, | ||
| "-c", | ||
| "import sys; sys.modules['parmed'] = None; " | ||
| "from openmmforcefields.generators import " | ||
| "GAFFTemplateGenerator, SMIRNOFFTemplateGenerator, SystemGenerator", | ||
| ], | ||
| check=True, | ||
| capture_output=True, | ||
| text=True, | ||
| ) | ||
|
|
||
|
|
||
| def test_gaff_missing_parmed(monkeypatch): | ||
| """Report the missing dependency before starting parameter assignment.""" | ||
| monkeypatch.setattr(shutil, "which", lambda _: "/usr/bin/mock-ambertools") | ||
| monkeypatch.setitem(sys.modules, "parmed", None) | ||
| generator = GAFFTemplateGenerator(forcefield="gaff-2.2.20") | ||
| with pytest.raises(RuntimeError, match="ParmEd is required for GAFF"): | ||
| generator.generate_residue_template(object()) | ||
|
|
||
|
|
||
| def test_gaff_missing_ambertools_still_reports_ambertools(monkeypatch): | ||
| monkeypatch.setattr(shutil, "which", lambda _: None) | ||
| monkeypatch.setitem(sys.modules, "parmed", None) | ||
| generator = GAFFTemplateGenerator(forcefield="gaff-2.2.20") | ||
| with pytest.raises(RuntimeError, match="AmberTools is required for GAFF"): | ||
| generator.generate_residue_template(object()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the explicit recommendation to install with pip here, since users might still install OpenMMForceFields with conda (in which case it is probably better to avoid creating an environment in which packages have been installed with both conda and pip).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking here is that if the package is installed with conda, then they will have parmed and ambertools, if the install it via pip, then they could be missing parmed but have ambertools in their path, so it felt like the only edge case here is solved with a pip install.