Run A Specific Jupyter Notebook On Start - jupyter-notebook

I would like to setup a system such that it not only runs jupyter notebook on start, but it also starts executing a specific notebook on that jupyter server (running all cells in sequence).
Is this possible? I specifically want to be able to access the notebook web interface and inspect/stop/etc the running notebook at any point.
I know nbconvert can execute a notebook, but it seems to run independently of any existing jupyter servers?
Maybe there is some API I can access so that I can write a shell script to run jupyter notebook and then use the API to open and run a notebook?

Related

Only Run Startup File When Launching IPython Kenel from Jupyter Lab

I'm writing a startup script for users of my Jupyter Lab extension that customizes the pandas dataframe output display using a formatter. The formatting only makes sense in the context of Jupyter Lab, but because the file is in the user's .ipython/profile_default/startup folder, it gets executed every time a IPython kernel is started.
I have tried using get_ipython().__class__.__name__, however 'ZMQInteractiveShell' is returned both in JupyterLab, Jupyter Notebooks, and VScode. I'm specifically looking for the case where the user is in Jupyter Lab.
Does anyone know how to detect if the IPython kernel was started by launching Jupyter Lab and either 1) preventing the startup file from running all together, or 2) just casing in my startup file itself to not load the formatter when it wasn't started through Jupyter Lab?
My startup file:
try:
import pandas as pd
def df_formatter(obj):
return f'<div><div onclick="console.log(\'You are in Jupyter Lab\'">In Jupyter Lab?</div> {obj.to_html()}</div>'
html_formatter = get_ipython().display_formatter.formatters['text/html']
html_formatter.for_type(pd.DataFrame, df_formatter)
except:
print('Unable to run startup script')

Can I start a Jupyter notebook using a Spyder kernel?

I have been able to start a remote ipython console using 'python -m spyder_kernels.console' and connect to it using Spyder on my local machine. However, this just gives me a console. I want to get a notebook running remotely and connect to it using Spyder. I understand the Spyder kernel is different and has several modifications. My question is, can I start a remote Jupyter notebook, using a Spyder kernel, and then connect to this notebook from inside my local Spyder? I have the Spyder notebook plugin installed. The idea is that since the notebook is started using a Spyder kernel, Spyder should be able to interact with it and the Variable Explorer should work.
PS: I know it should be possible to start a Jupyter notebook with the Spyder kernel, because that's exactly what the notebook plugin for Spyder does inside of Spyder. I just want the ability to start this notebook remotely and then connect to it.

List all running notebooks on jupyter server

I want to write a script to list all the .ipynb notebook files that are running on my jupyter server http://localhost:40000/tree/.
I am unable to find a command to do so, however i can only find command that lists all running servers:
jupyter notebooks list
Please list any method / shell command to do so.

Audit Commands run in Jupyter Notebook

Requirement:
Be able to audit (using logs) all the commands run in Jupyter Notebook by a user. The Jupyter Notebook is installed on Dataproc.
Is there a way we can log the command run by the user at the same time.
I have already tried changing Application.log_level in jupyter config file to 0 but no luck.
Looks like there was some discussion about this FR in the Jupyter community: https://groups.google.com/forum/#!topic/jupyter/sLKCCBwlKEc. You would have to modify the Jupyter kernel to print out all commands to a file.

The Kernel in Jupyter Notebook does not respond when importing the ROOT framework

I am hoping to use pyRoot, the data analysis framework developed by CERN, by integrating it in a Jupyter notebook. That said, I believe that I did the proper installation of ROOT on my macOS 10.
When I launch the ROOT Jupyter notebook using the following command, it launches properly:
root --notebook
and I get the Jupyter notebook editor. However, whenever I start the notebook by:
import ROOT
The command is kept loading a pop up notification telling me that:
The kernel appears to have died. It will restart automatically.

Resources