diff --git a/pyflask/apis/neuroconv.py b/pyflask/apis/neuroconv.py index 62028e365..abbb20fc4 100644 --- a/pyflask/apis/neuroconv.py +++ b/pyflask/apis/neuroconv.py @@ -68,7 +68,7 @@ def post(self): @neuroconv_api.route("/locate") -class Locate(Resource): +class LocateData(Resource): @neuroconv_api.doc(responses={200: "Success", 400: "Bad Request", 500: "Internal server error"}) def post(self): try: @@ -79,7 +79,7 @@ def post(self): @neuroconv_api.route("/locate/autocomplete") -class Locate(Resource): +class AutoCompleteFormatString(Resource): @neuroconv_api.doc(responses={200: "Success", 400: "Bad Request", 500: "Internal server error"}) def post(self): try: @@ -93,12 +93,13 @@ def post(self): class Metadata(Resource): @neuroconv_api.doc(responses={200: "Success", 400: "Bad Request", 500: "Internal server error"}) def post(self): - # try: - return get_metadata_schema(neuroconv_api.payload.get("source_data"), neuroconv_api.payload.get("interfaces")) - - # except Exception as exception: - # if notBadRequestException(exception): - # neuroconv_api.abort(500, str(exception)) + try: + return get_metadata_schema( + neuroconv_api.payload.get("source_data"), neuroconv_api.payload.get("interfaces") + ) + except Exception as exception: + if notBadRequestException(exception): + neuroconv_api.abort(500, str(exception)) @neuroconv_api.route("/convert") diff --git a/pyflask/manageNeuroconv/manage_neuroconv.py b/pyflask/manageNeuroconv/manage_neuroconv.py index 8dadce731..ee137a943 100644 --- a/pyflask/manageNeuroconv/manage_neuroconv.py +++ b/pyflask/manageNeuroconv/manage_neuroconv.py @@ -134,6 +134,7 @@ def coerce_schema_compliance_recursive(obj, schema): def autocomplete_format_string(info: dict) -> str: from neuroconv.tools.path_expansion import construct_path_template + from neuroconv.utils.json_schema import NWBMetaDataEncoder base_directory = info["base_directory"] filesystem_entry_path = info["path"] @@ -162,12 +163,13 @@ def autocomplete_format_string(info: dict) -> str: all_matched = locate_data(dict(autocomplete=to_locate_info)) - return dict(matched=all_matched, format_string=format_string) + return json.loads(json.dumps(obj=dict(matched=all_matched, format_string=format_string), cls=NWBMetaDataEncoder)) def locate_data(info: dict) -> dict: """Locate data from the specifies directories using fstrings.""" from neuroconv.tools import LocalPathExpander + from neuroconv.utils.json_schema import NWBMetaDataEncoder expander = LocalPathExpander() @@ -191,7 +193,7 @@ def locate_data(info: dict) -> dict: organized_output[subject_id][session_id] = item - return organized_output + return json.loads(json.dumps(obj=organized_output, cls=NWBMetaDataEncoder)) def module_to_dict(my_module):