Skip to content

Commit

Permalink
clean up retry logging a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanMarten committed Dec 16, 2024
1 parent 06cf8ce commit 999e579
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ async def process_requests_from_file(
retry_request.generic_request.messages
)
attempt_number = self.max_retries - retry_request.attempts_left
logger.info(
f"Processing retry for request {retry_request.task_id} "
f"(attempt #{attempt_number} of {self.max_retries}). "
logger.debug(
f"Retrying request {retry_request.task_id} "
f"(attempt #{attempt_number} of {self.max_retries})"
f"Previous errors: {retry_request.result}"
)

Expand Down Expand Up @@ -480,18 +480,14 @@ async def handle_single_request_with_retries(
status_tracker.pbar.update(1)

except Exception as e:
logger.warning(
f"Request {request.task_id} failed with Exception: {e}, attempts left: {request.attempts_left}"
)
status_tracker.num_other_errors += 1
request.result.append(e)

if request.attempts_left > 0:
request.attempts_left -= 1
# Add retry queue logging
logger.info(
f"Adding request {request.task_id} to retry queue. Will retry in next available slot. "
f"Attempts remaining: {request.attempts_left}"
logger.warning(
f"Request {request.task_id} failed with Exception: {e} "
f"Retries left: {request.attempts_left}"
)
retry_queue.put_nowait(request)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,12 @@ async def call_single_request(
except litellm.NotFoundError as e:
cost = 0

if completion_obj.choices[0].finish_reason == "content_filter":
raise ValueError(
f"finish_reason was content_filter with raw response {completion_obj.model_dump()} for request {request.generic_request.messages}"
finish_reason = completion_obj.choices[0].finish_reason
if finish_reason != "stop":
logger.debug(
f"finish_reason {finish_reason} was not 'stop' with raw response {completion_obj.model_dump()} for request {request.generic_request.messages}"
)
raise ValueError(f"finish_reason was {finish_reason} ")

if response_message is None:
raise ValueError(
Expand Down

0 comments on commit 999e579

Please sign in to comment.