-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into improve-list-rendering-for-structure
- Loading branch information
Showing
73 changed files
with
1,825 additions
and
619 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
from pathlib import Path | ||
import json | ||
from neuroconv import datainterfaces, NWBConverter | ||
|
||
filepath = Path("guideGlobalMetadata.json") | ||
generatedJSONSchemaPath = Path("schemas", "json", "generated") | ||
generatedJSONSchemaPath.mkdir(exist_ok=True, parents=True) | ||
|
||
f = filepath.open() | ||
data = json.load(f) | ||
|
||
# Create JSON for the Schema | ||
paths = {} | ||
for interface in data["supported_interfaces"]: | ||
interface_class_dict = {interface: interface} | ||
|
||
class CustomNWBConverter(NWBConverter): | ||
data_interface_classes = { | ||
custom_name: getattr(datainterfaces, interface_name) | ||
for custom_name, interface_name in interface_class_dict.items() | ||
} | ||
|
||
schema = CustomNWBConverter.get_source_schema() | ||
|
||
json_object = json.dumps(schema, indent=4) | ||
paths[interface] = filepath = generatedJSONSchemaPath / f"{interface}.json" | ||
with open(filepath, "w") as outfile: | ||
outfile.write(json.dumps(schema, indent=4)) | ||
|
||
|
||
sourceDataStoryPath = Path("src/renderer/src/stories/pages/guided-mode/SourceData.stories.js") | ||
|
||
importCode = "\n".join(map(lambda arr: f"import {arr[0]}Schema from '../../../../../../{arr[1]}'", paths.items())) | ||
storyCode = "\n".join( | ||
map( | ||
lambda arr: f"""export const {arr[0]} = PageTemplate.bind({{}}); | ||
const {arr[0]}GlobalCopy = JSON.parse(JSON.stringify(globalState)) | ||
{arr[0]}GlobalCopy.interfaces.interface = {arr[0]} | ||
{arr[0]}GlobalCopy.schema.source_data = {arr[0]}Schema | ||
{arr[0]}.args = {{ activePage, globalState: {arr[0]}GlobalCopy }}; | ||
""", | ||
paths.items(), | ||
) | ||
) | ||
|
||
|
||
allInterfaceCode = "\n".join( | ||
map( | ||
lambda arr: f"globalStateCopy.schema.source_data.properties.{arr[0]} = {arr[0]}Schema.properties.{arr[0]}", | ||
paths.items(), | ||
) | ||
) | ||
|
||
setDummyPathCode = f""" | ||
const results = globalStateCopy.results | ||
for (let sub in results){{ | ||
for (let ses in results[sub]) results[sub][ses].source_data = {{{list(paths.keys())[1]}: {{file_path: '/dummy/file/path'}}}} | ||
}} | ||
""" | ||
|
||
with open(sourceDataStoryPath, "w") as outfile: | ||
outfile.write( | ||
f"""import {{ globalState, PageTemplate }} from "./storyStates"; | ||
{importCode} | ||
export default {{ | ||
title: "Pages/Guided Mode/Source Data", | ||
parameters: {{ | ||
chromatic: {{ disableSnapshot: false }}, | ||
}} | ||
}}; | ||
const activePage = "conversion/sourcedata" | ||
const globalStateCopy = JSON.parse(JSON.stringify(globalState)) | ||
{allInterfaceCode} | ||
{setDummyPathCode} | ||
export const All = PageTemplate.bind({{}}); | ||
All.args = {{ activePage, globalState: globalStateCopy }}; | ||
{storyCode} | ||
""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import requests | ||
|
||
|
||
def get(path, client): | ||
if isinstance(client, str): | ||
r = requests.get(f"{client}/{path}", allow_redirects=True) | ||
r.raise_for_status() | ||
return r.json() | ||
else: | ||
return client.get(f"/{path}", follow_redirects=True).json | ||
|
||
|
||
def post(path, json, client): | ||
if isinstance(client, str): | ||
r = requests.post(f"{client}/{path}", json=json, allow_redirects=True) | ||
r.raise_for_status() | ||
return r.json() | ||
else: | ||
return client.post(path, json=json, follow_redirects=True).json | ||
|
||
|
||
def get_converter_output_schema(interfaces: dict): | ||
return { | ||
"type": "object", | ||
"properties": { | ||
"title": {"type": "string"}, | ||
"description": {"type": "string"}, | ||
"version": {"type": "string"}, | ||
"properties": { | ||
"type": "object", | ||
"properties": { | ||
interface: { | ||
"type": "object", | ||
"properties": { | ||
"properties": {"type": "object"}, | ||
"required": {"type": "array"}, | ||
}, | ||
} | ||
for interface in interfaces.keys() | ||
}, | ||
"additionalProperties": False, | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"required": [], | ||
"properties": { | ||
"BiocamRecordingInterface": { | ||
"required": [ | ||
"file_path" | ||
], | ||
"properties": { | ||
"file_path": { | ||
"format": "file", | ||
"type": "string" | ||
}, | ||
"verbose": { | ||
"type": "boolean", | ||
"default": true | ||
}, | ||
"es_key": { | ||
"type": "string", | ||
"default": "ElectricalSeries" | ||
} | ||
}, | ||
"type": "object", | ||
"additionalProperties": false | ||
} | ||
}, | ||
"type": "object", | ||
"additionalProperties": false, | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "source.schema.json", | ||
"title": "Source data schema", | ||
"description": "Schema for the source data, files and directories", | ||
"version": "0.1.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"required": [], | ||
"properties": { | ||
"BlackrockRecordingInterface": { | ||
"required": [ | ||
"file_path" | ||
], | ||
"properties": { | ||
"file_path": { | ||
"format": "file", | ||
"type": "string", | ||
"description": "Path to Blackrock file." | ||
}, | ||
"nsx_override": { | ||
"format": "file", | ||
"type": "string" | ||
}, | ||
"verbose": { | ||
"type": "boolean", | ||
"default": true | ||
}, | ||
"es_key": { | ||
"type": "string", | ||
"default": "ElectricalSeries" | ||
} | ||
}, | ||
"type": "object", | ||
"additionalProperties": false | ||
} | ||
}, | ||
"type": "object", | ||
"additionalProperties": false, | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "source.schema.json", | ||
"title": "Source data schema", | ||
"description": "Schema for the source data, files and directories", | ||
"version": "0.1.0" | ||
} |
Oops, something went wrong.