Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix counter in Runner and Executor in case of any exception #995

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions src/ragas/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,7 @@ async def _aresults(self) -> t.List[t.Any]:
# whether you want to keep the progress bar after completion
leave=self.keep_progress_bar,
):
r = (-1, np.nan)
try:
r = await future
except MaxRetriesExceeded as e:
logger.warning(f"max retries exceeded for {e.evolution}")
except Exception as e:
if self.raise_exceptions:
raise e
else:
logger.error(
"Runner in Executor raised an exception", exc_info=True
)
r = await future
results.append(r)

return results
Expand All @@ -109,7 +98,20 @@ class Executor:

def wrap_callable_with_index(self, callable: t.Callable, counter):
async def wrapped_callable_async(*args, **kwargs):
return counter, await callable(*args, **kwargs)
result = np.nan
try:
result = await callable(*args, **kwargs)
except MaxRetriesExceeded as e:
logger.warning(f"max retries exceeded for {e.evolution}")
except Exception as e:
if self.raise_exceptions:
raise e
else:
logger.error(
"Runner in Executor raised an exception", exc_info=True
)

return counter, result

return wrapped_callable_async

Expand Down