How do I set parameters for each notebook on JuPyterHub running on K8s

倾然丶 夕夏残阳落幕 提交于 2019-12-11 15:57:43

问题


I want to set some parameters as defined here(https://github.com/nteract/papermill#python-version-support). The catch is, I want to be able to do this via UI. I have a JHub installed on my cluster and while opening it, I want certain parameters to be set by default.

Also, when I pass the parameters via papermill(the above script gets saved somewhere and then I will run it via papermill), I want the latter to override the former.

I tried looking into several topics in pure JuPyter notebooks but in vain.


回答1:


For the user to access some parameters as soon as her notebook starts, ipython needs to know the startup cells. This can be done via the following commands in case of JuPyterHub:

proxy:
  secretToken: "yada yada"
singleuser:
  image:
    name: some_acc_id.dkr.ecr.ap-south-1.amazonaws.com/demo
    tag: 12h
  lifecycleHooks:
    postStart:
      exec:
        command: ["/bin/sh", "-c", 'ipython profile create; cd ~/.ipython/profile_default/startup; echo ''run_id = "sample" ''> aviral.py']
  imagePullSecret:
    enabled: true
    registry: some_acc_id.dkr.ecr.ap-south-1.amazonaws.com
    username: aws
    email: aviral@abc.com

Make sure you are escaping the quotes in the yaml correctly, or simply follow what I have done above.

Once this is done, papermill will override the params but for that, you have to make sure that the cell is tagged as "parameters". For instance, in my jupyterhub, every notebook that starts has run_id variable with the value "sample".



来源:https://stackoverflow.com/questions/56149931/how-do-i-set-parameters-for-each-notebook-on-jupyterhub-running-on-k8s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!