Skip to content

Commit

Permalink
Merge pull request #486 from NeurodataWithoutBorders/inspector-quick-fix
Browse files Browse the repository at this point in the history
Fallback to n_jobs=1 if NWB Inspector fails
  • Loading branch information
CodyCBakerPhD authored Oct 31, 2023
2 parents 1ea2f56 + 583778b commit 9b83dcb
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions pyflask/manageNeuroconv/manage_neuroconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,19 +592,29 @@ def inspect_nwb_file(payload):
def inspect_nwb_folder(payload):
from nwbinspector import inspect_all, load_config
from nwbinspector.nwbinspector import InspectorOutputJSONEncoder

messages = list(
inspect_all(
n_jobs=-2, # uses number of CPU - 1
ignore=[
"check_description",
"check_data_orientation",
], # TODO: remove when metadata control is exposed
config=load_config(filepath_or_keyword="dandi"),
**payload,
)
from pickle import PicklingError

kwargs = dict(
n_jobs=-2, # uses number of CPU - 1
ignore=[
"check_description",
"check_data_orientation",
], # TODO: remove when metadata control is exposed
config=load_config(filepath_or_keyword="dandi"),
**payload,
)

try:
messages = list(inspect_all(**kwargs))
except PicklingError as e:
if "attribute lookup auto_parse_some_output on nwbinspector.register_checks failed" in str(e):
del kwargs["n_jobs"]
messages = list(inspect_all(**kwargs))
else:
raise e
except Exception as e:
raise e

return json.loads(json.dumps(obj=messages, cls=InspectorOutputJSONEncoder))


Expand Down

0 comments on commit 9b83dcb

Please sign in to comment.