odriverobotics / ODrive

High performance motor control
https://odriverobotics.com
MIT License
2.89k stars 1.5k forks source link

odrivetool errors with ipython 8.11 #732

Open therealchalz opened 1 year ago

therealchalz commented 1 year ago

Describe the bug The odrivetool shell doesn't work with ipython 8.11. You get all sorts of various exceptions if you hit enter, tab, type anything etc. Some examples:

Unhandled exception in event loop:
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 698, in read_from_input
    self.key_processor.process_keys()
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 272, in process_keys
    self._process_coroutine.send(key_press)
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 187, in _process
    self._call_handler(matches[-1], key_sequence=buffer[:])
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 322, in _call_handler
    handler.call(event)
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_bindings.py", line 126, in call
    result = self.handler(event)
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/IPython/terminal/shortcuts/__init__.py", line 374, in handle_return_or_newline_or_execute
    return newline_or_execute_outer(shell)(event)
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/IPython/terminal/shortcuts/__init__.py", line 397, in newline_or_execute
    status, indent = shell.check_complete(check_text)

Exception 'NoneType' object has no attribute 'check_complete'
Unhandled exception in event loop:
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 698, in read_from_input
    self.key_processor.process_keys()
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 272, in process_keys
    self._process_coroutine.send(key_press)
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 170, in _process
    matches = self._get_matches(buffer)
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 128, in _get_matches
    return [b for b in self._bindings.get_bindings_for_keys(keys) if b.filter()]
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 128, in <listcomp>
    return [b for b in self._bindings.get_bindings_for_keys(keys) if b.filter()]
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/filters/base.py", line 134, in __call__
    return all(f() for f in self.filters)
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/filters/base.py", line 134, in <genexpr>
    return all(f() for f in self.filters)
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/filters/base.py", line 248, in __call__
    return self.func()
  File "/home/che/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/IPython/terminal/shortcuts/filters.py", line 75, in auto_match
    return shell.auto_match

Exception 'NoneType' object has no attribute 'auto_match'
Unhandled exception in event loop:
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/root/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 698, in read_from_input
    self.key_processor.process_keys()
  File "/root/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 272, in process_keys
    self._process_coroutine.send(key_press)
  File "/root/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 170, in _process
    matches = self._get_matches(buffer)
  File "/root/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 128, in _get_matches
    return [b for b in self._bindings.get_bindings_for_keys(keys) if b.filter()]
  File "/root/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 128, in <listcomp>
    return [b for b in self._bindings.get_bindings_for_keys(keys) if b.filter()]
  File "/root/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/filters/base.py", line 134, in __call__
    return all(f() for f in self.filters)
  File "/root/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/filters/base.py", line 134, in <genexpr>
    return all(f() for f in self.filters)
  File "/root/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/filters/base.py", line 248, in __call__
    return self.func()
  File "/root/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/IPython/terminal/shortcuts/filters.py", line 64, in ebivim
    return shell.emacs_bindings_in_vi_insert_mode

Exception 'NoneType' object has no attribute 'emacs_bindings_in_vi_insert_mode'
Unhandled exception in event loop:
  File "/root/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 985, in in_term
    await _do_wait_for_enter("Press ENTER to continue...")
  File "/root/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 1451, in _do_wait_for_enter
    await session.app.run_async()
  File "/root/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 875, in run_async
    return await _run_async(f)
  File "/root/.cache/pypoetry/virtualenvs/odrive-play-Jdveoc2Y-py3.10/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 740, in _run_async
    result = await f

Exception 
Press ENTER to continue...

To Reproduce Use odrivetool with ipython 8.11. I had set up a poetry virtual environment with the following in the pyproject.toml file:

[tool.poetry.dependencies]
python = "^3.10"
odrive = "^0.6.5"
matplotlib = "^3.7.1"

Expected behavior You should be able to use odrivetool like a command interpreter and issue commands like the ones in the getting started guide

Desktop

Additional context & workaround It was a bit confusing for me at first as this was my first foray into using odrivetool and playing with an odrive, but eventually I came across this bug: https://github.com/ipython/ipython/issues/13966 It's not clear to me if there should be a change made to the odrivetool code or if it's a upstream regression that should/will get fixed, but since I'm just interested in playing with the motor I simply added ipython = "8.10.0" to my virtual environment dependencies and rebuilt it, and then odrivetool was happy and I am also happy with a spinning motor. Hopefully this helps someone else.

samuelsadok commented 1 year ago

This is a regression in IPython 8.11 but we can work around it from our end. I just pushed a corresponding hotfix release.

pip install odrive --upgrade