Get notebook/user context from python?

I’m running JHub 0.8.2 on AWS EKS cluster

I would like to know if it is possible to retrieve the owner of the current notebook server.

Let’s assume I navigate to

In python, I want to do this:

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

By default JUPYTERHUB_USER environment variable is filled with the user. So any method to access the variable will do:


import os

This is defined in for reference.

1 Like