-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add the n_protocol_dag_results
property to ProtocolResult
#381
Add the n_protocol_dag_results
property to ProtocolResult
#381
Conversation
The `gather` aggregation method removes too much information when reducing the provided protocol_dag_results. This change adds the new n_protocol_dag_results property that reflects the number of ProtocolDAGResult objects that were used to create the ProtocolResult.
…t_n_protocol_dag_results
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #381 +/- ##
=======================================
Coverage 98.66% 98.67%
=======================================
Files 36 36
Lines 2097 2109 +12
=======================================
+ Hits 2069 2081 +12
Misses 28 28 ☔ View full report in Codecov by Sentry. |
I'm probably being a little (very) pedantic here, but since Since I'm using the All of that said, I'm happy to revert the guardrail (and its test) if it seems like too much for this PR. Although I suspect type checkers will complain if I use |
I think the case of infinite Do you agree with this? |
You will also need to make changes to the |
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.
Also blocking on downstream testing and maybe a bit of a discussion on protocol needs.
gufe/protocols/protocol.py
Outdated
self._data = data | ||
self._n_protocol_dag_results = ( | ||
n_protocol_dag_results if n_protocol_dag_results is not None else 0 |
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 trying to wrap my head around the use case here, could you explain the case where None happens? I.e. at first glance setting None to zero seems incorrect if None means that the gather method did not pass through a value. In that case None means undefined and it's much cleaner than getting 0 with the idea that you got no results (but you do).
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 think in the context of a Protocol
's gather
, you'll never see a None
passed in. I can see instances where ProtocolResult
s are used directly, incorrectly or not, and a None
would make sense. But of course I immediately throw away the None
in the code you highlighted above. I suppose there is still some indecision on my part what the right signature should be and which values the ProtocolResult
holds on to. I'm tempted to just drop Optional[int]
and use int
with default 0
.
Just from the tests, I see instances where someone would make a ProtocolResult
directly and I'll probably do something similar in testing parts of stratocaster
downstream:
class DummyProtocolResult(gufe.ProtocolResult):
def get_estimate(self):
return self.data['estimate']
def get_uncertainty(self):
return self.data['uncertainty']
class TestProtocolResult(GufeTokenizableTestsMixin):
cls = DummyProtocolResult
key = 'DummyProtocolResult-b7b854b39c1e37feabec58b4000680a0'
repr = f'<{key}>'
@pytest.fixture
def instance(self):
return DummyProtocolResult(
estimate=4.2 * unit.kilojoule_per_mole,
uncertainty=0.2 * unit.kilojoule_per_mole,
)
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.
Thanks @ianmkenney - is this a time critical thing? I would like to spend a bit of time to check what this means for the existing Protocols, but I don't think I'll have time until Monday :(
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.
Not necessarily. I'll be testing stratocaster strategies based on this branch until it's merged in the hopes that we get some solution that's close in spirit to what we have here.
Yeah that works, I think in the long term it will simplify typing issues. |
`_to_dict` and `_from_dict` of `ProtocolResult` were also updated to account for the new n_protocol_dag_results property
Explicitly test `get_uncertainty`, `get_estimate`, and `n_protocol_dag_results`
…t_n_protocol_dag_results
@IAlibay downstream do you serialize |
We serialize |
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.
How about this?
First attempt to extract n_protocol_dag_results from the data dict. If a KeyError is raised, as you'd find for ProtocolResults serialized prior to this commit, set n_protocol_dag_results to the default value of 0. Co-authored-by: Irfan Alibay <[email protected]>
Test creating a ProtocolResult from a dictionary that is missing the n_protocol_dag_results key.
93adf94
to
8d7f3b7
Compare
…ult_n_protocol_dag_results
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.
lgtm thanks!
@ianmkenney if you can resolve conflicts, I think this one is good to go for merge! |
This PR adds the
n_protocol_dag_results
property to theProtocolResult
class. It reflects the number ofProtocolDAGResult
s that were input to the_gather
call.