question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New custom magic commands do not work

See original GitHub issue

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: Screenshot from 2021-07-15 13-26-04

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
pacospacecommented, Jul 20, 2021

@pacospace Cool!

If you don’t mind, I’m going to close this issue then.

Thank you a lot @MrMino for all help and support!! 🚀 🥇

1reaction
MrMinocommented, Jul 20, 2021

@pacospace Cool!

If you don’t mind, I’m going to close this issue then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom magic in ipython notebooks - Code does not execute
I am relatively new to ipython magics and want to run some code and at the same time add it to a list...
Read more >
Defining custom magics — IPython 8.7.0 documentation
Defining custom magics¶. There are two main ways to define your own magic functions: from standalone functions and by inheriting from a base...
Read more >
Enhance kernels with magic commands - Amazon EMR
EMR Studio and EMR Notebooks support magic commands, which are enhancements provided by the IPython kernel to help run and analyze data.
Read more >
1.4. Creating an IPython extension with custom magic ...
Defining a new line magic is particularly simple. First, we create a function that accepts the contents of the line (except the initial...
Read more >
Defining custom magics — IPython 3.2.1 documentation
There are two main ways to define your own magic functions: from standalone functions and by ... it does not require IPython #...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found