From 72c48194396f80bb43b490eb4b60ee63696f0e66 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:10:34 -0400 Subject: [PATCH 1/5] add watermark --- src/pyflask/manageNeuroconv/manage_neuroconv.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index 22bceede3..9d10d1d55 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -14,7 +14,7 @@ from tqdm_publisher import TQDMProgressHandler -from .info import CONVERSION_SAVE_FOLDER_PATH, GUIDE_ROOT_FOLDER, STUB_SAVE_FOLDER_PATH +from .info import CONVERSION_SAVE_FOLDER_PATH, GUIDE_ROOT_FOLDER, STUB_SAVE_FOLDER_PATH, is_packaged, resource_path from .info.sse import format_sse progress_handler = TQDMProgressHandler() @@ -1000,6 +1000,13 @@ def update_conversion_progress(message): tzinfo=zoneinfo.ZoneInfo(info["timezone"]) ) + # Add GUIDE watermark + package_json_file_path = resource_path("package.json" if is_packaged() else "../../package.json") + with open(file=package_json_file_path) as fp: + package_json = json.load(fp=fp) + app_version = package_json["version"] + resolved_metadata["NWBFile"]["source_script"] = f"Created using NWB GUIDE v{app_version}" + # Actually run the conversion converter.run_conversion( metadata=resolved_metadata, From 5a86ee875996b6f2fee4926cc3345bae1e4ac69f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 20:11:11 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/pyflask/manageNeuroconv/manage_neuroconv.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index 9d10d1d55..ed695b0cd 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -14,7 +14,13 @@ from tqdm_publisher import TQDMProgressHandler -from .info import CONVERSION_SAVE_FOLDER_PATH, GUIDE_ROOT_FOLDER, STUB_SAVE_FOLDER_PATH, is_packaged, resource_path +from .info import ( + CONVERSION_SAVE_FOLDER_PATH, + GUIDE_ROOT_FOLDER, + STUB_SAVE_FOLDER_PATH, + is_packaged, + resource_path, +) from .info.sse import format_sse progress_handler = TQDMProgressHandler() @@ -1006,7 +1012,7 @@ def update_conversion_progress(message): package_json = json.load(fp=fp) app_version = package_json["version"] resolved_metadata["NWBFile"]["source_script"] = f"Created using NWB GUIDE v{app_version}" - + # Actually run the conversion converter.run_conversion( metadata=resolved_metadata, From 78c63b6dc424d6e57c286049195036d3a91c8e95 Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Wed, 5 Jun 2024 11:59:01 -0400 Subject: [PATCH 3/5] update package json location --- src/pyflask/manageNeuroconv/manage_neuroconv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index 607d7c338..296aea2f3 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -1008,7 +1008,7 @@ def update_conversion_progress(message): ).replace(tzinfo=zoneinfo.ZoneInfo(info["timezone"])) # Add GUIDE watermark - package_json_file_path = resource_path("package.json" if is_packaged() else "../../package.json") + package_json_file_path = resource_path("../package.json" if is_packaged() else "../package.json") with open(file=package_json_file_path) as fp: package_json = json.load(fp=fp) app_version = package_json["version"] From 39a90db6a59a0fef99b8ad1def4bc03d78135a8d Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Wed, 5 Jun 2024 12:22:35 -0400 Subject: [PATCH 4/5] fix validation issue --- src/pyflask/manageNeuroconv/manage_neuroconv.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index 296aea2f3..343cea578 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -862,7 +862,7 @@ def convert_to_nwb( """Function used to convert the source data to NWB format using the specified metadata.""" import requests - from neuroconv import NWBConverter + import neuroconv from tqdm_publisher import TQDMProgressSubscriber url = info.get("url", None) @@ -975,7 +975,7 @@ def update_conversion_progress(message): interface_or_subconverter = converter.data_interface_objects[sub_interface] - if isinstance(interface_or_subconverter, NWBConverter): + if isinstance(interface_or_subconverter, neuroconv.NWBConverter): subconverter = interface_or_subconverter update_recording_properties_from_table_as_json( @@ -1013,6 +1013,7 @@ def update_conversion_progress(message): package_json = json.load(fp=fp) app_version = package_json["version"] resolved_metadata["NWBFile"]["source_script"] = f"Created using NWB GUIDE v{app_version}" + resolved_metadata["NWBFile"]["source_script_file_name"] = neuroconv.__file__ # Must be included to be valid # Actually run the conversion converter.run_conversion( From 84f2aa02b4a44eb606a4a716edf1ffb5ff27df07 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 5 Jun 2024 16:26:05 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/pyflask/manageNeuroconv/manage_neuroconv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index 2b70c7d3c..228230fe6 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -875,8 +875,8 @@ def convert_to_nwb( ) -> str: """Function used to convert the source data to NWB format using the specified metadata.""" - import requests import neuroconv + import requests from tqdm_publisher import TQDMProgressSubscriber url = info.get("url", None)