plasmabio / tljh-repo2docker

Plugin for The Littlest JupyterHub to build multiple user environments with repo2docker
BSD 3-Clause "New" or "Revised" License
60 stars 15 forks source link

Switch to JupyterHub service #75

Closed trungleduc closed 5 months ago

trungleduc commented 6 months ago

Changes

This PR converts extra hub handlers into a hub-managed service. This service can be started by this command:

python -m tljh_repo2docker

The available settings for this service are:

Here is an example of registering tljh_repo2docker's service with JupyterHub

# jupyterhub_config.py

from tljh_repo2docker import TLJH_R2D_ADMIN_SCOPE

c.JupyterHub.services.extend(
    [
        {
            "name": "tljh_repo2docker",
            "url": "http://127.0.0.1:6789", # URL must match the `ip` and `port` config
            "command": [
                sys.executable,
                "-m",
                "tljh_repo2docker",
                "--ip",
                "127.0.0.1",
                "--port",
                "6789"
            ],
            "oauth_no_confirm": True,
        }
    ]
)
# Set required scopes for the service and users
c.JupyterHub.load_roles = [
    {
        "description": "Role for tljh_repo2docker service",
        "name": "tljh-repo2docker-service",
        "scopes": ["read:users", "read:servers", "read:roles:users"],
        "services": ["tljh_repo2docker"],
    },
    {
        "name": "user",
        "scopes": [
            "self",
            # access to the serve page
            "access:services!service=tljh_repo2docker",
        ],
    },
]
jtpio commented 6 months ago

Thanks @trungleduc for looking into this!

jtpio commented 6 months ago

cc @yuvipanda this is one step towards https://github.com/plasmabio/tljh-repo2docker/issues/72 (in case you are interested in following progress on that)

yuvipanda commented 6 months ago

oooooh will look!