-
Notifications
You must be signed in to change notification settings - Fork 8
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
Readonly settings #169
Merged
Merged
Readonly settings #169
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fa35f09
tweaked typing info for settings
richardjgowers baf4829
fixes #138
richardjgowers ee6653d
fixup mypy woes
richardjgowers 0231dc7
make benzene_variants fixture use Settings
richardjgowers db02942
more test fixups, but this isn't right currently
richardjgowers 999a81d
fixes #138
richardjgowers 6e48494
another test fix up
richardjgowers b70dec9
new plan on readonly settings
richardjgowers 9cde60a
revert trying to be clever about type annotations
richardjgowers 2a25f28
Improved readonly settings
dwhswenson 51b463f
don't need special-casing for _is_frozen
dwhswenson 958db64
Update models.py
richardjgowers c7d8e6d
fix type annotations on settings
richardjgowers b75ea44
update AlchemicalNetwork hashes
richardjgowers 28e49d2
adds Settings.unfrozen_copy
richardjgowers da8df08
copy of test fixups
richardjgowers a70d92d
make Protocol.settings return read-only view
richardjgowers 8f1476d
added test for setting subsection of frozen settings fails as expected
richardjgowers 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 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 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 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 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 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 |
---|---|---|
|
@@ -9,7 +9,11 @@ | |
from openff.units import unit | ||
import pytest | ||
|
||
from gufe.settings.models import Settings, OpenMMSystemGeneratorFFSettings | ||
from gufe.settings.models import ( | ||
OpenMMSystemGeneratorFFSettings, | ||
Settings, | ||
ThermoSettings, | ||
) | ||
|
||
|
||
def test_model_schema(): | ||
|
@@ -53,3 +57,57 @@ def test_invalid_constraint(value, good): | |
else: | ||
with pytest.raises(ValueError): | ||
_ = OpenMMSystemGeneratorFFSettings(constraints=value) | ||
|
||
|
||
class TestFreezing: | ||
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. Current tests check that it works we do |
||
def test_default_not_frozen(self): | ||
s = Settings.get_defaults() | ||
# make a frozen copy to check this doesn't alter the original | ||
s2 = s.frozen_copy() | ||
|
||
s.thermo_settings.temperature = 199 * unit.kelvin | ||
assert s.thermo_settings.temperature == 199 * unit.kelvin | ||
|
||
def test_freezing(self): | ||
s = Settings.get_defaults() | ||
|
||
s2 = s.frozen_copy() | ||
|
||
with pytest.raises(AttributeError, match="immutable"): | ||
s2.thermo_settings.temperature = 199 * unit.kelvin | ||
|
||
def test_unfreezing(self): | ||
s = Settings.get_defaults() | ||
|
||
s2 = s.frozen_copy() | ||
|
||
with pytest.raises(AttributeError, match="immutable"): | ||
s2.thermo_settings.temperature = 199 * unit.kelvin | ||
|
||
assert s2.is_frozen | ||
|
||
s3 = s2.unfrozen_copy() | ||
|
||
s3.thermo_settings.temperature = 199 * unit.kelvin | ||
assert s3.thermo_settings.temperature == 199 * unit.kelvin | ||
|
||
def test_frozen_equality(self): | ||
# the frozen-ness of Settings doesn't alter its contents | ||
# therefore a frozen/unfrozen Settings which are otherwise identical | ||
# should be considered equal | ||
s = Settings.get_defaults() | ||
s2 = s.frozen_copy() | ||
|
||
assert s == s2 | ||
|
||
def test_set_subsection(self): | ||
# check that attempting to set a subsection of settings still respects | ||
# frozen state of parent object | ||
s = Settings.get_defaults().frozen_copy() | ||
|
||
assert s.is_frozen | ||
|
||
ts = ThermoSettings(temperature=301 * unit.kelvin) | ||
|
||
with pytest.raises(AttributeError, match="immutable"): | ||
s.thermo_settings = ts |
This file contains 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 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
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.
Just checking: is this changing the gufe key because you've changed the fixture to use non-
None
settings? (Otherwise, nothing in this PR should affect gufe keys, right?)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.
yep it's this