JupyterHub Credit Servce
Project description
JupyterHub Credit Service
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.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jupyterhub_credit_service-0.3.11.tar.gz.
File metadata
- Download URL: jupyterhub_credit_service-0.3.11.tar.gz
- Upload date:
- Size: 31.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a961a1c32b9974b5bb9de7e3787b444f3d6072869721993deb258eefa7d8da7f
|
|
| MD5 |
2a63774b48c9236c7b85816a65f9818a
|
|
| BLAKE2b-256 |
99b3ff5379a2fd8cabba0baf3e1432dc51323608b16b2aa7d9d2c1c8884ae4dc
|
Provenance
The following attestation bundles were made for jupyterhub_credit_service-0.3.11.tar.gz:
Publisher:
publish-release.yml on jsc-jupyter/jupyterhub-credit-service
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jupyterhub_credit_service-0.3.11.tar.gz -
Subject digest:
a961a1c32b9974b5bb9de7e3787b444f3d6072869721993deb258eefa7d8da7f - Sigstore transparency entry: 809625495
- Sigstore integration time:
-
Permalink:
jsc-jupyter/jupyterhub-credit-service@d307b793727583319502d4e6d1216301e855c4eb -
Branch / Tag:
refs/tags/0.3.11 - Owner: https://github.com/jsc-jupyter
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-release.yml@d307b793727583319502d4e6d1216301e855c4eb -
Trigger Event:
push
-
Statement type:
File details
Details for the file jupyterhub_credit_service-0.3.11-py3-none-any.whl.
File metadata
- Download URL: jupyterhub_credit_service-0.3.11-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e80a0385cb5a827443215600107b3b6ee2b67e1a244c88742f65665243d39af7
|
|
| MD5 |
5c59335022b9786fa15b280c3e3f746f
|
|
| BLAKE2b-256 |
68b8dae8bff24fe73d4b37061e2fa1e857982b7e3680e6f0ed0c0489e576b948
|
Provenance
The following attestation bundles were made for jupyterhub_credit_service-0.3.11-py3-none-any.whl:
Publisher:
publish-release.yml on jsc-jupyter/jupyterhub-credit-service
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jupyterhub_credit_service-0.3.11-py3-none-any.whl -
Subject digest:
e80a0385cb5a827443215600107b3b6ee2b67e1a244c88742f65665243d39af7 - Sigstore transparency entry: 809625526
- Sigstore integration time:
-
Permalink:
jsc-jupyter/jupyterhub-credit-service@d307b793727583319502d4e6d1216301e855c4eb -
Branch / Tag:
refs/tags/0.3.11 - Owner: https://github.com/jsc-jupyter
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-release.yml@d307b793727583319502d4e6d1216301e855c4eb -
Trigger Event:
push
-
Statement type: