-
Notifications
You must be signed in to change notification settings - Fork 660
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
ValueError: Can't patch loop of type <class 'uvloop.Loop'> #1270
Comments
Hey there, @gustavo-has-stone! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this together! To resolve the You can modify the def results(self) -> t.List[t.Any]:
if is_event_loop_running():
# an event loop is running so call nested_asyncio to fix this
try:
import uvloop
if isinstance(asyncio.get_event_loop(), uvloop.Loop):
raise RuntimeError("Cannot use nest_asyncio with uvloop")
except ImportError:
pass
try:
import nest_asyncio
except ImportError:
raise ImportError(
"It seems like you're running this in a jupyter-like environment. Please install nest_asyncio with `pip install nest_asyncio` to make it work."
)
if not self._nest_asyncio_applied:
nest_asyncio.apply()
self._nest_asyncio_applied = True
# create a generator for which returns tasks as they finish
futures_as_they_finish = as_completed(
coros=[afunc(*args, **kwargs) for afunc, args, kwargs, _ in self.jobs],
max_workers=(self.run_config or RunConfig()).max_workers,
)
async def _aresults() -> t.List[t.Any]:
results = []
for future in tqdm(
futures_as_they_finish,
desc=self.desc,
total=len(self.jobs),
# whether you want to keep the progress bar after completion
leave=self.keep_progress_bar,
):
r = await future
results.append(r)
return results
results = asyncio.run(_aresults())
sorted_results = sorted(results, key=lambda x: x[0])
return [r[1] for r in sorted_results] This modification checks if |
Hi, I also encountered the same error using ragas versions earlier than 0.1.15 (I would say I tried 0.1.1 to 0.1.6). Do you know what is a way to solve the problem other than editing the Thank you very much! |
I'm having the same issue,Can't patch loop of type <class 'uvloop.Loop'>。Did you solve it? |
I didn't. The only workaround I know would involve using asyncio when running uvicorn |
I'm really introducing Ragas in the Sanic frame, |
[x] I have checked the documentation and related resources and couldn't resolve my bug.
Describe the bug
I am trying to integrate RAGAS with an API based on FastAPI, and I'm getting an error:
ValueError: Can't patch loop of type <class 'uvloop.Loop'>
Ragas version: 0.1.15
Python version: 3.10.12
Code to Reproduce
Error trace
Expected behavior
I expected to be able to integrate RAGAS with our API based on FastAPI
Additional context
The text was updated successfully, but these errors were encountered: