Activate Jupyter Kernel
Table of contents
yt_run_JupyterKernel
int yt_run_JupyterKernel(const char* flag_file_name, bool use_connection_file);
- Usage: Activate Jupyter kernel if file
flag_file_nameis detected.libytuses user provided connection file ifuse_connection_fileistrue. 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: Whenlibytis not compiled with-DJUPYTER_KERNEL=ON, it returnsYT_FAIL.
Must compile
libytwith-DJUPYTER_KERNEL=ON.
The API only launches a Jupyter kernel that exposes simulation data. For how to connect to the kernel, please go to Jupyter Notebook Access.
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"
}
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);
}