Skip to main content

JupyterHub Credit Servce

Project description

JupyterHub Credit Service

Documentation PyPI Test Action PyPI


Overview

The JupyterHub Credit Service is a python package that can be installed as an extension to JupyterHub. It introduces a lightweight, flexible system to limit resource consumption on a per-user and/or per-project model.

It enables administrators to control how long users can use computational environments, and how shared project resources are allocated — all without complex accounting or billing systems.

JupyterHub

Installation

You can install the package directly from PyPI:

pip install jupyterhub-credit-service

Configuration

For detailed information, please visit the documentation site.

Example jupyterhub_config.py:

import jupyterhub_credit_service

# Configure Authenticator
from oauthenticator.generic import GenericOAuthenticator
# Use any Authenticator you usually use together with the CreditsAuthenticator
class MixinAuthenticator(GenericOAuthenticator, jupyterhub_credit_service.CreditsAuthenticator):
    pass

c.JupyterHub.authenticator_class = MixinAuthenticator

# Different users may get different amount of credits
def user_cap(username, user_groups=[], is_admin=False):
    if username.endswith("mycompany.org"):
        return 1000
    elif username.endswith("googlemail.com") or username.endswith("gmail.com"):
        return 30
    return 100

c.MixinAuthenticator.credits_user_cap = user_cap  # may be a callable or integer
c.MixinAuthenticator.credits_user_grant_value = 5 # may be a callable or integer
c.MixinAuthenticator.credits_user_grant_interval = 600 # Gain 5 credits every 10 minutes, may be a callable or integer

c.MixinAuthenticator.userinfo_url = ... # your normal configuration


# Configure Spawner
import kubespawner
# You can reuse the "KubeSpawner" name so you don't have to change your other configs
class KubeSpawner(kubespawner.KubeSpawner, jupyterhub_credit_service.CreditsSpawner):
    pass

def get_billing_value(spawner):
    # Costs gpus*10 credits + 5 credits, per billing_interval
    billing_value = 5
    if "gpus" in spawner.user_options.keys():
        billing_value += spawner.user_options["gpus"] * 10
    return billing_value

c.JupyterHub.spawner_class = KubeSpawner
c.KubeSpawner.billing_value = get_billing_value # may be a callable or integer
c.KubeSpawner.billing_interval = 600 # Pay credits depending on gpus usage every 10 minutes, may be a callable or integer

# Show JupyterHub Credits in the Header in your frontend
c.JupyterHub.template_paths = jupyterhub_credit_service.template_paths

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterhub_credit_service-0.3.7.tar.gz (31.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyterhub_credit_service-0.3.7-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file jupyterhub_credit_service-0.3.7.tar.gz.

File metadata

File hashes

Hashes for jupyterhub_credit_service-0.3.7.tar.gz
Algorithm Hash digest
SHA256 bbb7bf3596662667245825c8ed3ab7bbe88b9c5dc0c0b37ffe82dcf72e984c96
MD5 7a135a03b9ebf81197fb5fe6bafad7b3
BLAKE2b-256 86096af3053d950f1ac4f08842cf859e00cb7c3bcb9620e71cd1c222b819996a

See more details on using hashes here.

Provenance

The following attestation bundles were made for jupyterhub_credit_service-0.3.7.tar.gz:

Publisher: publish-release.yml on jsc-jupyter/jupyterhub-credit-service

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jupyterhub_credit_service-0.3.7-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyterhub_credit_service-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 45606d945b4b95d3f0a952cfe420ffeda664a32384657e756208b35237c4cf70
MD5 d0c9ddb403bd298a0c3a32342d5a1dfe
BLAKE2b-256 1e214e960a15c65f2770672ba7a326ddcbad7cb06f7bd62a03bceaec84a68e39

See more details on using hashes here.

Provenance

The following attestation bundles were made for jupyterhub_credit_service-0.3.7-py3-none-any.whl:

Publisher: publish-release.yml on jsc-jupyter/jupyterhub-credit-service

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page