Skip to content

Commit

Permalink
Merge branch 'backend-configuration-uniform' of https://github.com/Ne…
Browse files Browse the repository at this point in the history
…urodataWithoutBorders/nwb-guide into backend-configuration-uniform
  • Loading branch information
garrettmflynn committed Jun 3, 2024
2 parents 0b347d5 + f276c06 commit a5eaeec
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 @@ -901,7 +901,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 @@ -919,7 +919,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 @@ -928,24 +928,24 @@ 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 @@ -963,7 +963,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 a5eaeec

Please sign in to comment.