Skip to content

Commit

Permalink
Prepare to document or remove "pipeline search" endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
eecavanna committed Dec 2, 2024
1 parent 84e260c commit 27b58fb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
5 changes: 4 additions & 1 deletion nmdc_runtime/api/endpoints/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,18 +460,20 @@ def search_page(
return HTMLResponse(content=html_content, status_code=200)


# TODO: Confirm with endpoint's author whether they meant for it to receive data via query params, not the request body.
@router.post(
"/pipeline_search",
response_model=PipelineFindResponse,
response_model_exclude_unset=True,
)
def pipeline_search(
req: PipelineFindRequest = Depends(),
req: Annotated[PipelineFindRequest, Query()],
mdb: MongoDatabase = Depends(get_mongo_db),
):
return pipeline_find_resources(req, mdb)


# TODO: Exclude this endpoint from Swagger UI by including the `include_in_schema=False` kwarg in the router decorator.
@router.post(
"/pipeline_search_form",
response_model=PipelineFindResponse,
Expand All @@ -486,6 +488,7 @@ def pipeline_search(
return pipeline_find_resources(req, mdb)


# TODO: Exclude this endpoint from Swagger UI by including the `include_in_schema=False` kwarg in the router decorator.
@router.get("/pipeline_search", response_class=HTMLResponse)
def pipeline_search(
mdb: MongoDatabase = Depends(get_mongo_db),
Expand Down
13 changes: 11 additions & 2 deletions nmdc_runtime/api/models/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,17 @@ class PipelineFindRequest(BaseModel):
TODO: Document this class and its attributes.
"""

pipeline_spec: str
description: str
# TODO: Add real descriptions and examples to these parameter definitions.
pipeline_spec: str = Field(
title="Pipeline specification",
description="",
examples=[],
)
description: str = Field(
title="Pipeline description",
description="",
examples=[],
)


class FindResponse(BaseModel):
Expand Down
10 changes: 9 additions & 1 deletion nmdc_runtime/templates/pipeline_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@
<h1>NMDC Runtime Pipeline-Search Form</h1>
<p><a href="#examples">Examples below</a></p>


<!--
TODO: Clean this up.
1. Remove stray comma from `textarea` HTML element.
2. Display names of input fields on UI.
3. Explain the example(s)—what is `| part_of->id`?
4. The topmost example doesn't work (HTTP 500 Internal Server Error).
5. If this page is obsolete (or its author never meant for it to be in production),
deprecate it and then delete it to save maintenance cost.
-->
<form action="pipeline_search_form" method="post">
<textarea name="pipeline_spec" rows="5", cols="40">
</textarea>
Expand Down

0 comments on commit 27b58fb

Please sign in to comment.