Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for jupyterhub 3.1.0 (patch included) #3

Open
aminasyan opened this issue Jan 16, 2023 · 1 comment
Open

fix for jupyterhub 3.1.0 (patch included) #3

aminasyan opened this issue Jan 16, 2023 · 1 comment

Comments

@aminasyan
Copy link

aminasyan commented Jan 16, 2023

Hi,
I have patched podmanspawner to work with jupyterhub 3.1.0 also added a needed feature to jupyter_additional_cmds.

(podmanspawner-v3-hub.patch)

diff -ruN a/podmanspawner/podmanspawner.py b/podmanspawner/podmanspawner.py
--- a/podmanspawner/podmanspawner.py    2022-03-23 23:54:42.000000000 -0700
+++ b/podmanspawner/podmanspawner.py    2023-01-14 18:41:30.418601680 -0800
@@ -77,7 +77,7 @@
         "start-notebook.sh",
         help="""This command is run in the container. Should be 'start-notebook.sh'
         or 'jupyterhub-singleuser'. PORT gets replaced by the port number the notebook should run on."""
-        )
+        ).tag(config=True)
     standard_jupyter_port = Integer(
         8888,
         help="""The standard port, the Jupyter Notebook is listening in the
@@ -96,20 +96,21 @@
         ).tag(config=True)
     jupyter_additional_cmds = List(
         default_value=[],
-        help="""These commands are appended to the jupyter_base_cmd."""
+        help="""These commands are appended to the jupyter_base_cmd. Use USERNAME to refer
+        to the users name in the cmd options"""
         ).tag(config=True)
 
     enable_lab = Bool(
         False,
         help="""Enable Jupyter Lab in the container via environment variable.
         Dont forget to change c.Spawner.default_url = '/lab'."""
-        )
+        ).tag(config=True)
 
     env_keep = List(
         [],
         help="""Override the env_keep of the Spawner calls, since we do not need
         to keep these env variables in the container."""
-        )
+        ).tag(config=True)
     # here we would need traitlets callable type...
     preexec_fn_set = Integer(
         0,
@@ -117,10 +118,10 @@
         Set this to 1, when there is a different preexec_fn""",
     )
     conthome = Unicode(
-        "/home/jovyan/home",
+        "",
         help="""Where to map the users home directory. Use USERNAME to refer
         to the users name in the filepath"""
-        )
+        ).tag(config=True)
     startatconthome = Bool(False, help="""add -w conthome to podman cmd""")
 
     def make_preexec_fn(self, name):
@@ -185,6 +186,8 @@
     def get_env(self):
         """Get the complete set of environment variables to be set in the spawned process."""
         env = super().get_env()
+        env['JUPYTERHUB_OAUTH_SCOPES']=env['JUPYTERHUB_OAUTH_SCOPES'].translate(str.maketrans({"[":  r"'[", "]":  r"]'",}))
+        env['JUPYTERHUB_OAUTH_ACCESS_SCOPES']=env['JUPYTERHUB_OAUTH_ACCESS_SCOPES'].translate(str.maketrans({"[":  r"'[", "]":  r"]'",}))
         # We do not need user defined stuff in the container. So we do not need
         # this next line...
         # env = self.user_env(env)
@@ -280,7 +283,7 @@
             jupyter_base_cmd.append("--NotebookApp.port={}".format(self.port))
 
         podman_cmd = podman_base_cmd+self.podman_additional_cmds
-        jupyter_cmd = jupyter_base_cmd+self.jupyter_additional_cmds
+        jupyter_cmd = jupyter_base_cmd+[sub.replace('USERNAME', self.user.name ) for sub in self.jupyter_additional_cmds]
 
         cmd = shlex.split(" ".join(podman_cmd+jupyter_cmd))

Best Regards
Aram

@aminasyan
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant