Skip to content

Commit

Permalink
more refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD committed Jun 3, 2024
1 parent 1bbd42c commit 5fc9132
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/pyflask/manageNeuroconv/manage_neuroconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
Expand All @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit 5fc9132

Please sign in to comment.