Skip to content

Commit

Permalink
fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
micheldumontier committed Aug 27, 2024
1 parent 2c962cd commit f85df16
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
7 changes: 5 additions & 2 deletions src/trapi_predict_kit/trapi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import os
import time
from typing import Any, Callable, Dict, List, Optional
import logging

from fastapi import Body, FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
Expand Down Expand Up @@ -319,8 +319,11 @@ def add_opentelemetry(app: FastAPI, service_name: str) -> None:
RequestsInstrumentor().instrument()
HTTPXClientInstrumentor().instrument()

# Filter out /health endpoint to stop flooding uvicorn log

# Filter out /health endpoint to stop flooding uvicorn log
class EndpointFilter(logging.Filter):
def filter(self, record: logging.LogRecord) -> bool:
return record.getMessage().find("/health") == -1


logging.getLogger("uvicorn.access").addFilter(EndpointFilter())
27 changes: 17 additions & 10 deletions src/trapi_predict_kit/trapi_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,28 @@ def resolve_trapi_query(reasoner_query, endpoints_list, infores: str = ""):
"score": association_score,
# "dummy_score": 0.42,
"scoring_method": "Model confidence between 0 and 1",
"edge_bindings": {edge_qg_id: [{"id": edge_kg_id,
"attributes": [],}]},
"edge_bindings": {
edge_qg_id: [
{
"id": edge_kg_id,
"attributes": [],
}
]
},
}
],
}
result["node_bindings"][query_plan[edge_id]["qg_subject_node_id"]] = [
{"id": association["subject"],
"attributes": [],}
{
"id": association["subject"],
"attributes": [],
}
]
result["node_bindings"][query_plan[edge_id]["qg_object_node_id"]] = [
{"id": association["object"],
"attributes": [],}
{
"id": association["object"],
"attributes": [],
}
]
query_results.append(result)

Expand All @@ -301,10 +311,7 @@ def resolve_trapi_query(reasoner_query, endpoints_list, infores: str = ""):
node_category = "biolink:" + node_category.capitalize()
if isinstance(node_category, str):
node_category = [node_category]
node_to_add = {
"categories": node_category,
"attributes": []
}
node_to_add = {"categories": node_category, "attributes": []}
if "label" in properties and properties["label"]:
node_to_add["name"] = properties["label"]
knowledge_graph["nodes"][node_id] = node_to_add
Expand Down

0 comments on commit f85df16

Please sign in to comment.