Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNT] Removed session_file_path from aggregate results #214

Merged
merged 6 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions app/api/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,7 @@ async def get(
by=dataset_cols
):
if util.RETURN_AGG.val:
subject_data = list(
{"session_file_path": file_path}
for file_path in group["session_file_path"].dropna()
)
subject_data = "protected"
else:
subject_data = (
group.drop(dataset_cols, axis=1)
Expand Down
4 changes: 2 additions & 2 deletions app/api/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Data models."""

from enum import Enum
from typing import Optional
from typing import Optional, Union

from fastapi import Query
from fastapi.exceptions import HTTPException
Expand Down Expand Up @@ -60,7 +60,7 @@ class CohortQueryResponse(BaseModel):
dataset_portal_uri: Optional[str]
records_protected: bool
num_matching_subjects: int
subject_data: list[dict]
subject_data: Union[list[dict], str]
image_modals: list


Expand Down
4 changes: 2 additions & 2 deletions app/api/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ def create_query(
# wrap query in an aggregating statement so data returned from graph include only attributes needed for dataset-level aggregate metadata.
if return_agg:
query_string = f"""
SELECT ?dataset_uuid ?dataset_name ?dataset_portal_uri ?sub_id ?session_file_path ?image_modal WHERE {{\n
SELECT ?dataset_uuid ?dataset_name ?dataset_portal_uri ?sub_id ?image_modal WHERE {{\n
{query_string}
\n}} GROUP BY ?dataset_uuid ?dataset_name ?dataset_portal_uri ?sub_id ?session_file_path ?image_modal
\n}} GROUP BY ?dataset_uuid ?dataset_name ?dataset_portal_uri ?sub_id ?image_modal
"""

return "\n".join([create_context(), query_string])
Expand Down
26 changes: 2 additions & 24 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ def test_data():
"dataset_portal_uri": "https://rpq-qpn.ca/en/researchers-section/databases/",
"num_matching_subjects": 5,
"records_protected": True,
"subject_data": [
{"session_file_path": "/my/happy/path/sub-0051/to/session-01"},
{"session_file_path": "/my/happy/path/sub-0653/to/session-01"},
{"session_file_path": "/my/happy/path/sub-1063/to/session-01"},
{"session_file_path": "/my/happy/path/sub-1113/to/session-01"},
{"session_file_path": "/my/happy/path/sub-1170/to/session-01"},
],
"subject_data": "protected",
"image_modals": [
"http://purl.org/nidash/nidm#T1Weighted",
"http://purl.org/nidash/nidm#T2Weighted",
Expand All @@ -38,23 +32,7 @@ def test_data():
"dataset_portal_uri": "https://www.ppmi-info.org/access-data-specimens/download-data",
"num_matching_subjects": 3,
"records_protected": True,
"subject_data": [
{
"session_file_path": "/my/happy/path/sub-719238/to/session-01"
},
{
"session_file_path": "/my/happy/path/sub-719341/to/session-01"
},
{
"session_file_path": "/my/happy/path/sub-719369/to/session-01"
},
{
"session_file_path": "/my/happy/path/sub-719238/to/session-02"
},
{
"session_file_path": "/my/happy/path/sub-719341/to/session-02"
},
],
"subject_data": "protected",
"image_modals": [
"http://purl.org/nidash/nidm#FlowWeighted",
"http://purl.org/nidash/nidm#T1Weighted",
Expand Down