Skip to content

Commit

Permalink
Better logging
Browse files Browse the repository at this point in the history
  • Loading branch information
betaprior committed Aug 15, 2024
1 parent 1df78db commit 289f692
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions perspective_ranker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
datefmt="%Y-%m-%d %H:%M:%S",
)
logger = logging.getLogger(__name__)
log_level = os.getenv("LOGGING_LEVEL", "INFO")
numeric_level = logging.getLevelName(log_level.upper())
if not isinstance(numeric_level, int):
numeric_level = logging.INFO
logger.setLevel(numeric_level)
logger.info("Starting up")

PERSPECTIVE_HOST = os.getenv(
Expand Down Expand Up @@ -129,12 +134,12 @@ async def score(self, attributes, statement, statement_id):
try:
score = response["attributeScores"][attr]["summaryScore"]["value"]
except KeyError:
score = 0 # for now, set the score to 0 if it wasn't possible get a score
score = (
0 # for now, set the score to 0 if it wasn't possible get a score
)
scorable = False

results.append(
(attr, score)
)
results.append((attr, score))

result = self.ScoredStatement(statement, results, statement_id, scorable)

Expand Down Expand Up @@ -200,7 +205,8 @@ def arm_sort(self, scored_statements):
async def main(ranking_request: RankingRequest) -> RankingResponse:
ranker = PerspectiveRanker()
results = await ranker.ranker(ranking_request)
return results
logger.debug(f"ranking results: {results}")
return RankingResponse(ranked_ids=results["ranked_ids"])


@app.get("/health")
Expand Down

0 comments on commit 289f692

Please sign in to comment.