Issue
I try to dynamically load a jupyter notebook into a module and found a working code example in https://github.com/axil/import-ipynb/blob/master/import_ipynb.py. However, since this implementation uses some deprecated functions and I want to consolidate some common functionality into a single package I want to implement my own version. However, when I try to transform jupyter magic code into python code before execution, I get this strange error.
(Pdb) self
<IPython.core.inputsplitter.IPythonInputSplitter object at 0x102198c50>
(Pdb) IPythonInputSplitter
<class 'IPython.core.inputsplitter.IPythonInputSplitter'>
(Pdb) type(self)
<class 'IPython.core.inputsplitter.IPythonInputSplitter'>
(Pdb) IPythonInputSplitter is type(self)
False
(Pdb) super(IPythonInputSplitter, self)
*** TypeError: super(type, obj): obj must be an instance or subtype of type
Here is some context for the offending code:
for cell in notebook.cells:
if cell.cell_type == "code":
code = self.shell.input_transformer_manager.transform_cell(cell.source)
From the error type I don't think this is a problem special to ipython, but I don't quite get it
Solution
This Problem was unrelated to the provided Code
The Problem occurred because the module that contained IPython.core.inputsplitter.IPythonInputSplitter
was reloaded using importlib.reload
between instantiation and the typecheck.
Answered By - chuck258
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.