gpoore / codebraid

Live code in Pandoc Markdown
BSD 3-Clause "New" or "Revised" License
376 stars 13 forks source link

can't run codebraid with new version of jupyter-client #46

Closed jaycunningham-8451 closed 11 months ago

jaycunningham-8451 commented 3 years ago

I have the following markdown:

% example
% Jay Cunningham
% 22 April 2021

# What's happening?

```{.python .cb.nb jupyter_kernel=python3 example=false session=foo}
print("hello, world")

I'm running the following command to create slides:

codebraid pandoc -f markdown example.md -t revealjs -s -i -o example.html

If I install jupyter-client==6.1.12, it works fine. If I upgrade it to the most-current jupyter-client==6.2.0, I (usually?) get the following error:

Traceback (most recent call last):
  File "/Users/j260381/.pyenv/versions/kayday-deep-dive/bin/codebraid", line 8, in <module>
    sys.exit(main())
  File "/Users/j260381/.pyenv/versions/3.8.7/envs/kayday-deep-dive/lib/python3.8/site-packages/codebraid/cmdline.py", line 107, in main
    args.func(args)
  File "/Users/j260381/.pyenv/versions/3.8.7/envs/kayday-deep-dive/lib/python3.8/site-packages/codebraid/cmdline.py", line 153, in pandoc
    converter.code_braid()
  File "/Users/j260381/.pyenv/versions/3.8.7/envs/kayday-deep-dive/lib/python3.8/site-packages/codebraid/converters/base.py", line 1199, in code_braid
    self._process_code_chunks()
  File "/Users/j260381/.pyenv/versions/3.8.7/envs/kayday-deep-dive/lib/python3.8/site-packages/codebraid/converters/base.py", line 1213, in _process_code_chunks
    cp.process()
  File "/Users/j260381/.pyenv/versions/3.8.7/envs/kayday-deep-dive/lib/python3.8/site-packages/codebraid/codeprocessors/base.py", line 603, in process
    self._run_jupyter(session)
  File "/Users/j260381/.pyenv/versions/3.8.7/envs/kayday-deep-dive/lib/python3.8/site-packages/codebraid/codeprocessors/base.py", line 1384, in _run_jupyter
    if msg['parent_header'].get('msg_id') != cc_jupyter_id:
TypeError: 'coroutine' object is not subscriptable
sys:1: RuntimeWarning: coroutine 'ZMQSocketChannel.get_msg' was never awaited

It sometimes works the first time I run codebraid after installing 6.2.0, but it always fails the second or further times I run it after making a change to the markdown.

gpoore commented 3 years ago

It looks like all releases since 6.1.12 have had issues and will be replaced with an upcoming 7.0.0: https://github.com/jupyter/jupyter_client/blob/master/docs/changelog.rst. The Codebraid error is likely related to https://github.com/jupyter/jupyter_client/blob/master/docs/changelog.rst. I'm guessing that Codebraid needs an await somewhere, but will have to see if that's still the case with 7.0.0.

If you have a chance, please test against jupyter-client 7.0.0a. Otherwise, I'm currently working on some other Codebraid issues, and can probably take a look in a few days when that's finished.

jaycunningham-8451 commented 2 years ago

Apologies for the very long delay here. For what it's worth, I'm seeing the a different (but extremely similar) error with jupyter-client 7.0.4. (Python 3.9.7, macOS 11.6, codebraid 0.5.0)

Pinning to jupyter-client 6.1.12 still does work, though.

gpoore commented 2 years ago

Thanks for the update. I've been working on the next version of Codebraid for several months. To support several new features, I'm reimplementing much of the core as async, including interaction with jupyter-client. These issues should all be resolved whenever I can finish the next release.

gpoore commented 2 years ago

This should be fixed in the latest release. All interaction with jupyter_client is now async.