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

Switch to JupyterHub service #75

Merged
merged 3 commits into from
Mar 26, 2024
Merged

Switch to JupyterHub service #75

merged 3 commits into from
Mar 26, 2024

Conversation

trungleduc
Copy link
Collaborator

@trungleduc trungleduc commented Mar 7, 2024

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:

  • port: Port of the service; defaults to 6789
  • ip: Internal IP of the service; defaults to 127.0.0.1
  • default_memory_limit: Default memory limit of a user server; defaults to None
  • default_cpu_limit: Default CPU limit of a user server; defaults to None
  • machine_profiles: Instead of entering directly the CPU and Memory value, tljh-repo2docker can be configured with pre-defined machine profiles and users can only choose from the available option; defaults to []

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",
        ],
    },
]

@trungleduc trungleduc force-pushed the service branch 2 times, most recently from 27a6728 to b706115 Compare March 16, 2024 14:12
@trungleduc trungleduc added the enhancement New feature or request label Mar 16, 2024
@trungleduc trungleduc requested a review from jtpio March 16, 2024 14:18
@trungleduc trungleduc marked this pull request as ready for review March 16, 2024 14:18
@jtpio jtpio linked an issue Mar 18, 2024 that may be closed by this pull request
@jtpio
Copy link
Member

jtpio commented Mar 18, 2024

Thanks @trungleduc for looking into this!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if this snapshot update is intended? It looks like the refresh icon appears instead of "Open Server"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The navbar changes look relevant due to the switch to the service. So it's likely only the refresh icon.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated snapshot is for the nav bar, the refresh icon, or the "Open Server" button depending on the runner's processing speed; sometimes it fires the server quickly enough to show the open server button.
We have a maxDiffPixelRatio: 0.001 config to catch this inconsistency

@jtpio
Copy link
Member

jtpio commented Mar 20, 2024

cc @yuvipanda this is one step towards #72 (in case you are interested in following progress on that)

@yuvipanda
Copy link

oooooh will look!

Copy link
Member

@jtpio jtpio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jtpio jtpio merged commit 466f6fb into plasmabio:master Mar 26, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch to a JupyterHub service
3 participants