-
Notifications
You must be signed in to change notification settings - Fork 32
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
Refactor: Add arguments block to main MatNWB api functions #619
Conversation
- Move some functions io.spec namespace - Add validation functions in matnwb.common namespace
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #619 +/- ##
==========================================
+ Coverage 90.85% 95.16% +4.30%
==========================================
Files 107 113 +6
Lines 4781 4734 -47
==========================================
+ Hits 4344 4505 +161
+ Misses 437 229 -208 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
- Simplify logic in fillExport
continue is unecessary here
Add arguments block
Removes lines that can not be reached
Simplify
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.
Extracted function from NwbFile/export
to collect all code related to reading and writing embedded specifications in one place
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.
Moved rehash statement to file.cloneNwbFileClass
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.
Use onCleanup
to close space and object instead of doing it "conditionally"
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.
Add utility function for finding the latest available nwb schema version
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.
Add validator function to assert that a path is an NWB filepath
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.
Add validator function to assert that a versionNumber
value is a properly formatted version number string and that the version number is available among the available nwb schemas
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.
- Specify default values in property block instead of constructor
- Use assert instead of if to improve coverage
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 allow
schemaSource
being a string - use
fileread
instead offopen
,fwrite
,fclose
sequence
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.
- Add named arguments and arguments block to simplify argument parsing
- Negate
isempty(fileList)
block to remove potentially unreachable code
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.
Add unit tests to increase coverage for nwbRead
, nwbExport
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.
Add unites to test the file.cloneNwbFileClass
function
@@ -131,6 +142,9 @@ function testExternalFilters(testCase) | |||
import types.untyped.datapipe.properties.DynamicFilter; | |||
import types.untyped.datapipe.properties.Shuffle; | |||
|
|||
% TODO: Why is Filter.LZ4 not part of the exported Pipe, i.e when 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.
@bendichter @lawrence-mbf I need help to understand if this is a bug
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.
Result of updating class generator to fix word capitalisation
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.
Added arguments block
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.
Move default output to beginning as it was potentially unreachable for unit tests
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.
Removed unused method
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.
Added named arguments and argument block
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.
Fixed to work for older schema versions
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.
- Add arguments block to constructor and export method
- Added mode for overwriting file on export
- Use assertion instead of if block with error on export to improve coverage
- removed
embedSpecifications
method. Was moved toio.spec.writeEmbeddedSpecifications
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.
moved file into resources folder
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.
- Add named arguments and arguments block
- Pass
namespaceFiles
cell array to generateExtension instead of potentially calling it twice
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.
- Add named arguments and arguments block
- Added local validator function
mustBeYamlFle
to check that namespace spec files exist - simplified code in loop for generating class files
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.
- Add optional output argument. Can be used by cleanup operations to regenerate cleared namespaces
- Add input for specifying root folder where classes to be cleared exist
- Added option for also clearing the namespace cache
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.
- Rename input arguments to be more descriptive
- Added argument blocks for simpler input handling / validation
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.
Moved to resources folder
Changed to be up-to-date
@@ -0,0 +1,18 @@ | |||
function specLocation = readEmbeddedSpecLocation(fid, specLocAttributeName) |
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.
what's the difference between readEmbeddedSpecLocaation and getEmbeddedSpecLocation? Can you add a comment here indicating the distinction?
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.
getEmbeddedSpecLocation
- Takes a filepath as an input.
readEmbeddedSpecLocation
- Takes a fid as an input, useful if the file is already opened
function closeSpaceAndObject(spaceId, objectId) | ||
H5S.close(spaceId); | ||
H5O.close(objectId); | ||
end |
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.
This feels like it could have some side effects. Are you able to separate this change into a different PR?
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 would argue that it is more robust than the current code.
When h5CleanupObj
is cleared from the workspace, i.e when the function exits, either on returning or on errors, it will run the callback and close the space and objects.
At the moment if the code fails on line 16-18 or 26, these would not be closed, but with the cleanup callback they will
Fix #606
Motivation
How to test the behavior?
Checklist
fix #XX
whereXX
is the issue number?