From 33e570c1e3482a7d9c777a74f022952be168cc76 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Sat, 7 Oct 2023 04:08:27 -0400 Subject: [PATCH 1/3] use dandi config --- pyflask/manageNeuroconv/manage_neuroconv.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pyflask/manageNeuroconv/manage_neuroconv.py b/pyflask/manageNeuroconv/manage_neuroconv.py index 2045f2d42..a9114889d 100644 --- a/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/pyflask/manageNeuroconv/manage_neuroconv.py @@ -17,7 +17,7 @@ def replace_nan_with_none(data): if isinstance(data, dict): # If it's a dictionary, iterate over its items and replace NaN values with None - return {key: replace_nan_with_none(value) for key, value in data.items()} + return {key: replace_nan_with_none(value) for key, value in data.items()}x elif isinstance(data, list): # If it's a list, iterate over its elements and replace NaN values with None return [replace_nan_with_none(item) for item in data] @@ -536,6 +536,7 @@ def inspect_nwb_file(payload): "check_description", "check_data_orientation", ], # TODO: remove when metadata control is exposed + config="dandi", **payload, ) ), @@ -556,6 +557,7 @@ def inspect_nwb_file(payload): "check_description", "check_data_orientation", ], # TODO: remove when metadata control is exposed + config="dandi", **payload, ) ), @@ -564,7 +566,7 @@ def inspect_nwb_file(payload): ) -def inspect_nwb_folder(payload): +def _inspect_nwb_folder(payload): from nwbinspector import inspect_all from nwbinspector.nwbinspector import InspectorOutputJSONEncoder @@ -575,6 +577,7 @@ def inspect_nwb_folder(payload): "check_description", "check_data_orientation", ], # TODO: remove when metadata control is exposed + config="dandi", **payload, ) ) @@ -584,7 +587,7 @@ def inspect_nwb_folder(payload): return json.loads(json.dumps(messages, cls=InspectorOutputJSONEncoder)) -def aggregate_symlinks_in_new_directory(paths, reason="", folder_path=None): +def _aggregate_symlinks_in_new_directory(paths, reason="", folder_path=None): if folder_path is None: folder_path = GUIDE_ROOT_FOLDER / ".temp" / reason / f"temp_{datetime.now().strftime('%Y%m%d-%H%M%S')}" @@ -604,7 +607,7 @@ def aggregate_symlinks_in_new_directory(paths, reason="", folder_path=None): def inspect_multiple_filesystem_objects(paths): - tmp_folder_path = aggregate_symlinks_in_new_directory(paths, "inspect") - result = inspect_nwb_folder({"path": tmp_folder_path}) + tmp_folder_path = _aggregate_symlinks_in_new_directory(paths, "inspect") + result = _inspect_nwb_folder({"path": tmp_folder_path}) rmtree(tmp_folder_path) return result From 80e04e45bfc345f83cdca8cbc1559bf34726b0f2 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Fri, 13 Oct 2023 08:28:00 -0400 Subject: [PATCH 2/3] Update pyflask/manageNeuroconv/manage_neuroconv.py --- pyflask/manageNeuroconv/manage_neuroconv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyflask/manageNeuroconv/manage_neuroconv.py b/pyflask/manageNeuroconv/manage_neuroconv.py index a9114889d..dabfd2290 100644 --- a/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/pyflask/manageNeuroconv/manage_neuroconv.py @@ -17,7 +17,7 @@ def replace_nan_with_none(data): if isinstance(data, dict): # If it's a dictionary, iterate over its items and replace NaN values with None - return {key: replace_nan_with_none(value) for key, value in data.items()}x + return {key: replace_nan_with_none(value) for key, value in data.items()} elif isinstance(data, list): # If it's a list, iterate over its elements and replace NaN values with None return [replace_nan_with_none(item) for item in data] From d7cf85e1866ceabfa364fdc01de78da2e8923224 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Fri, 13 Oct 2023 14:27:56 -0400 Subject: [PATCH 3/3] debugs --- pyflask/manageNeuroconv/manage_neuroconv.py | 52 ++++++--------------- 1 file changed, 13 insertions(+), 39 deletions(-) diff --git a/pyflask/manageNeuroconv/manage_neuroconv.py b/pyflask/manageNeuroconv/manage_neuroconv.py index dabfd2290..c128938a3 100644 --- a/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/pyflask/manageNeuroconv/manage_neuroconv.py @@ -528,45 +528,21 @@ def inspect_nwb_file(payload): from nwbinspector import inspect_nwbfile from nwbinspector.nwbinspector import InspectorOutputJSONEncoder - return json.loads( - json.dumps( - list( - inspect_nwbfile( - ignore=[ - "check_description", - "check_data_orientation", - ], # TODO: remove when metadata control is exposed - config="dandi", - **payload, - ) - ), - cls=InspectorOutputJSONEncoder, + messages = list( + inspect_nwbfile( + ignore=[ + "check_description", + "check_data_orientation", + ], # TODO: remove when metadata control is exposed + config="dandi", + **payload, ) ) + return json.loads(json.dumps(obj=messages, cls=InspectorOutputJSONEncoder)) -def inspect_nwb_file(payload): - from nwbinspector import inspect_nwbfile - from nwbinspector.nwbinspector import InspectorOutputJSONEncoder - return json.loads( - json.dumps( - list( - inspect_nwbfile( - ignore=[ - "check_description", - "check_data_orientation", - ], # TODO: remove when metadata control is exposed - config="dandi", - **payload, - ) - ), - cls=InspectorOutputJSONEncoder, - ) - ) - - -def _inspect_nwb_folder(payload): +def inspect_nwb_folder(payload): from nwbinspector import inspect_all from nwbinspector.nwbinspector import InspectorOutputJSONEncoder @@ -582,9 +558,7 @@ def _inspect_nwb_folder(payload): ) ) - # messages = organize_messages(messages, levels=["importance", "message"]) - - return json.loads(json.dumps(messages, cls=InspectorOutputJSONEncoder)) + return json.loads(json.dumps(obj=messages, cls=InspectorOutputJSONEncoder)) def _aggregate_symlinks_in_new_directory(paths, reason="", folder_path=None): @@ -597,7 +571,7 @@ def _aggregate_symlinks_in_new_directory(paths, reason="", folder_path=None): path = Path(path) new_path = folder_path / path.name if path.is_dir(): - aggregate_symlinks_in_new_directory( + _aggregate_symlinks_in_new_directory( list(map(lambda name: os.path.join(path, name), os.listdir(path))), None, new_path ) else: @@ -608,6 +582,6 @@ def _aggregate_symlinks_in_new_directory(paths, reason="", folder_path=None): def inspect_multiple_filesystem_objects(paths): tmp_folder_path = _aggregate_symlinks_in_new_directory(paths, "inspect") - result = _inspect_nwb_folder({"path": tmp_folder_path}) + result = inspect_nwb_folder({"path": tmp_folder_path}) rmtree(tmp_folder_path) return result