treebeardtech / nbmake

📝 Pytest plugin for testing notebooks
https://pypi.org/project/nbmake/
Apache License 2.0
184 stars 18 forks source link

NBMAKE INTERNAL ERROR: There is no current event loop #71

Closed adamjstewart closed 2 years ago

adamjstewart commented 2 years ago

Describe the bug

Starting with nbmake 1.2, we're seeing the following error message in our tests:

NBMAKE INTERNAL ERROR
There is no current event loop
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/_pytest/runner.py", line 338, in from_call
    result: Optional[TResult] = func()
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/_pytest/runner.py", line 259, in <lambda>
lambda: ihook(item=item, **kwds), when=when, reraise=reraise
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
returnself._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
returnself._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
return outcome.get_result()
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
raise ex[1].with_traceback(ex[2])
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/_pytest/runner.py", line 174, in pytest_runtest_call
raise e
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/_pytest/runner.py", line 166, in pytest_runtest_call
    item.runtest()
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/nbmake/pytest_items.py", line 52, in runtest
    res: NotebookResult = run.execute()
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/nbmake/nb_run.py", line 79, in execute
raise err
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/nbmake/nb_run.py", line 63, in execute
    c.execute(cwd=self.filename.parent)
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/nbclient/util.py", line 84, in wrapped
return just_run(coro(*args, **kwargs))
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/site-packages/nbclient/util.py", line 47, in just_run
    loop = asyncio.get_event_loop()
...
sys:1: RuntimeWarning: coroutine 'NotebookClient.async_execute' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

To Reproduce

Error log can be seen at https://github.com/microsoft/torchgeo/runs/7272949937. Click on "Install pip dependencies" to see the output of pip list and the versions of all packages we are using.

Expected behavior

These tests work fine with nbmake 1.1: https://github.com/microsoft/torchgeo/runs/7273001912. There seems to have been some change in nbmake 1.2 that broke things.

Desktop (please complete the following information):

alex-treebeard commented 2 years ago

Hi @adamjstewart, thanks for this bug report. Please try version 1.3.1 which contains a fixed version of nbclient (see PR above for details).

adamjstewart commented 2 years ago

Works now, thanks!