ipython: New custom magic commands do not work
Hi all,
I was starting to create some magic commands for jupyterlab-requirements extenstion for dependency management following: https://ipython.readthedocs.io/en/stable/config/custommagics.html
I added the new class in https://github.com/thoth-station/jupyterlab-requirements/blob/master/jupyterlab_requirements/__init__.py in local environment for testing:
from IPython.core.magic import magics_class, Magics
from IPython.core.magic import line_magic # Called with %
from IPython.core.magic import cell_magic # Called with %%
from IPython.core.magic import line_cell_magic # Called with % or %%
@magics_class
class HorusMagics(Magics):
"""Horus jupyterlab-requirements CLI as magic commands."""
@line_magic
def abra(self, line):
return line
@cell_magic
def show(self, line, cell):
return line, cell
After starting jupyter lab
and testing the command in a notebook, I get:
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (6 by maintainers)
Thank you a lot @MrMino for all help and support!! 🚀 🥇
@pacospace Cool!
If you don’t mind, I’m going to close this issue then.
Thanks @MrMino for looking into this!! I think I found a solution, adding logic to the extension for that. Basically when opening any notebook, the command
%load_ext jupyterlab_requirements
is run automatically: https://github.com/thoth-station/jupyterlab-requirements/blob/01af0c92af31b887f9fd9d22a2151ec4f7a7c14b/src/dependencyManagementButton.ts#L84No worries, I still have this in mind 😃. I’ll look at it as soon as I have the time to.
here the PR I use to test the magic commands: https://github.com/thoth-station/jupyterlab-requirements/pull/356/files @MrMino.