imetadata

Опубликовано: 27 Июль 2026
на канале: Lambda dot Joburg
7
0

%imetadata [Project Intro] - a simple Jupyter Lab/Notebook Front-End-meets-Back-End Extension that functions as Auto Import Mechanism to load ipython cell/line magics at kernel startup, in an elegant way.

The idea is "Simple":

1) Using TypeScript for the Jupyter Lab/Notebook Front-End, create an empty cell at the bottom of the .ipynb notebook file at session startup.
2) Then replace its contents with a python module import statement and run the cell.
2) The module imported in the previous steps can even be an ipython cell/line magic class - The cell may be deleted while the import sticks around for the shell session. Now you can use the imported module without ever having seen the `import module_name` python syntax in the notebook startup.
3) Now you can easily write python code for the imported module to automate your Jupyter Notebook/Lab processes.

Known issue:
Having run the "hidden/deleted" cell for importing the python module, the execution count in the prompt node is incremented by 1, resulting in ln[1]: (hidden/deleted), thus the notebook appears to start execution count prompt numbering at ln[2].

Possible fix:
Reset the counter using

import IPython; IPython.get_ipython().execution_count = 0

as suggested [here](https://stackoverflow.com/questions/2.... This results in an inelegant kernel exception which may/may not able to be suppressed.