jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.65k stars 4.91k forks source link

Customize execution in kernel #3177

Open avriLee opened 6 years ago

avriLee commented 6 years ago

Hi, all

@my_comm.on_msg def _recv(msg): try:

modify the default execution

    # add the `test` to codes(top) from code cell like:
    # ```Python
    # test = msg['content']['data']['test']
    # print test
    # ```
except AttributeError as e:
    pass

- 
  - _step b:_ 
![image](https://user-images.githubusercontent.com/22313470/34513457-5640dd54-f0a3-11e7-8052-ad86b83f8675.png)

- **_Q:_**
  - if we follow the way we mentioned above, i have no idea of 
    -  customizing the execution in kernel;
    - now that this could be registered when a [`extension`](http://jupyter-notebook.readthedocs.io/en/stable/extending/frontend_extensions.html) is loaded,  after clicking `SEND`, does it mean that we need to trigger the batch operations(install and enable via nbextension) like `bash` in click fn?
  - otherwise, is there any convenient way to recommend?

Thanks for your time and waiting for your reply!
avriLee commented 6 years ago

em,i tried it and found if we follow as i mentioned above, Comm is unnecessary, while customizing the execution of codes in kernel is the key. Here's my personal 'solution':

So, it may evolve into: is there any public or recommended way to customize the execution?