| 407 | retry_condition = retry_if_exception(lambda exc: retry_config.should_retry(exc)) |
| 408 | |
| 409 | def _before_sleep(retry_state) -> None: |
| 410 | exc = retry_state.outcome.exception() |
| 411 | if exc is None: |
| 412 | return |
| 413 | attempt = retry_state.attempt_number |
| 414 | details = { |
| 415 | "attempt": attempt, |
| 416 | "max_attempts": retry_config.max_attempts, |
| 417 | "exception": exc.__class__.__name__, |
| 418 | } |
| 419 | self.log_manager.warning( |
| 420 | f"[Node: {node.id}] Model call attempt {attempt} failed: {exc}", |
| 421 | node_id=node.id, |
| 422 | details=details, |
| 423 | ) |
| 424 | |
| 425 | retrier = Retrying( |
| 426 | stop=stop_after_attempt(retry_config.max_attempts), |