Skip to content

Commit

Permalink
Fix list content rendering and provide notes for future changes
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmflynn committed Apr 9, 2024
1 parent 2f2ed5f commit d687e5f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 29 deletions.
57 changes: 32 additions & 25 deletions pyflask/manageNeuroconv/manage_neuroconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,36 @@ def get_interface_alignment(info: dict) -> dict:
return timestamps


def configure_dataset_backends(nwbfile, backend_configuration, configuration = None):
from neuroconv.tools.nwb_helpers import get_default_backend_configuration, configure_backend

PROPS_TO_AVOID = [
"full_shape"
]

if (configuration is None):
configuration = get_default_backend_configuration(nwbfile=nwbfile, backend="hdf5")

for name, item in backend_configuration.items():
for key, value in item.items():

# Avoid setting compression options if unspecified
if (key == 'compression_options' and 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 get_backend_configuration(info: dict) -> dict:

import numpy as np
from neuroconv.tools.nwb_helpers import make_or_load_nwbfile, get_default_backend_configuration, HDF5BackendConfiguration, configure_backend
from neuroconv.tools.nwb_helpers import make_or_load_nwbfile, get_default_backend_configuration

backend_configuration = info.get("configuration")

Expand All @@ -685,11 +711,6 @@ def get_backend_configuration(info: dict) -> dict:
"dtype"
]

PROPS_TO_AVOID = [
"full_shape"
]


with make_or_load_nwbfile(
nwbfile_path=path_info["file"],
metadata=metadata,
Expand All @@ -703,28 +724,13 @@ def get_backend_configuration(info: dict) -> dict:
configuration = get_default_backend_configuration(nwbfile=nwbfile, backend="hdf5")

if 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 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)


configure_dataset_backends(nwbfile, backend_configuration, configuration)

def custom_encoder(obj):
if isinstance(obj, np.ndarray):
return obj.tolist()
if isinstance(obj, np.dtype):
return str(obj)
# Add more types as needed
raise TypeError(f"Object of type {obj.__class__.__name__} is not JSON serializable")

# neuroconv_api.logger.info(default_backend_configuration)
Expand Down Expand Up @@ -850,8 +856,9 @@ def convert_to_nwb(info: dict) -> str:
else None
)

# if (backend_configuration):
# configure_backend(nwbfile=nwbfile, backend_configuration=backend_configuration)
## NOTE: figure out how to actually set this on the output NWB file...
# if backend_configuration:
# configure_dataset_backends(nwbfile, backend_configuration)

# Actually run the conversion
converter.run_conversion(
Expand Down
10 changes: 7 additions & 3 deletions src/renderer/src/stories/List.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export class List extends LitElement {
overflow: auto;
}
ol {
margin: 0px;
}
#empty {
margin: 1rem;
Expand Down Expand Up @@ -327,10 +331,10 @@ export class List extends LitElement {
this.object[i] = value;
}

console.log(this)

if (isObjectContent) {} // Skip object contents

else if (content instanceof HTMLElement) li.append(editableElement = content)
if (content instanceof HTMLElement) li.append(editableElement = content)
else if (isObjectContent) {} // Skip other object contents

// Always attempt render of other items
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export class GuidedBackendConfigurationPage extends ManagedPage {
if (instance instanceof JSONSchemaForm) await instance.validate(); // Will throw an error in the callback
}

await this.getBackendConfiguration() // Validate by trying to set backend configuration with the latest values
// NOTE: Eventually you'll want to swap this to a full stub conversion with these options (which will fail the same...)
await this.getBackendConfiguration(true, { title: "Validating backend options..." }) // Validate by trying to set backend configuration with the latest values

return this.to(1);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export class GuidedStructurePage extends Page {
this.searchModal.toggle(false);
};

Object.assign(this.addButton.style, {
marginTop: '10px'
})

this.addButton.innerText = "Add Format";
this.addButton.onClick = () => {
this.search.shadowRoot.querySelector("input").focus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export class GuidedInspectorPage extends Page {
return html`
${until(
(async () => {
if (fileArr.length <= 1) {
this.report = inspector;
Expand Down Expand Up @@ -147,12 +148,17 @@ export class GuidedInspectorPage extends Page {
const path = getSharedPath(fileArr.map(({ info }) => info.file));
this.report = inspector;
if (!this.report) {
const result = await run("inspect_folder", { path, ...options }, { title: title + "s" });
this.report = globalState.preview.inspector = {
...result,
messages: truncateFilePaths(result.messages, path),
};
console.log(this.report, fileArr)
}
if (!inspector) await this.save();
Expand Down

0 comments on commit d687e5f

Please sign in to comment.