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

SequenceLearner with unhashable entries in sequence break Runner #265

Open
basnijholt opened this issue Apr 14, 2020 · 0 comments
Open

SequenceLearner with unhashable entries in sequence break Runner #265

basnijholt opened this issue Apr 14, 2020 · 0 comments

Comments

@basnijholt
Copy link
Member

basnijholt commented Apr 14, 2020

When a SequenceLearner that has unhashable entries in sequence (e.g., List[dict]) fails, the Runner breaks.

This happens because of the dict[x] in

adaptive/adaptive/runner.py

Lines 204 to 210 in 0f85d3a

except Exception as e:
self.tracebacks[x] = traceback.format_exc()
self.to_retry[x] = self.to_retry.get(x, 0) + 1
if self.to_retry[x] > self.retries:
self.to_retry.pop(x)
if self.raise_if_retries_exceeded:
self._do_raise(e, x)

Reproduce with:

import adaptive
import numpy as np

adaptive.notebook_extension()

def f(dct):
    import random

    if random.random() < 0.5:
        raise Exception()
    return dct["x"]


seq = [dict(x=x) for x in np.linspace(-1, 1, 101)]  # unhashable

learner = adaptive.SequenceLearner(f, sequence=seq)

runner = adaptive.Runner(learner, goal=adaptive.SequenceLearner.done)
runner.live_info()
runner.task.print_stack()

traceback

Traceback for <Task finished name='Task-3' coro=<AsyncRunner._run() done, defined at /Users/basnijholt/Work/adaptive/adaptive/runner.py:601> exception=TypeError("unhashable type: 'dict'")> (most recent call last):
TypeError: unhashable type: 'dict'
  File "/Users/basnijholt/Work/adaptive/adaptive/runner.py", line 555, in status
    return "failed"
  File "/Users/basnijholt/Work/adaptive/adaptive/runner.py", line 555, in status
    return "failed"
  File "/Users/basnijholt/Work/adaptive/adaptive/runner.py", line 618, in _run
    self._cleanup()
  File "/Users/basnijholt/Work/adaptive/adaptive/runner.py", line 210, in _process_futures
    self._do_raise(e, x)

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