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

Incompatibility of adaptive (asyncio) with python=3.10 #344

Closed
juandaanieel opened this issue May 23, 2022 · 4 comments · Fixed by #348
Closed

Incompatibility of adaptive (asyncio) with python=3.10 #344

juandaanieel opened this issue May 23, 2022 · 4 comments · Fixed by #348

Comments

@juandaanieel
Copy link
Contributor

When executing an adaptive example, the runner fails due to a keyword error.
This error has been found before. It requires to remove the loop keyword since it is not anymore supported by python 3.10.

The minimal code that produces the problem is:

import adaptive
import numpy as np
adaptive.notebook_extension()

def ring(xy):
    x, y = xy
    a = 0.2
    return x + np.exp(-(x**2 + y**2 - 0.75**2)**2/a**4)

learner = adaptive.Learner2D(ring, bounds=[(-1, 1), (-1, 1)])
runner = adaptive.Runner(learner, goal=lambda l: l.loss() < 0.01)
runner.task.result()

The error is:

TypeError                                 Traceback (most recent call last)
Input In [27], in <cell line: 1>()
----> 1 runner.task.result()

File /opt/conda/lib/python3.10/site-packages/adaptive/runner.py:584, in AsyncRunner.status(self)
    579 """Return the runner status as a string.
    580 
    581 The possible statuses are: running, cancelled, failed, and finished.
    582 """
    583 try:
--> 584     self.task.result()
    585 except asyncio.CancelledError:
    586     return "cancelled"

File /opt/conda/lib/python3.10/site-packages/adaptive/runner.py:584, in AsyncRunner.status(self)
    579 """Return the runner status as a string.
    580 
    581 The possible statuses are: running, cancelled, failed, and finished.
    582 """
    583 try:
--> 584     self.task.result()
    585 except asyncio.CancelledError:
    586     return "cancelled"

File /opt/conda/lib/python3.10/site-packages/adaptive/runner.py:645, in AsyncRunner._run(self)
    643     while not self.goal(self.learner):
    644         futures = self._get_futures()
--> 645         done, _ = await asyncio.wait(
    646             futures, return_when=first_completed, loop=self.ioloop
    647         )
    648         self._process_futures(done)
    649 finally:

TypeError: wait() got an unexpected keyword argument 'loop'
@akhmerov
Copy link
Contributor

@basnijholt
Copy link
Member

Thanks for reporting! I'll fix this soon and add CI Python 3.10 testing.

@basnijholt
Copy link
Member

I have added Python 3.10 to the CI and fixed this issue in #348 (which should autocomplete in about 20 min).

@basnijholt
Copy link
Member

@juandaanieel, I have also released v0.13.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants