Skip to content

Commit

Permalink
removing the /overlay endpoint, cleaning up /query exceptions, improv…
Browse files Browse the repository at this point in the history
…ing some summaries and descriptions for openapi
  • Loading branch information
EvanDietzMorris committed Apr 17, 2024
1 parent 4e0c9eb commit 4bedc42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 256 deletions.
216 changes: 0 additions & 216 deletions PLATER/examples/overlay.json

This file was deleted.

50 changes: 10 additions & 40 deletions PLATER/services/app_trapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ async def get_meta_knowledge_graph() -> ORJSONResponse:
response_model=None,
responses={200: {"model": MetaKnowledgeGraph}},
summary="Meta knowledge graph representation of this TRAPI web service.",
description="Returns meta knowledge graph representation of this TRAPI web service.",
description="Returns a meta knowledge graph representation of this TRAPI web service. The meta knowledge graph is "
"composed of the union of most specific categories and predicates for each node and edge.",
tags=["trapi"]
)

Expand All @@ -104,7 +105,9 @@ async def reasoner_api(
...,
example=TRAPI_QUERY_EXAMPLE,
),
profile: bool = False, # looks like it's not used, but it's here so that it's documented in the open api spec
# it looks like the parameter profile is not used, but it is
# it's here so that it's documented in the open api spec, and it's used by pyinstrument in profile_request
profile: bool = False,
validate: bool = False,
graph_interface: GraphInterface = Depends(get_graph_interface),
) -> CustomORJSONResponse:
Expand All @@ -120,15 +123,8 @@ async def reasoner_api(
try:
response_message = await question.answer(graph_interface)
request_json.update({'message': response_message, 'workflow': workflow})
except InvalidPredicateError as e:
except (InvalidPredicateError, InvalidQualifierError, InvalidQualifierValueError, UnsupportedError) as e:
return CustomORJSONResponse(status_code=400, content={"description": str(e)}, media_type="application/json")
except InvalidQualifierError as e:
return CustomORJSONResponse(status_code=400, content={"description": str(e)}, media_type="application/json")
except InvalidQualifierValueError as e:
return CustomORJSONResponse(status_code=400, content={"description": str(e)}, media_type="application/json")
except UnsupportedError as e:
return CustomORJSONResponse(status_code=400, content={"description": str(e)}, media_type="application/json")

elif 'overlay_connect_knodes' in workflows:
overlay = Overlay(graph_interface=graph_interface)
response_message = await overlay.connect_k_nodes(request_json['message'])
Expand Down Expand Up @@ -159,8 +155,8 @@ async def reasoner_api(
methods=["POST"],
response_model=None,
responses={400: {"model": Dict}, 200: {"model": ReasonerRequest}},
summary="Query reasoner via one of several inputs.",
description="",
summary="Accepts TRAPI Queries.",
description="Accepts a TRAPI Query and returns a TRAPI Response. (https://github.com/NCATSTranslator/ReasonerAPI/)",
tags=["trapi"]
)

Expand Down Expand Up @@ -190,41 +186,15 @@ async def cypher(
cypher,
methods=["POST"],
response_model=CypherResponse,
summary="Run cypher query",
summary="Run a Neo4j cypher query.",
description=(
"Runs cypher query against the Neo4j instance, and returns an "
"Runs a cypher query against the Neo4j instance, and returns an "
"equivalent response expected from a Neo4j HTTP endpoint "
"(https://neo4j.com/docs/rest-docs/current/)."
),
)


async def overlay(
request: ReasonerRequest = Body(
...,
example={"message": get_example("overlay")},
),
graph_interface: GraphInterface = Depends(get_graph_interface),
) -> Message:
"""Handle TRAPI request."""
overlay_class = Overlay(graph_interface)
return await overlay_class.overlay_support_edges(request.dict()["message"])


APP.add_api_route(
"/overlay",
overlay,
methods=["POST"],
response_model=Message,
description=(
"Given a ReasonerAPI graph, add support edges for any nodes linked in "
"result bindings."
),
summary="Overlay results with available connections between each node.",
tags=["translator"]
)


async def metadata() -> Any:
"""Handle /metadata."""
return GRAPH_METADATA
Expand Down

0 comments on commit 4bedc42

Please sign in to comment.