-
Notifications
You must be signed in to change notification settings - Fork 124
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
FIX: Ensure values of boolean metadata fields are preserved #1034
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1034 +/- ##
==========================================
+ Coverage 83.46% 83.48% +0.01%
==========================================
Files 38 38
Lines 4307 4310 +3
Branches 1097 1098 +1
==========================================
+ Hits 3595 3598 +3
Misses 514 514
Partials 198 198 ☔ View full report in Codecov by Sentry. |
bids/layout/models.py
Outdated
self.value = self.dtype(self._value) | ||
if self.dtype == bool and self._value == "False": | ||
self.value = False | ||
else: | ||
self.value = self.dtype(self._value) |
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 don't trust that this is the only place where this problem comes up, nor that this is the best way to handle it, but it gets my failing test to pass.
This has me thinking that there should be a set of tests that directly compare loaded metadata values from |
We do have all of the types. Can we just load them as JSON and load them as metadata and compare?
|
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 this is in good shape. I verified that my test failed without this fix and passes now.
I think that might be a good test idea. To be honest, I might just be being paranoid. It's hard to imagine another case like this, given the other datatypes that are possible, but then again I never noticed this bug before now, so checking every possible value seems like a good idea. Still, that can be done in a separate PR. Is there anything else I should do before merging? |
I did it in the latest commit. I'm happy to merge if everybody else is. @adelavega? |
That's awesome, thanks! Also, can we fast-track a patch release once this is merged? |
No problem. Do you have commit rights here? Our release process is pretty easy to follow. |
It looks like I do have commit rights. I'm happy to take a crack at it once @adelavega weighs in on the PR. |
Meh. I'm okay not waiting on Alej. |
I went through the blames for the relevant lines and I think this bug was introduced in 0.9.0 (when SQL was adopted). Does that sound right? I'd like to include the affected versions in the release notes. |
Sounds about right. |
Closes #1033. As @effigies suspected, the problem stems from the fact that metadata fields are initially converted to strings (
False
becomes'False'
) and then are converted using the desired datatype (bool('False')
becomesTrue
).Changes proposed:
MTState
in the 7t_trt dataset since that dataset is used intest_get_metadata
.test_get_metadata_error2
, that checks that the value returned is False.Tag._init_on_load()
and explicitly convert'False'
toFalse
. Other datatypes and values can be handled using the old code.