quota
Limits on what a user may run and the record of what they ran.
- Session limit.
session_limitcounts a user's sessions on every node, as the nodes last reported them; a node that is away counts with what it last said, so losing sight of a node never frees a slot. - Session size.
session_cpusandsession_memory_mbcap each session's container, below whatever the app or its template asks for. - Session length.
session_hoursends a session that old. - Allowance.
allowance_hoursperallowance_period(day,week, ormonth, in UTC) is spent by session time, weighted by thecostof the pool the session runs in (gpu_costfor a GPU session), so an hour on a GPU node can cost more than an hour of office work. A user out of allowance starts nothing new; a pool withstop_when_spentalso ends what runs. - Storage.
storage_limit, in gigabytes, stops new uploads and persistent launches once the user's directories on the node hold that much.
Each node adds up the time of its own sessions and writes it to
cluster/usage/<day>/<node id>.yml every usage_flush_seconds, an object no
other node writes. What is spent is the sum over the nodes, plus this node's
time not yet written.
attributelogger= logging.getLogger(__name__)attributeUSAGEdict[str, dict[str, dict[str, float]]]= {}func_today() -> strReturn today's date in UTC.
Returns
strfunc_usage_dir(day='') -> strReturn the directory of the usage records, or of one day's.
paramdaystr= ''Returns
strfuncperiod_days(period) -> list[str]Return the dates, in UTC, of the day, week (from Monday), or month running now.
paramperiodstrReturns
list[str]funcload() -> NoneRead the usage records of the running month; a day gone by is read once.
Returns
Nonefunctick() -> NoneAdd the time since the last tick to every running session's user.
Returns
Nonefuncflush() -> NoneWrite this node's usage of the days it changed.
Returns
Nonefuncused_hours(username, period) -> floatReturn the weighted hours a user spent in the running period, on every node.
paramusernamestrparamperiodstrReturns
floatfuncallowance(user) -> dict[str, Any] | NoneReturn a user's allowance and what is spent of it, or None for a user with none.
paramuserdict[str, Any]Returns
dict[str, typing.Any] | Nonefunclimited(user) -> boolWhether a user has a session limit or an allowance, so their launches have to be counted.
paramuserdict[str, Any]Returns
boolfunccheck_launch(user) -> NoneRefuse a launch that would take a user past the session limit or the allowance.
The other nodes are asked for their sessions first, so the count is as fresh as they can make it.
paramuserdict[str, Any]Returns
Nonefunc_bytes(value) -> int | NoneParse a Docker memory size (512m, 4g, a byte count) into bytes.
paramvalueAnyReturns
int | Nonefunccap_resources(overrides, effective_settings) -> NoneLower a launch's CPU and memory to the user's session_cpus and session_memory_mb.
paramoverridesdict[str, Any]Docker run options of the launch, changed in place.
parameffective_settingsdict[str, Any] | NoneThe user's effective settings.
Returns
Nonefuncstorage_used(username) -> intReturn the bytes under a user's storage directory on this node, measured at most once a minute.
paramusernamestrReturns
intfunccheck_storage(user) -> NoneRefuse to add to the storage of a user who is at their storage_limit.
paramuserdict[str, Any]Returns
Nonefuncoverdue() -> list[tuple[str, str]]Return the sessions on this node to end now, each with the reason.
That is a session older than its user's session_hours, and, in a pool
with stop_when_spent, one whose user is out of allowance.
Returns
list[tuple[str, str]]