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

[Feautre Reuqest] [Bug] Async + RAGAS #1819

Open
logan-markewich opened this issue Jan 7, 2025 · 4 comments
Open

[Feautre Reuqest] [Bug] Async + RAGAS #1819

logan-markewich opened this issue Jan 7, 2025 · 4 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request fix-me

Comments

@logan-markewich
Copy link

Describe the Feature
As far as I can tell, it seems like there is a lack of async functions in ragas, which leads to a lot of nesting async issues (since sync functions are calling async functions somewhere in the stack). Furthermore, nest_asyncio.apply() is automatically called in the import stack, which breaks a lot of applications

File "/usr/local/lib/python3.10/site-packages/ragas/executor.py", line 15, in <module>
2025-01-07 23:06:08     nest_asyncio.apply()

It would be awesome to have async functions like aevaluate instead of evaluate -- the approach I might take is make everything async first, and then get/create an event loop and run it there for the sync versions to avoid code duplication.

At the very least, removing the automatic nest_asyncio.apply() might be a good idea?

Why is the feature important for you?
Async code is the backbone of production systems -- without it, ragas will block the event loop of the server

Additional context
I THINK the workaround here for now is doing something like

def run_ragas(...):
  from app.evaluation.ragas import generate_dev_set, generate_dev_set_csv
  # other ragas imports

# Then, later on in your code
result = await asyncio.to_thread(run_ragas(...))

Which delays the ragas imports and runs it behind an isolated thread, which should be safe. But obviously not ideal

@logan-markewich logan-markewich added the enhancement New feature or request label Jan 7, 2025
@logan-markewich logan-markewich changed the title Async + RAGAS [Feautre Reuqest] [Bug] Async + RAGAS Jan 7, 2025
@dosubot dosubot bot added the bug Something isn't working label Jan 7, 2025
@jjmachan
Copy link
Member

jjmachan commented Jan 8, 2025

hey @logan-markewich 🙂 👋🏽

like you suggested the main culprit is the

File "/usr/local/lib/python3.10/site-packages/ragas/executor.py", line 15, in <module>
2025-01-07 23:06:08     nest_asyncio.apply()

now we added this as a dirty fix for the executor thread which was responsible for handling the logic "he approach I might take is make everything async first, and then get/create an event loop and run it there for the sync versions to avoid code duplication."

I'll do a bit more experiments and testing to remove the need for nesting_asyncio call.

@jjmachan
Copy link
Member

OpenHands started fixing the issue! You can monitor the progress here.

2 similar comments
@jjmachan
Copy link
Member

OpenHands started fixing the issue! You can monitor the progress here.

@jjmachan
Copy link
Member

OpenHands started fixing the issue! You can monitor the progress here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request fix-me
Projects
None yet
Development

No branches or pull requests

2 participants