Handles evaluation retries with exponential backoff.
(data)
| 46 | data_list.append(data) |
| 47 | |
| 48 | def call(data): |
| 49 | """Handles evaluation retries with exponential backoff.""" |
| 50 | max_retries = 10 |
| 51 | for attempt in range(max_retries): |
| 52 | try: |
| 53 | return evaluator.evaluate_strings( |
| 54 | prediction=data["pred"], |
| 55 | input=data["question"], |
| 56 | reference=data["answer"] |
| 57 | ) |
| 58 | except Exception as e: |
| 59 | print(f"Error during evaluation: {e}") |
| 60 | if attempt < max_retries - 1: |
| 61 | time.sleep(1 * (2 ** attempt)) # Exponential backoff |
| 62 | else: |
| 63 | raise e # Raise the exception if the last retry fails |
| 64 | |
| 65 | s = 0 |
| 66 | cnt = 0 |
nothing calls this directly
no outgoing calls
no test coverage detected