Search code examples
jupyterkdb

Set slaves for jupyterq


I am running Q in jupyter. To enable multiple slaves, jupyter requires to be run with parameter -s.

How can I launch a kernel in jupyerq with slaves enabled? I tried passing -s 20 into argv here in runkernel.py, but the kernel wouldn't start at all

os.execvp('/bin/qlib/3.6.x86_64/q', ['/bin/qlib/3.6.x86_64/q', jupyterq_kernel.q', '-cds'] + argv)

Solution

  • You can do this as follows:

    1. Find the location of your kernel.json file for qpk by running
    $jupyter kernelspec list
      qpk        /Users/anaconda3/share/jupyter/kernels/qpk
    

    Open the kernel.json file and modify the following line as outlined to set up the notebook to initialise 20 slaves threads on server startup

     "env": {"JUPYTERQ_SERVERARGS":"","MPLBACKEND":"Agg"}
    
    Changed to 
    
    "env": {"JUPYTERQ_SERVERARGS":"-s 20","MPLBACKEND":"Agg"}
    

    For reference instructions for completing command line argument execution for jupyterq can be found here: https://code.kx.com/v2/ml/jupyterq/notebooks/#server-command-line-arguments