We implemented an IPython extension using the @magics_class (and @line_magic and @cell_magic) annotations. It is working quite well for the most part, with one important limitation. @cell_magic only gets the cell contents as an argument, but we need a way of identifying the actual cell somehow.
I suspect IPython would internally have an identifier for each cell, but this is not passed into the cell magic as far as I can tell.
The reason for needing this is because we want different functionality depending on whether the call is the result of an edit or whether it's a new cell.
Thanks!
Unfortunately, the cell ID is not being passed to your magic function/class and no API could obtain it directly. However, you can use an event listener to get the cell ID that will be executed before calling your magic function/class.
And then run the cell magic with
It will print the cell id. You could validate the result by checking the content of .ipynb.