-
Notifications
You must be signed in to change notification settings - Fork 33
Fix: Mark required attribute- and link-properties as required #655
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
Conversation
Set Required "tag" for properties derived from attributes and links
…perties on export
If a required attribute depends on a non-required Dataset or Group, this method issues a warning if the dependent attribute (property) is missing when it's parent is present
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #655 +/- ##
==========================================
+ Coverage 95.18% 95.21% +0.03%
==========================================
Files 124 124
Lines 5044 5077 +33
==========================================
+ Hits 4801 4834 +33
Misses 243 243 ☔ View full report in Codecov by Sentry. |
I'm a bit confused by this one: % Example 2 - Required link. Fails before, but for the wrong reason
nwbFile2 = NwbFile( ...
'session_description', 'test file for nwb export', ...
'identifier', 'export_test', ...
'session_start_time', datetime("now", 'TimeZone', 'local') );
electrode = types.core.IntracellularElectrode('description', 'test');
nwbFile2.general_intracellular_ephys.set('Electrode', electrode)
nwbExport(nwbFile2, "example2.nwb") To be a link it must be added somewhere else in the NWB file, right? |
% Example 3 - Required dependent attribute. Ok before, issues warning now
nwbFile3 = NwbFile( ...
'session_description', 'test file for nwb export', ...
'identifier', 'export_test', ...
'session_start_time', datetime("now", 'TimeZone', 'local') );
nwbFile3.general_source_script = '.../nwbExportTest.m';
nwbExport(nwbFile3, "example3.nwb") what was the missing attribute? |
And I guess these changes didn't cause any problems for the tutorials? |
Co-authored-by: Ben Dichter <[email protected]>
Yes, this is not very clear. |
|
All tests are passing |
If |
I guess the advantage of your approach is that if we flag these things on write then we don't have to worry about breaking read for old out-of-spec files. Since this is a pretty serious bug, I'm fine with pushing it forward in this way, even though it's not the ideal solution. But ultimately how would you feel about putting these checks in the class constructors? |
@bendichter , The check will also occur on class construction. For example: >> types.core.IntracellularElectrode()
ans =
IntracellularElectrode with properties:
description: ''
device: []
cell_id: ''
filtering: ''
initial_access_resistance: ''
location: ''
resistance: ''
seal: ''
slice: ''
Warning: The following required properties are missing for instance for type "types.core.IntracellularElectrode":
description
device Note that the warning does not appear if the output is suppressed, e.g. >> ielectrode = types.core.IntracellularElectrode();
>> and we could think about fine-tuning this, but I would suggest making that a separate issue. I would definitely go for warning on construction / error on export to be able to read files where these properties might be missing, but also as a more "gentle" way of teaching users what are required and not |
The warning is good, but I don't like that it is suppressed by the semicolon. I think most users will use a semicolon here and so they will miss the warning. It is a very important warning, so I don't want them to miss it. I was not aware of this behavior in MATLAB. Is this custom or standard warning behavior? |
Fix #654
Motivation
Attributes and links that were required according to the NWB schemas were not required in MatNWB. This PR fixes that.
It also adds a warning if a dependent required attribute is missing on export. For example, an attribute might be required but part of an untyped dataset or group which is not required. If such a dataset or group is added, but a required attribute of that dataset or group is not, a warning is shown on export.
How to test the behavior?
Checklist
fix #XX
whereXX
is the issue number?