-
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 config file option #86
Conversation
add config json schema add example config file add configure_checks function and corresponding test TODO: expose to command line
@CodyCBakerPhD I started to build out the feature for custom configuration file that changes the severity of checks. In doing so, I simplified the available_checks dictionary from: {Importance: {nd_type: [checks]}} to {Importance: [checks]} the nd_type is pulled from the attribute of the check. This is a simplification without loss of function for the library, and it makes the config feature easier to implement. |
@bendichter 👍 Yup, looking over it now. The main reason for pre-sorting by neurodata type was to save time complexity from having to manually inspect it during each step of the outer iteration, but I can re-analyze it again and see if there's an even better way to structure that. |
As I look at the primary iteration usage of That way, we could move those nested Extreme example: we only want to for nwbfile_object in nwbfile.objects.values(): <---- could have a large number of objects
for check_function in check_functions: <---- could have a large number of functions
if issubclass(type(nwbfile_object), check_function.neurodata_type):
if ignore is not None and check_function.__name__ in ignore: <-- line gets hit every time
continue
if select is not None and check_function.__name__ not in select:
continue
output = check_function(nwbfile_object) <---- only reaches here a couple of times |
Oh, I also think it would help the design of the configuration approach (and probably other things too...) if the initial registry With this approach, the default configuration would simply be the What do you think? |
Co-authored-by: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com>
# Conflicts: # nwbinspector/nwbinspector.py
for more information, see https://pre-commit.ci
@CodyCBakerPhD yes, I think that could make things simpler |
So the config logic would simply be something like: checks = copy.copy(available_checks)
for importance, func_names in config.items():
func = checks[func]
func.importance = importance
check[func] = func |
Yeah, pretty much. Looks much cleaner. |
@CodyCBakerPhD I went even further and just made |
@bendichter Yup, this all looks really good now. |
Also, I just remembered Dorota pointed out that it may be for the best to only allow elevation of Importance levels via the config to prevent people from being able to forcibly downgrade important things; do you agree with that? Also also, Yarik mentioned having the config be able to specify SKIP type behavior on a per-NWBFile level when this config is meant to be run on a directory. Any ideas for how that could go into this schema? |
I don't know what you mean |
From #37
Unless he means to apply the SKIP rule over all files in that directory and not NWBFile-specific. Example: |
@CodyCBakerPhD OK, I understand. Skipping checks for specific files. I'd say if you want to do that you can run your own script and do something like for file in glob.glob(os.path.join(path, '*.nwb'):
if file == 'bad_file.nwb':
ignore = ["check_data_orientation"]
else:
ignore = None
inspect_nwb(file, ignore=ignore) |
Co-authored-by: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com>
@bendichter Two minor suggestions for schema-pertaining items. Otherwise LGTM |
Codecov Report
@@ Coverage Diff @@
## dev #86 +/- ##
==========================================
- Coverage 94.31% 93.55% -0.76%
==========================================
Files 12 12
Lines 422 481 +59
==========================================
+ Hits 398 450 +52
- Misses 24 31 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
|
fix #37
restructure available_checks
add config json schema
add example config file
add configure_checks function and corresponding test
TODO: expose to command line