You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from jupyterhub_usage_quotas.manager import SpawnException, UsageQuotaManager
47
+
48
+
quota_manager = UsageQuotaManager(config=c)
49
+
50
+
async def quota_pre_spawn_hook(spawner):
51
+
try:
52
+
output = await quota_manager.enforce(spawner)
53
+
launch_flag = output["allow_server_launch"]
54
+
except Exception:
55
+
raise SpawnException(
56
+
status_code=424,
57
+
log_message="Spawn failed occurred due to a failed dependency in the usage quota system. Please contact your hub admin for assistance.",
58
+
)
59
+
if launch_flag is False:
60
+
raise SpawnException(
61
+
status_code=403,
62
+
log_message=f"{output['error']['message']}",
63
+
html_message=f"<p>Compute {output['quota']['resource']} quota limit exceeded.</p><p style='font-size:100%'>You have used <span style='color:var(--bs-red)'>{output['quota']['used']:.2f}</span> / {output['quota']['limit']['value']:.2f} {output['quota']['limit']['unit']} in the last {output['quota']['window']} days.</p><p style='font-size:100%'>Contact your JupyterHub admin if you need additional quota.</p><i style='font-size:100%;color:var(--bs-gray)'>Last updated: {output["timestamp"]} (UTC).</i>",
0 commit comments