【问题标题】:Get current notebook/user context from JupyterHub notebook server?从 JupyterHub 笔记本服务器获取当前笔记本/用户上下文?
【发布时间】:2019-12-14 13:25:27
【问题描述】:

我在 AWS EKS 集群上运行 JupyterHub 0.8.2。

我想知道是否可以检索当前笔记本服务器的所有者。

例如 假设我导航到myjupyterhubhost.com/user/john-doe/notebooks/SampleNotebook.ipynb

在python中,我想这样做:

user = get_current_context().get_notebook_user_owner()
print(f"The user who owns this notebook server: {user}")

# Output:
# The user who owns this notebook server: john-doe

python环境下有没有这样的功能?

【问题讨论】:

    标签: python amazon-web-services jupyter-notebook jupyterhub


    【解决方案1】:

    原来这很简单,用户名存储在一个环境变量中:

    import os
    username = os.environ['JUPYTERHUB_USER']
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-28
      • 1970-01-01
      • 2018-12-19
      • 2015-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多