yt_run_JupyterKernel
– Activate Jupyter Kernel¶
yt_run_JupyterKernel
¶
int yt_run_JupyterKernel(const char* flag_file_name, bool use_connection_file);
Usage: Activate Jupyter kernel if file
flag_file_name
is detected.libyt
uses user-provided connection file ifuse_connection_file
istrue
. Iffalse
, it will pick and bind to ports and generate the connection file itself. The connection file name must belibyt_kernel_connection.json
.Return:
YT_SUCCESS
YT_FAIL
: Whenlibyt
is not compiled with-DJUPYTER_KERNEL=ON
, it returnsYT_FAIL
.
Must compile
libyt
with-DJUPYTER_KERNEL=ON
.
The API only launches a Jupyter kernel, which is an entry point for Jupyter Notebook / JupyterLab to connect to. For how to connect to the kernel, please go to
Connection File¶
The connection file name must be libyt_kernel_connection.json
. This is the same connection file used in Jupyter but with different file name.
(Please refer to Jupyter Client – Connection files)
libyt
use this connection file to bind to ports and construct kernel.
For example:
{
"transport": "tcp",
"ip": "127.0.0.1",
"control_port": 53545,
"shell_port": 63994,
"stdin_port": 58177,
"iopub_port": 51243,
"hb_port": 61501,
"signature_scheme": "hmac-sha256",
"key": "64e13a6faaf1470eb1f86df565543923"
}
Connection file name must be
libyt_kernel_connection.json
.
Example¶
This forces libyt
to use user provided connection file. libyt
will launch Jupyter kernel when it detects LIBYT_STOP
file.
#include "libyt.h"
...
if (yt_run_JupyterKernel("LIBYT_STOP", true) != YT_SUCCESS) {
fprintf(stderr, "ERROR: yt_run_JupyterKernel failed!\n");
exit(EXIT_FAILURE);
}