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

[ENH] Implemented pipeline_name and pipeline_version query params #121

Merged
merged 1 commit into from
Oct 15, 2024
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
10 changes: 10 additions & 0 deletions app/api/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ async def get(
min_num_phenotypic_sessions: int,
assessment: str,
image_modal: str,
pipeline_name: str,
pipeline_version: str,
node_urls: list[str],
) -> dict:
"""
Expand All @@ -67,6 +69,10 @@ async def get(
Non-imaging assessment completed by subjects.
image_modal : str
Imaging modality of subject scans.
pipeline_name : str
Name of pipeline run on subject scans.
pipeline_version : str
Version of pipeline run on subject scans.
node_urls : list[str]
List of Neurobagel nodes to send the query to.

Expand Down Expand Up @@ -101,6 +107,10 @@ async def get(
params["assessment"] = assessment
if image_modal:
params["image_modal"] = image_modal
if pipeline_name:
params["pipeline_name"] = pipeline_name
if pipeline_version:
params["pipeline_version"] = pipeline_version

tasks = [
util.send_get_request(node_url + "query", params)
Expand Down
3 changes: 3 additions & 0 deletions app/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class QueryModel(BaseModel):
min_num_phenotypic_sessions: int = None
assessment: str = None
image_modal: str = None
pipeline_name: str = None
pipeline_version: str = None
# TODO: Replace default value with union of local and public nodes once https://github.com/neurobagel/federation-api/issues/28 is merged
# syntax from https://github.com/tiangolo/fastapi/issues/4445#issuecomment-1117632409
node_url: list[str] | None = Field(Query(default=[]))
Expand All @@ -39,6 +41,7 @@ class CohortQueryResponse(BaseModel):
num_matching_subjects: int
subject_data: Union[list[dict], str]
image_modals: list
available_pipelines: dict


class NodesResponseStatus(str, Enum):
Expand Down
2 changes: 2 additions & 0 deletions app/api/routers/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ async def get_query(
query.min_num_phenotypic_sessions,
query.assessment,
query.image_modal,
query.pipeline_name,
query.pipeline_version,
query.node_url,
)

Expand Down
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,12 @@ def mocked_single_matching_dataset_result():
"http://purl.org/nidash/nidm#T1Weighted",
"http://purl.org/nidash/nidm#T2Weighted",
],
"available_pipelines": {
"https://github.com/nipoppy/pipeline-catalog/tree/main/processing/fmriprep": [
"23.1.3"
],
"https://github.com/nipoppy/pipeline-catalog/tree/main/processing/freesurfer": [
"7.3.2"
],
},
}