From a2dde6834377f63f27a61908894ec40d30c5637d Mon Sep 17 00:00:00 2001 From: Alyssa Dai Date: Wed, 21 Aug 2024 17:10:24 -0400 Subject: [PATCH 1/3] add example n-API and f-API responses --- api-responses/fapi_query_fail_207.json | 14 ++ .../fapi_query_partial_success_207.json | 41 ++++ api-responses/fapi_query_success_200.json | 218 ++++++++++++++++++ .../napi_query_aggregated_results.json | 30 +++ .../napi_query_unaggregated_results.json | 183 +++++++++++++++ 5 files changed, 486 insertions(+) create mode 100644 api-responses/fapi_query_fail_207.json create mode 100644 api-responses/fapi_query_partial_success_207.json create mode 100644 api-responses/fapi_query_success_200.json create mode 100644 api-responses/napi_query_aggregated_results.json create mode 100644 api-responses/napi_query_unaggregated_results.json diff --git a/api-responses/fapi_query_fail_207.json b/api-responses/fapi_query_fail_207.json new file mode 100644 index 0000000..787f6e2 --- /dev/null +++ b/api-responses/fapi_query_fail_207.json @@ -0,0 +1,14 @@ +{ + "errors": [ + { + "node_name": "2 OpenNeuro Datasets", + "error": "Request failed due to a network error or because the node API could not be reached: [Errno -3] Temporary failure in name resolution" + }, + { + "node_name": "BIDS Synthetic", + "error": "Request failed due to a network error or because the node API could not be reached: [Errno -2] Name or service not known" + } + ], + "responses": [], + "nodes_response_status": "fail" +} \ No newline at end of file diff --git a/api-responses/fapi_query_partial_success_207.json b/api-responses/fapi_query_partial_success_207.json new file mode 100644 index 0000000..963f277 --- /dev/null +++ b/api-responses/fapi_query_partial_success_207.json @@ -0,0 +1,41 @@ +{ + "errors": [ + { + "node_name": "BIDS Synthetic", + "error": "Request failed due to a network error or because the node API could not be reached: [Errno -2] Name or service not known" + } + ], + "responses": [ + { + "node_name": "2 OpenNeuro Datasets", + "dataset_uuid": "http://neurobagel.org/vocab/1c9a29d8-9ce7-4bb6-9c44-f33ac504bcb4", + "dataset_name": "Balloon Analog Risk-taking Task", + "dataset_portal_uri": "https://github.com/OpenNeuroDatasets-JSONLD/ds000001.git", + "dataset_total_subjects": 16, + "records_protected": true, + "num_matching_subjects": 10, + "subject_data": "protected", + "image_modals": [ + "http://purl.org/nidash/nidm#T2Weighted", + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ] + }, + { + "node_name": "2 OpenNeuro Datasets", + "dataset_uuid": "http://neurobagel.org/vocab/c7bb6a5b-4066-4a59-b56c-3c6fe4d44b90", + "dataset_name": "Classification learning", + "dataset_portal_uri": "https://github.com/OpenNeuroDatasets-JSONLD/ds000002.git", + "dataset_total_subjects": 17, + "records_protected": true, + "num_matching_subjects": 10, + "subject_data": "protected", + "image_modals": [ + "http://purl.org/nidash/nidm#T2Weighted", + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ] + } + ], + "nodes_response_status": "partial success" +} \ No newline at end of file diff --git a/api-responses/fapi_query_success_200.json b/api-responses/fapi_query_success_200.json new file mode 100644 index 0000000..5ba9536 --- /dev/null +++ b/api-responses/fapi_query_success_200.json @@ -0,0 +1,218 @@ +{ + "errors": [], + "responses": [ + { + "node_name": "2 OpenNeuro Datasets", + "dataset_uuid": "http://neurobagel.org/vocab/1c9a29d8-9ce7-4bb6-9c44-f33ac504bcb4", + "dataset_name": "Balloon Analog Risk-taking Task", + "dataset_portal_uri": "https://github.com/OpenNeuroDatasets-JSONLD/ds000001.git", + "dataset_total_subjects": 16, + "records_protected": true, + "num_matching_subjects": 10, + "subject_data": "protected", + "image_modals": [ + "http://purl.org/nidash/nidm#T2Weighted", + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ] + }, + { + "node_name": "2 OpenNeuro Datasets", + "dataset_uuid": "http://neurobagel.org/vocab/c7bb6a5b-4066-4a59-b56c-3c6fe4d44b90", + "dataset_name": "Classification learning", + "dataset_portal_uri": "https://github.com/OpenNeuroDatasets-JSONLD/ds000002.git", + "dataset_total_subjects": 17, + "records_protected": true, + "num_matching_subjects": 10, + "subject_data": "protected", + "image_modals": [ + "http://purl.org/nidash/nidm#T2Weighted", + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ] + }, + { + "node_name": "BIDS Synthetic", + "dataset_uuid": "http://neurobagel.org/vocab/e0c7d08c-edcc-4c2a-816a-306878ed7be2", + "dataset_name": "BIDS synthetic", + "dataset_portal_uri": "https://github.com/bids-standard/bids-examples", + "dataset_total_subjects": 5, + "records_protected": false, + "num_matching_subjects": 2, + "subject_data": [ + { + "sub_id": "sub-01", + "session_id": "ses-01", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/ImagingSession", + "age": null, + "sex": null, + "diagnosis": [ + null + ], + "subject_group": null, + "assessment": [ + null + ], + "image_modal": [ + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ], + "session_file_path": "/data/neurobagel/bagel-cli/bids-examples/synthetic/sub-01/ses-01" + }, + { + "sub_id": "sub-01", + "session_id": "ses-01", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/PhenotypicSession", + "age": 34.1, + "sex": "http://purl.bioontology.org/ontology/SNOMEDCT/248152002", + "diagnosis": [ + null + ], + "subject_group": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C94342", + "assessment": [ + "https://www.cognitiveatlas.org/task/id/trm_57964b8a66aed", + "https://www.cognitiveatlas.org/task/id/tsk_4a57abb949ece" + ], + "image_modal": [ + null + ], + "session_file_path": null + }, + { + "sub_id": "sub-01", + "session_id": "ses-02", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/ImagingSession", + "age": null, + "sex": null, + "diagnosis": [ + null + ], + "subject_group": null, + "assessment": [ + null + ], + "image_modal": [ + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ], + "session_file_path": "/data/neurobagel/bagel-cli/bids-examples/synthetic/sub-01/ses-02" + }, + { + "sub_id": "sub-01", + "session_id": "ses-02", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/PhenotypicSession", + "age": 35.3, + "sex": "http://purl.bioontology.org/ontology/SNOMEDCT/248152002", + "diagnosis": [ + null + ], + "subject_group": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C94342", + "assessment": [ + "https://www.cognitiveatlas.org/task/id/trm_57964b8a66aed", + "https://www.cognitiveatlas.org/task/id/tsk_4a57abb949ece" + ], + "image_modal": [ + null + ], + "session_file_path": null + }, + { + "sub_id": "sub-04", + "session_id": "ses-01", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/ImagingSession", + "age": null, + "sex": null, + "diagnosis": [ + null + ], + "subject_group": null, + "assessment": [ + null + ], + "image_modal": [ + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ], + "session_file_path": "/data/neurobagel/bagel-cli/bids-examples/synthetic/sub-04/ses-01" + }, + { + "sub_id": "sub-04", + "session_id": "ses-01", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/PhenotypicSession", + "age": 21.1, + "sex": "http://purl.bioontology.org/ontology/SNOMEDCT/248152002", + "diagnosis": [ + null + ], + "subject_group": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C94342", + "assessment": [ + "https://www.cognitiveatlas.org/task/id/tsk_4a57abb949ece" + ], + "image_modal": [ + null + ], + "session_file_path": null + }, + { + "sub_id": "sub-04", + "session_id": "ses-02", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/ImagingSession", + "age": null, + "sex": null, + "diagnosis": [ + null + ], + "subject_group": null, + "assessment": [ + null + ], + "image_modal": [ + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ], + "session_file_path": "/data/neurobagel/bagel-cli/bids-examples/synthetic/sub-04/ses-02" + }, + { + "sub_id": "sub-04", + "session_id": "ses-02", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/PhenotypicSession", + "age": 22.3, + "sex": "http://purl.bioontology.org/ontology/SNOMEDCT/248152002", + "diagnosis": [ + null + ], + "subject_group": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C94342", + "assessment": [ + "https://www.cognitiveatlas.org/task/id/trm_57964b8a66aed", + "https://www.cognitiveatlas.org/task/id/tsk_4a57abb949ece" + ], + "image_modal": [ + null + ], + "session_file_path": null + } + ], + "image_modals": [ + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ] + } + ], + "nodes_response_status": "success" +} \ No newline at end of file diff --git a/api-responses/napi_query_aggregated_results.json b/api-responses/napi_query_aggregated_results.json new file mode 100644 index 0000000..957e9a8 --- /dev/null +++ b/api-responses/napi_query_aggregated_results.json @@ -0,0 +1,30 @@ +[ + { + "dataset_uuid": "http://neurobagel.org/vocab/1c9a29d8-9ce7-4bb6-9c44-f33ac504bcb4", + "dataset_name": "Balloon Analog Risk-taking Task", + "dataset_portal_uri": "https://github.com/OpenNeuroDatasets-JSONLD/ds000001.git", + "dataset_total_subjects": 16, + "records_protected": true, + "num_matching_subjects": 10, + "subject_data": "protected", + "image_modals": [ + "http://purl.org/nidash/nidm#T2Weighted", + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ] + }, + { + "dataset_uuid": "http://neurobagel.org/vocab/c7bb6a5b-4066-4a59-b56c-3c6fe4d44b90", + "dataset_name": "Classification learning", + "dataset_portal_uri": "https://github.com/OpenNeuroDatasets-JSONLD/ds000002.git", + "dataset_total_subjects": 17, + "records_protected": true, + "num_matching_subjects": 10, + "subject_data": "protected", + "image_modals": [ + "http://purl.org/nidash/nidm#T2Weighted", + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ] + } +] \ No newline at end of file diff --git a/api-responses/napi_query_unaggregated_results.json b/api-responses/napi_query_unaggregated_results.json new file mode 100644 index 0000000..58f131c --- /dev/null +++ b/api-responses/napi_query_unaggregated_results.json @@ -0,0 +1,183 @@ +[ + { + "dataset_uuid": "http://neurobagel.org/vocab/e0c7d08c-edcc-4c2a-816a-306878ed7be2", + "dataset_name": "BIDS synthetic", + "dataset_portal_uri": "https://github.com/bids-standard/bids-examples", + "dataset_total_subjects": 5, + "records_protected": false, + "num_matching_subjects": 2, + "subject_data": [ + { + "sub_id": "sub-01", + "session_id": "ses-01", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/ImagingSession", + "age": null, + "sex": null, + "diagnosis": [ + null + ], + "subject_group": null, + "assessment": [ + null + ], + "image_modal": [ + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ], + "session_file_path": "/data/neurobagel/bagel-cli/bids-examples/synthetic/sub-01/ses-01" + }, + { + "sub_id": "sub-01", + "session_id": "ses-01", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/PhenotypicSession", + "age": 34.1, + "sex": "http://purl.bioontology.org/ontology/SNOMEDCT/248152002", + "diagnosis": [ + null + ], + "subject_group": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C94342", + "assessment": [ + "https://www.cognitiveatlas.org/task/id/trm_57964b8a66aed", + "https://www.cognitiveatlas.org/task/id/tsk_4a57abb949ece" + ], + "image_modal": [ + null + ], + "session_file_path": null + }, + { + "sub_id": "sub-01", + "session_id": "ses-02", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/ImagingSession", + "age": null, + "sex": null, + "diagnosis": [ + null + ], + "subject_group": null, + "assessment": [ + null + ], + "image_modal": [ + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ], + "session_file_path": "/data/neurobagel/bagel-cli/bids-examples/synthetic/sub-01/ses-02" + }, + { + "sub_id": "sub-01", + "session_id": "ses-02", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/PhenotypicSession", + "age": 35.3, + "sex": "http://purl.bioontology.org/ontology/SNOMEDCT/248152002", + "diagnosis": [ + null + ], + "subject_group": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C94342", + "assessment": [ + "https://www.cognitiveatlas.org/task/id/trm_57964b8a66aed", + "https://www.cognitiveatlas.org/task/id/tsk_4a57abb949ece" + ], + "image_modal": [ + null + ], + "session_file_path": null + }, + { + "sub_id": "sub-04", + "session_id": "ses-01", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/ImagingSession", + "age": null, + "sex": null, + "diagnosis": [ + null + ], + "subject_group": null, + "assessment": [ + null + ], + "image_modal": [ + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ], + "session_file_path": "/data/neurobagel/bagel-cli/bids-examples/synthetic/sub-04/ses-01" + }, + { + "sub_id": "sub-04", + "session_id": "ses-01", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/PhenotypicSession", + "age": 21.1, + "sex": "http://purl.bioontology.org/ontology/SNOMEDCT/248152002", + "diagnosis": [ + null + ], + "subject_group": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C94342", + "assessment": [ + "https://www.cognitiveatlas.org/task/id/tsk_4a57abb949ece" + ], + "image_modal": [ + null + ], + "session_file_path": null + }, + { + "sub_id": "sub-04", + "session_id": "ses-02", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/ImagingSession", + "age": null, + "sex": null, + "diagnosis": [ + null + ], + "subject_group": null, + "assessment": [ + null + ], + "image_modal": [ + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ], + "session_file_path": "/data/neurobagel/bagel-cli/bids-examples/synthetic/sub-04/ses-02" + }, + { + "sub_id": "sub-04", + "session_id": "ses-02", + "num_matching_phenotypic_sessions": 2, + "num_matching_imaging_sessions": 2, + "session_type": "http://neurobagel.org/vocab/PhenotypicSession", + "age": 22.3, + "sex": "http://purl.bioontology.org/ontology/SNOMEDCT/248152002", + "diagnosis": [ + null + ], + "subject_group": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#C94342", + "assessment": [ + "https://www.cognitiveatlas.org/task/id/trm_57964b8a66aed", + "https://www.cognitiveatlas.org/task/id/tsk_4a57abb949ece" + ], + "image_modal": [ + null + ], + "session_file_path": null + } + ], + "image_modals": [ + "http://purl.org/nidash/nidm#T1Weighted", + "http://purl.org/nidash/nidm#FlowWeighted" + ] + } +] \ No newline at end of file From 124157215ba054e02b75c83166978be4fabdfd0a Mon Sep 17 00:00:00 2001 From: Alyssa Dai Date: Wed, 21 Aug 2024 17:10:41 -0400 Subject: [PATCH 2/3] add code to generate example api responses --- api-responses/make_api_responses.sh | 66 +++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 api-responses/make_api_responses.sh diff --git a/api-responses/make_api_responses.sh b/api-responses/make_api_responses.sh new file mode 100644 index 0000000..bf36b2a --- /dev/null +++ b/api-responses/make_api_responses.sh @@ -0,0 +1,66 @@ +# The following script sets up two test nodes, +# Test node 1: 2 OpenNeuro datasets, in the aggregate results mode +# Test node 2: the (default) BIDS Synthetic dataset, in the unaggregated results mode +# +# A full_stack deployment recipe will be used for Test node 1 to provide local federation. + +mkdir test_node1 test_node2 api-responses + +# SETUP FOR TEST NODE 1 +git clone https://github.com/neurobagel/recipes.git test_node1/recipes + +# Get the data +git clone https://github.com/neurobagel/openneuro-annotations.git test_node1/openneuro-annotations +mkdir test_node1/openneuro_mini_data +cp test_node1/openneuro-annotations/ds000001.jsonld test_node1/recipes/ds000001.jsonld test_node1/openneuro_mini_data + +cd test_node1/recipes +cp template.env .env + +sed -i 's/^LOCAL_GRAPH_DATA=.*/LOCAL_GRAPH_DATA=../openneuro_mini_data/' .env +sed -i 's/^NB_FEDERATE_REMOTE_PUBLIC_NODES=.*/NB_FEDERATE_REMOTE_PUBLIC_NODES=False/' .env +sed -i 's/^NB_API_QUERY_URL=.*/NB_API_QUERY_URL=http://localhost:8080/' .env +sed -i 's/^COMPOSE_PROFILES=.*/COMPOSE_PROFILES=full_stack/' .env + +# Use full container names to avoid conflicts +echo '[{"NodeName": "2 OpenNeuro Datasets", "ApiURL": "http://neurobagel_node-api-1:8000"},{"NodeName": "BIDS Synthetic", "ApiURL": "http://neurobagel_node2-api-1:8000"}]' > local_nb_nodes.json + +# Generate a partial success result (since Test node 2 isn't up yet) +docker compose up -d + +# WAIT FOR GRAPH TO FINISH BEING SET UP (?) +while ! curl --silent "localhost:7200/rest/repositories" -u "DBUSER:DBPASSWORD" | grep '\['; do + : +done + +# Query for female sex in f-API +curl -s http://localhost:8080/query?sex=snomed:248152002 | jq . > api-responses/fapi_query_partial_success_207.json + +# Generate a fail result (both nodes are not accessible) +docker stop neurobagel_node-api-1 +curl -s http://localhost:8080/query?sex=snomed:248152002 | jq . > api-responses/fapi_query_fail_207.json + +cd ../.. + +# SETUP FOR TEST NODE 2 +git clone https://github.com/neurobagel/recipes.git test_node2/recipes +cd test_node2/recipes +cp template.env .env + +sed -i 's/^COMPOSE_PROJECT_NAME=.*/COMPOSE_PROJECT_NAME=neurobagel_node2/' .env +sed -i 's/^NB_GRAPH_PORT_HOST=.*/NB_GRAPH_PORT_HOST=7201/' .env +sed -i 's/^NB_NAPI_PORT_HOST=.*/NB_NAPI_PORT_HOST=8001/' .env + +# Generate a full success result (both nodes are running and accessible) +# First, restart n-API for test node 1 +docker start neurobagel_node-api-1 +docker compose up -d +# Add second n-API to the network of the first node, so that the f-API can access the second n-API by container name +docker network add neurobagel_node_default neurobagel_node2-api-1 +curl -s http://localhost:8080/query?sex=snomed:248152002 | jq . > api-responses/fapi_query_success_207.json + + +# Generate query response where results are protected (test node 1) +curl -s http://localhost:8000/query?sex=snomed:248152002 | jq . > api-responses/napi_query_aggregated_results.json +# Generate query response where results are open (test node 2) +curl -s http://localhost:8001/query?sex=snomed:248152002 | jq . > api-responses/napi_query_unaggregated_results.json From 727baadfdf7a344c32794d7c6593796ce5fde2e3 Mon Sep 17 00:00:00 2001 From: Alyssa Dai Date: Thu, 22 Aug 2024 16:02:21 -0400 Subject: [PATCH 3/3] fix typo in dataset ID --- api-responses/make_api_responses.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api-responses/make_api_responses.sh b/api-responses/make_api_responses.sh index bf36b2a..a3d9c6e 100644 --- a/api-responses/make_api_responses.sh +++ b/api-responses/make_api_responses.sh @@ -12,7 +12,7 @@ git clone https://github.com/neurobagel/recipes.git test_node1/recipes # Get the data git clone https://github.com/neurobagel/openneuro-annotations.git test_node1/openneuro-annotations mkdir test_node1/openneuro_mini_data -cp test_node1/openneuro-annotations/ds000001.jsonld test_node1/recipes/ds000001.jsonld test_node1/openneuro_mini_data +cp test_node1/openneuro-annotations/ds000001.jsonld test_node1/recipes/ds000002.jsonld test_node1/openneuro_mini_data cd test_node1/recipes cp template.env .env