Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Add some logging
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickkwang committed Aug 17, 2021
1 parent c2a30ef commit 808a3f1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions trapi_throttle/throttle.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def wrapper(*args, **kwargs):
return wrapper


async def anull(arg):
async def anull(arg, *args, **kwargs):
"""Do nothing, asynchronously."""
return arg

Expand Down Expand Up @@ -189,7 +189,16 @@ async def process_batch(
response_values = dict()
try:
# Make request
merged_request_value = await self.preproc(merged_request_value)
self.logger.info("[{id}] Sending request made of {subrequests} subrequests ({curies} curies)".format(
id = self.id,
subrequests=len(request_curie_mapping),
curies=" x ".join(
str(len(qnode.get("ids", []) or []))
for qnode in merged_request_value["message"]["query_graph"]["nodes"].values()
),
))
self.logger.context = self.id
merged_request_value = await self.preproc(merged_request_value, self.logger)
async with httpx.AsyncClient() as client:
response = await client.post(
self.url,
Expand Down Expand Up @@ -219,6 +228,8 @@ async def process_batch(
response = ReasonerResponse.parse_obj(response.json()).dict()
response = await self.postproc(response)
message = response["message"]
results = message.get("results") or []
self.logger.info(f"[{self.id}] Received response with {len(results)} results")

# Split using the request_curie_mapping
for request_id, curie_mapping in request_curie_mapping.items():
Expand Down

0 comments on commit 808a3f1

Please sign in to comment.