Skip to content

Commit

Permalink
Merge pull request #33 from TranslatorSRI/remove_novelty
Browse files Browse the repository at this point in the history
Remove novelty
  • Loading branch information
maximusunc authored Oct 3, 2024
2 parents a88c5a1 + 397840b commit c5a4d87
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ logs/*
*.log
kgx/
data/
test_queries/
scripts/
18 changes: 9 additions & 9 deletions app/ordering_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ async def get_ordering_components(message, logger):
logger.debug(f"Computing scores for {len(message['results'])} results")
db_conn = redis.Redis(connection_pool=redis_pool)
novelty_scores = {}
try:
novelty_scores = await get_novelty(message, logger)
except Exception:
logger.error(f"Novelty score failed: {traceback.format_exc()}")
# try:
# novelty_scores = await get_novelty(message, logger)
# except Exception:
# logger.error(f"Novelty score failed: {traceback.format_exc()}")
for result in tqdm(message.get("results") or []):
confidence = 0.0
try:
Expand All @@ -73,8 +73,8 @@ async def get_ordering_components(message, logger):
"clinical_evidence": clinical_evidence_score,
"novelty": 0.0,
}
for node_bindings in result.get("node_bindings", {}).values():
for node_binding in node_bindings:
result["ordering_components"]["novelty"] = novelty_scores.get(
node_binding["id"], 0.0
)
# for node_bindings in result.get("node_bindings", {}).values():
# for node_binding in node_bindings:
# result["ordering_components"]["novelty"] = novelty_scores.get(
# node_binding["id"], 0.0
# )
14 changes: 7 additions & 7 deletions app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

openapi_args = dict(
title="SRI Answer Appraiser",
version="0.5.1",
version="0.6.0",
terms_of_service="",
description="SRI service that provides metrics for scoring and ordering of results",
trapi="1.5.0",
Expand Down Expand Up @@ -164,14 +164,14 @@ async def get_appraisal(
)


@APP.post("/get_appraisal", response_model=Response)
async def sync_get_appraisal(query: Query = Body(..., example=EXAMPLE)):
@APP.post("/get_appraisal")
async def sync_get_appraisal(query=Body(..., example=EXAMPLE)):
qid = str(uuid4())[:8]
query_dict = query.dict()
log_level = query_dict.get("log_level") or "INFO"
# query_dict = query.dict()
log_level = query.get("log_level") or "INFO"
logger = get_logger(qid, log_level)
logger.info("Starting sync appraisal")
message = query_dict["message"]
message = query["message"]
if not message.get("results"):
return JSONResponse(
content={"status": "Rejected", "description": "No Results.", "job_id": qid},
Expand All @@ -182,7 +182,7 @@ async def sync_get_appraisal(query: Query = Body(..., example=EXAMPLE)):
except Exception:
logger.error(f"Something went wrong while appraising: {traceback.format_exc()}")
logger.info("Done appraising")
return Response(message=message)
return query


@APP.get("/redis_ready")
Expand Down

0 comments on commit c5a4d87

Please sign in to comment.