From 4bf639dee6784b9eaa4c9b0f72c7b44740c08153 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Mon, 3 Jun 2024 12:14:42 -0500 Subject: [PATCH 01/12] Always use run_conversion --- .../manageNeuroconv/manage_neuroconv.py | 138 +++++++++--------- 1 file changed, 67 insertions(+), 71 deletions(-) diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index 475d69e3c..3929ed454 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -863,22 +863,22 @@ def create_file( ) -> dict: import requests - from neuroconv.tools.nwb_helpers import ( - get_default_backend_configuration, - make_or_load_nwbfile, - ) from tqdm_publisher import TQDMProgressSubscriber + project_name = info.get("project_name") run_stub_test = info.get("stub_test", False) - backend_configuration = info.get("configuration") + overwrite = info.get("overwrite", False) + # Progress update info url = info.get("url") request_id = info.get("request_id") - will_configure_backend = backend_configuration is not None and run_stub_test is False + # Backend configuration info + backend_configuration = info.get("configuration") + backend = backend_configuration.get("backend", "hdf5") converter, metadata, path_info = get_conversion_info(info) @@ -894,60 +894,48 @@ def create_file( else: nwbfile_path.unlink() - if will_configure_backend: - - backend = backend_configuration.get("backend", "hdf5") - configuration_values = backend_configuration.get("results", {}).get(backend, {}) - - # Create NWB file with appropriate backend configuration - with make_or_load_nwbfile( - nwbfile_path=nwbfile_path, metadata=metadata, overwrite=overwrite, backend=backend - ) as nwbfile: - converter.add_to_nwbfile(nwbfile, metadata=metadata) - configuration = get_default_backend_configuration(nwbfile=nwbfile, backend=backend) - configure_dataset_backends(nwbfile, configuration_values, configuration) - - else: + def update_conversion_progress(message): + update_dict = dict(request_id=request_id, **message) + if url or not run_stub_test: + requests.post(url=url, json=update_dict) + else: + progress_handler.announce(update_dict) - def update_conversion_progress(message): - update_dict = dict(request_id=request_id, **message) - if url or not run_stub_test: - requests.post(url=url, json=update_dict) - else: - progress_handler.announce(update_dict) + progress_bar_options = dict( + mininterval=0, + on_progress_update=update_conversion_progress, + ) - progress_bar_options = dict( - mininterval=0, - on_progress_update=update_conversion_progress, - ) + # Assume all interfaces have the same conversion options for now + available_options = converter.get_conversion_options_schema() + options = {interface: {} for interface in info["source_data"]} - # Assume all interfaces have the same conversion options for now - available_options = converter.get_conversion_options_schema() - options = {interface: {} for interface in info["source_data"]} + for interface in options: + available_opts = available_options.get("properties").get(interface).get("properties", {}) - for interface in options: - available_opts = available_options.get("properties").get(interface).get("properties", {}) + # Specify if stub test + if run_stub_test: + if available_opts.get("stub_test"): + options[interface]["stub_test"] = True - # Specify if stub test - if run_stub_test: - if available_opts.get("stub_test"): - options[interface]["stub_test"] = True + # Specify if iterator options are available + elif available_opts.get("iterator_opts"): + options[interface]["iterator_opts"] = dict( + display_progress=True, + progress_bar_class=TQDMProgressSubscriber, + progress_bar_options=progress_bar_options, + ) - # Specify if iterator options are available - elif available_opts.get("iterator_opts"): - options[interface]["iterator_opts"] = dict( - display_progress=True, - progress_bar_class=TQDMProgressSubscriber, - progress_bar_options=progress_bar_options, - ) - # Actually run the conversion - converter.run_conversion( - metadata=metadata, - nwbfile_path=nwbfile_path, - overwrite=overwrite, - conversion_options=options, - ) + # Actually run the conversion + converter.run_conversion( + metadata=metadata, + nwbfile_path=nwbfile_path, + overwrite=overwrite, + conversion_options=options, + backend=backend, + backend_configuration=extract_backend_configuration(info), + ) except Exception as e: if log_url: @@ -964,43 +952,51 @@ def update_conversion_progress(message): raise e -def get_backend_configuration(info: dict) -> dict: - - import numpy as np - - PROPS_TO_REMOVE = [ - # Immutable - "object_id", - "dataset_name", - "location_in_file", - "dtype", - ] - - PROPS_TO_IGNORE = ["full_shape"] - - info["overwrite"] = True # Always overwrite the file - +def extract_backend_configuration(info: dict) -> dict: + from neuroconv.tools.nwb_helpers import ( get_default_backend_configuration, make_nwbfile_from_metadata, ) + PROPS_TO_IGNORE = ["full_shape"] + backend_configuration = info.get("configuration", {}) backend = backend_configuration.get("backend", "hdf5") results = backend_configuration.get("results", {}).get(backend, {}) - # raise ValueError(f"This function is not currently supported. {results}") - converter, metadata, __ = get_conversion_info(info) nwbfile = make_nwbfile_from_metadata(metadata=metadata) converter.add_to_nwbfile(nwbfile, metadata=metadata) + configuration = get_default_backend_configuration(nwbfile=nwbfile, backend=backend) + for dataset_name, dataset_configuration in results.items(): for key, value in dataset_configuration.items(): if key not in PROPS_TO_IGNORE: setattr(configuration.dataset_configurations[dataset_name], key, value) + return configuration + + +def get_backend_configuration(info: dict) -> dict: + + import numpy as np + + PROPS_TO_REMOVE = [ + # Immutable + "object_id", + "dataset_name", + "location_in_file", + "dtype", + ] + + info["overwrite"] = True # Always overwrite the file + + backend = info.get("backend", "hdf5") + configuration = extract_backend_configuration(info) + def custom_encoder(obj): if isinstance(obj, np.ndarray): return obj.tolist() From 81cf13100490735d7d1c33881cc5004fa67696ed Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 17:18:35 +0000 Subject: [PATCH 02/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/pyflask/manageNeuroconv/manage_neuroconv.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index 3929ed454..eac3b8a0d 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -865,7 +865,6 @@ def create_file( import requests from tqdm_publisher import TQDMProgressSubscriber - project_name = info.get("project_name") run_stub_test = info.get("stub_test", False) @@ -926,7 +925,6 @@ def update_conversion_progress(message): progress_bar_options=progress_bar_options, ) - # Actually run the conversion converter.run_conversion( metadata=metadata, @@ -953,7 +951,7 @@ def update_conversion_progress(message): def extract_backend_configuration(info: dict) -> dict: - + from neuroconv.tools.nwb_helpers import ( get_default_backend_configuration, make_nwbfile_from_metadata, @@ -971,7 +969,7 @@ def extract_backend_configuration(info: dict) -> dict: converter.add_to_nwbfile(nwbfile, metadata=metadata) configuration = get_default_backend_configuration(nwbfile=nwbfile, backend=backend) - + for dataset_name, dataset_configuration in results.items(): for key, value in dataset_configuration.items(): if key not in PROPS_TO_IGNORE: @@ -979,7 +977,7 @@ def extract_backend_configuration(info: dict) -> dict: return configuration - + def get_backend_configuration(info: dict) -> dict: import numpy as np From dc0e5988ae3ec03f3472bfc370f4e7589637aa56 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:33:55 -0400 Subject: [PATCH 03/12] refactor configuraiton function --- src/pyflask/manageNeuroconv/manage_neuroconv.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index eac3b8a0d..b0581d17a 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -827,7 +827,7 @@ def get_interface_alignment(info: dict) -> dict: ) -def configure_dataset_backends(nwbfile, backend_configuration, configuration=None): +def configure_dataset_backends(nwbfile, backend: Optional[str] = None, backend_configuration: Optional[dict] = None) -> None: from neuroconv.tools.nwb_helpers import ( configure_backend, get_default_backend_configuration, @@ -835,16 +835,11 @@ def configure_dataset_backends(nwbfile, backend_configuration, configuration=Non PROPS_TO_AVOID = ["full_shape"] - # Default to HDF5 backend configuration - if configuration is None: - configuration = get_default_backend_configuration(nwbfile=nwbfile, backend="hdf5") + backend = backend or "hdf5" + backend_configuration = backend_configuration or get_default_backend_configuration(nwbfile=nwbfile, backend=backend) - # Ensure the configuration is a dictionary - elif isinstance(configuration, str): - configuration = get_default_backend_configuration(nwbfile=nwbfile, backend=configuration) - - for name, item in backend_configuration.items(): - for key, value in item.items(): + for dataset_name, dataset_configuration in backend_configuration.items(): + for key, value in dataset_configuration.items(): # Avoid setting compression options if unspecified if key == "compression_options" and (value is None or len(value) == 0): @@ -854,7 +849,7 @@ def configure_dataset_backends(nwbfile, backend_configuration, configuration=Non elif key not in PROPS_TO_AVOID: setattr(configuration.dataset_configurations[name], key, value) - configure_backend(nwbfile=nwbfile, backend_configuration=configuration) + configure_backend(nwbfile=nwbfile, backend_configuration=backend_configuration) def create_file( From 1bbd42c513e891bf3969b7cca4ebfec7e1283f65 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 17:34:11 +0000 Subject: [PATCH 04/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/pyflask/manageNeuroconv/manage_neuroconv.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index b0581d17a..cfab0411a 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -827,7 +827,9 @@ def get_interface_alignment(info: dict) -> dict: ) -def configure_dataset_backends(nwbfile, backend: Optional[str] = None, backend_configuration: Optional[dict] = None) -> None: +def configure_dataset_backends( + nwbfile, backend: Optional[str] = None, backend_configuration: Optional[dict] = None +) -> None: from neuroconv.tools.nwb_helpers import ( configure_backend, get_default_backend_configuration, From 5fc9132a1273fd36f2210da9cad2578573fc01b5 Mon Sep 17 00:00:00 2001 From: CodyCBakerPhD Date: Mon, 3 Jun 2024 13:54:39 -0400 Subject: [PATCH 05/12] more refactoring --- .../manageNeuroconv/manage_neuroconv.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index cfab0411a..12dfc92dc 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -929,7 +929,7 @@ def update_conversion_progress(message): overwrite=overwrite, conversion_options=options, backend=backend, - backend_configuration=extract_backend_configuration(info), + backend_configuration=update_backend_configuration(info), ) except Exception as e: @@ -947,7 +947,7 @@ def update_conversion_progress(message): raise e -def extract_backend_configuration(info: dict) -> dict: +def update_backend_configuration(info: dict) -> dict: from neuroconv.tools.nwb_helpers import ( get_default_backend_configuration, @@ -956,23 +956,23 @@ def extract_backend_configuration(info: dict) -> dict: PROPS_TO_IGNORE = ["full_shape"] - backend_configuration = info.get("configuration", {}) - backend = backend_configuration.get("backend", "hdf5") - results = backend_configuration.get("results", {}).get(backend, {}) + info_from_frontend = info.get("configuration", {}) + backend = info_from_frontend.get("backend", "hdf5") + backend_configuration_from_frontend = info_from_frontend.get("results", {}).get(backend, {}) converter, metadata, __ = get_conversion_info(info) nwbfile = make_nwbfile_from_metadata(metadata=metadata) converter.add_to_nwbfile(nwbfile, metadata=metadata) - configuration = get_default_backend_configuration(nwbfile=nwbfile, backend=backend) + backend_configuration = get_default_backend_configuration(nwbfile=nwbfile, backend=backend) - for dataset_name, dataset_configuration in results.items(): + for dataset_name, dataset_configuration in backend_configuration_from_frontend.items(): for key, value in dataset_configuration.items(): if key not in PROPS_TO_IGNORE: - setattr(configuration.dataset_configurations[dataset_name], key, value) + backend_configuration.dataset_configurations[dataset_name][key] = value - return configuration + return backend_configuration def get_backend_configuration(info: dict) -> dict: @@ -990,7 +990,7 @@ def get_backend_configuration(info: dict) -> dict: info["overwrite"] = True # Always overwrite the file backend = info.get("backend", "hdf5") - configuration = extract_backend_configuration(info) + configuration = update_backend_configuration(info) def custom_encoder(obj): if isinstance(obj, np.ndarray): From f276c06877aa91f0bfb25f5169202f4c96a6d0a6 Mon Sep 17 00:00:00 2001 From: CodyCBakerPhD Date: Mon, 3 Jun 2024 13:56:23 -0400 Subject: [PATCH 06/12] removed unused helper --- .../manageNeuroconv/manage_neuroconv.py | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index 12dfc92dc..3b0ebd5b3 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -827,33 +827,6 @@ def get_interface_alignment(info: dict) -> dict: ) -def configure_dataset_backends( - nwbfile, backend: Optional[str] = None, backend_configuration: Optional[dict] = None -) -> None: - from neuroconv.tools.nwb_helpers import ( - configure_backend, - get_default_backend_configuration, - ) - - PROPS_TO_AVOID = ["full_shape"] - - backend = backend or "hdf5" - backend_configuration = backend_configuration or get_default_backend_configuration(nwbfile=nwbfile, backend=backend) - - for dataset_name, dataset_configuration in backend_configuration.items(): - for key, value in dataset_configuration.items(): - - # Avoid setting compression options if unspecified - if key == "compression_options" and (value is None or len(value) == 0): - setattr(configuration.dataset_configurations[name], key, None) - - # Avoid certain properties passed to the GUIDE - elif key not in PROPS_TO_AVOID: - setattr(configuration.dataset_configurations[name], key, value) - - configure_backend(nwbfile=nwbfile, backend_configuration=backend_configuration) - - def create_file( info: dict, log_url: Optional[str] = None, From 0b347d5dc28526d4a9b74cf347eefbe0d4ede241 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Mon, 3 Jun 2024 13:05:25 -0500 Subject: [PATCH 07/12] Fix logger --- src/pyflask/app.py | 7 ++-- .../manageNeuroconv/manage_neuroconv.py | 34 ++----------------- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/src/pyflask/app.py b/src/pyflask/app.py index 7b62ea2a4..3301c21a8 100644 --- a/src/pyflask/app.py +++ b/src/pyflask/app.py @@ -115,6 +115,7 @@ def post(self): message += f"\n{traceback}\n" selected_logger = getattr(api.logger, type) + api.logger.info(f"Logging {type} message: {header}") selected_logger(message) @@ -143,10 +144,10 @@ def get(self): ) log_handler.setFormatter(log_formatter) - flask_app.logger.addHandler(log_handler) - flask_app.logger.setLevel(DEBUG) + api.logger.addHandler(log_handler) + api.logger.setLevel(DEBUG) - flask_app.logger.info(f"Logging to {LOG_FILE_PATH}") + api.logger.info(f"Logging to {LOG_FILE_PATH}") # Run the server api.logger.info(f"Starting server on port {port}") diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index eac3b8a0d..be4c3a7ef 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -826,37 +826,6 @@ def get_interface_alignment(info: dict) -> dict: errors=errors, ) - -def configure_dataset_backends(nwbfile, backend_configuration, configuration=None): - from neuroconv.tools.nwb_helpers import ( - configure_backend, - get_default_backend_configuration, - ) - - PROPS_TO_AVOID = ["full_shape"] - - # Default to HDF5 backend configuration - if configuration is None: - configuration = get_default_backend_configuration(nwbfile=nwbfile, backend="hdf5") - - # Ensure the configuration is a dictionary - elif isinstance(configuration, str): - configuration = get_default_backend_configuration(nwbfile=nwbfile, backend=configuration) - - for name, item in backend_configuration.items(): - for key, value in item.items(): - - # Avoid setting compression options if unspecified - if key == "compression_options" and (value is None or len(value) == 0): - setattr(configuration.dataset_configurations[name], key, None) - - # Avoid certain properties passed to the GUIDE - elif key not in PROPS_TO_AVOID: - setattr(configuration.dataset_configurations[name], key, value) - - configure_backend(nwbfile=nwbfile, backend_configuration=configuration) - - def create_file( info: dict, log_url: Optional[str] = None, @@ -932,7 +901,7 @@ def update_conversion_progress(message): overwrite=overwrite, conversion_options=options, backend=backend, - backend_configuration=extract_backend_configuration(info), + backend_configuration=extract_backend_configuration(info) ) except Exception as e: @@ -963,6 +932,7 @@ def extract_backend_configuration(info: dict) -> dict: backend = backend_configuration.get("backend", "hdf5") results = backend_configuration.get("results", {}).get(backend, {}) + converter, metadata, __ = get_conversion_info(info) nwbfile = make_nwbfile_from_metadata(metadata=metadata) From dbb82059b96f1f15dbd7cc477082c0c25287944e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 18:06:26 +0000 Subject: [PATCH 08/12] [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 ee38ee862..3b0ebd5b3 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -826,6 +826,7 @@ def get_interface_alignment(info: dict) -> dict: errors=errors, ) + def create_file( info: dict, log_url: Optional[str] = None, @@ -932,7 +933,6 @@ def update_backend_configuration(info: dict) -> dict: backend = info_from_frontend.get("backend", "hdf5") backend_configuration_from_frontend = info_from_frontend.get("results", {}).get(backend, {}) - converter, metadata, __ = get_conversion_info(info) nwbfile = make_nwbfile_from_metadata(metadata=metadata) From 3cbc7d3c3594a14e257e7bf1ea0fed5e2f0f4ab9 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Mon, 3 Jun 2024 13:13:11 -0500 Subject: [PATCH 09/12] Notify of configuration issue --- .../guided-mode/data/GuidedBackendConfiguration.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/electron/frontend/core/components/pages/guided-mode/data/GuidedBackendConfiguration.js b/src/electron/frontend/core/components/pages/guided-mode/data/GuidedBackendConfiguration.js index 8051e1d64..d81dc4438 100644 --- a/src/electron/frontend/core/components/pages/guided-mode/data/GuidedBackendConfiguration.js +++ b/src/electron/frontend/core/components/pages/guided-mode/data/GuidedBackendConfiguration.js @@ -20,7 +20,6 @@ import { getResourceUsage } from "../../../../validation/backend-configuration"; import { resolveBackendResults, updateSchema } from "../../../../../../../schemas/backend-configuration.schema"; import { getInfoFromId } from "./utils.js"; -const getBackendConfigurations = (info, options = {}) => run(`neuroconv/configuration`, info, options); const itemIgnore = { full_shape: true, @@ -40,6 +39,11 @@ export class GuidedBackendConfigurationPage extends ManagedPage { this.style.height = "100%"; // Fix main section } + getBackendConfigurations = (info, options = {}) => run(`neuroconv/configuration`, info, options).catch(e => { + this.notify(e.message, "error"); + throw e; + }) + beforeSave = () => { merge(this.localState, this.info.globalState); }; @@ -228,13 +232,13 @@ export class GuidedBackendConfigurationPage extends ManagedPage { { title: "Getting backend options", }, - getBackendConfigurations + this.getBackendConfigurations ); }; validate = (toRun) => { if (!toRun) - return this.runConversions({}, true, { title: "Validating backend options" }, getBackendConfigurations); + return this.runConversions({}, true, { title: "Validating backend options" }, this.getBackendConfigurations); const { subject, session } = toRun; return this.runConversions( @@ -244,7 +248,7 @@ export class GuidedBackendConfigurationPage extends ManagedPage { title: "Validating backend options", showCancelButton: false, }, - getBackendConfigurations + this.getBackendConfigurations ); }; From 5fa437dab753c0d54a3466eb97308bbdd6294120 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 18:13:32 +0000 Subject: [PATCH 10/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../data/GuidedBackendConfiguration.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/electron/frontend/core/components/pages/guided-mode/data/GuidedBackendConfiguration.js b/src/electron/frontend/core/components/pages/guided-mode/data/GuidedBackendConfiguration.js index d81dc4438..101de4642 100644 --- a/src/electron/frontend/core/components/pages/guided-mode/data/GuidedBackendConfiguration.js +++ b/src/electron/frontend/core/components/pages/guided-mode/data/GuidedBackendConfiguration.js @@ -20,7 +20,6 @@ import { getResourceUsage } from "../../../../validation/backend-configuration"; import { resolveBackendResults, updateSchema } from "../../../../../../../schemas/backend-configuration.schema"; import { getInfoFromId } from "./utils.js"; - const itemIgnore = { full_shape: true, buffer_shape: true, @@ -39,10 +38,11 @@ export class GuidedBackendConfigurationPage extends ManagedPage { this.style.height = "100%"; // Fix main section } - getBackendConfigurations = (info, options = {}) => run(`neuroconv/configuration`, info, options).catch(e => { - this.notify(e.message, "error"); - throw e; - }) + getBackendConfigurations = (info, options = {}) => + run(`neuroconv/configuration`, info, options).catch((e) => { + this.notify(e.message, "error"); + throw e; + }); beforeSave = () => { merge(this.localState, this.info.globalState); @@ -238,7 +238,12 @@ export class GuidedBackendConfigurationPage extends ManagedPage { validate = (toRun) => { if (!toRun) - return this.runConversions({}, true, { title: "Validating backend options" }, this.getBackendConfigurations); + return this.runConversions( + {}, + true, + { title: "Validating backend options" }, + this.getBackendConfigurations + ); const { subject, session } = toRun; return this.runConversions( From 5ab0c167ee9d012304c31e004863955ea5004f7b Mon Sep 17 00:00:00 2001 From: CodyCBakerPhD Date: Mon, 3 Jun 2024 14:23:42 -0400 Subject: [PATCH 11/12] restore stattr --- 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 3b0ebd5b3..3b8474833 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -940,10 +940,11 @@ def update_backend_configuration(info: dict) -> dict: backend_configuration = get_default_backend_configuration(nwbfile=nwbfile, backend=backend) - for dataset_name, dataset_configuration in backend_configuration_from_frontend.items(): + for location_in_file, dataset_configuration in backend_configuration_from_frontend.items(): for key, value in dataset_configuration.items(): if key not in PROPS_TO_IGNORE: - backend_configuration.dataset_configurations[dataset_name][key] = value + # Pydantic models only allow setting of attributes + setattr(backend_configuration.dataset_configurations[location_in_file], key, value) return backend_configuration From dde939bb5b9e260cae2d11ae2df624c25cc3295e Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Tue, 4 Jun 2024 09:58:02 -0400 Subject: [PATCH 12/12] fix for stub mode --- src/pyflask/manageNeuroconv/manage_neuroconv.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pyflask/manageNeuroconv/manage_neuroconv.py b/src/pyflask/manageNeuroconv/manage_neuroconv.py index 3b8474833..0c97ad3ed 100644 --- a/src/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/src/pyflask/manageNeuroconv/manage_neuroconv.py @@ -895,16 +895,19 @@ def update_conversion_progress(message): progress_bar_options=progress_bar_options, ) - # Actually run the conversion - converter.run_conversion( + run_conversion_kwargs = dict( metadata=metadata, nwbfile_path=nwbfile_path, overwrite=overwrite, conversion_options=options, backend=backend, - backend_configuration=update_backend_configuration(info), ) + if not run_stub_test: + run_conversion_kwargs.update(dict(backend_configuration=update_backend_configuration(info))) + + converter.run_conversion(**run_conversion_kwargs) + except Exception as e: if log_url: requests.post(