Hub Python Library documentation

Managing your Space runtime

You are viewing v2.1.0 version. A newer version v2.1.1 is available.
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Managing your Space runtime

Check the HfApi documentation page for the reference of methods to manage your Space on the Hub.

Data structures

SpaceRuntime

class huggingface_hub.SpaceRuntime

< >

( data: dict )

Parameters

  • stage (str) — Current stage of the space. Example: RUNNING.
  • hardware (str or None) — Current hardware of the space. Example: “cpu-basic”. Can be None if Space is BUILDING for the first time.
  • requested_hardware (str or None) — Requested hardware. Can be different from hardware especially if the request has just been made. Example: “t4-medium”. Can be None if no hardware has been requested yet.
  • sleep_time (int or None) — Number of seconds the Space will be kept alive after the last request. By default (if value is None), the Space will never go to sleep if it’s running on an upgraded hardware, while it will go to sleep after 48 hours on a free ‘cpu-basic’ hardware. For more details, see https://huggingface.co/docs/hub/spaces-gpus#sleep-time.
  • volumes (list[Volume] or None) — List of volumes mounted in the Space. Each volume is a Volume object describing its type, source, mount path, and optional settings. None if no volumes are attached.
  • raw (dict) — Raw response from the server. Contains more information about the Space runtime like number of replicas, number of cpu, memory size,…

Contains information about the current runtime of a Space.

SpaceHardware

class huggingface_hub.SpaceHardware

< >

( valuenames = Nonemodule = Nonequalname = Nonetype = Nonestart = 1 )

Enumeration of hardwares available to run your Space on the Hub.

Value can be compared to a string:

assert SpaceHardware.CPU_BASIC == "cpu-basic"

Taken from https://github.com/huggingface-internal/moon-landing/blob/main/server/repo_types/SpaceHardwareFlavor.ts (private url).

SpaceStage

class huggingface_hub.SpaceStage

< >

( valuenames = Nonemodule = Nonequalname = Nonetype = Nonestart = 1 )

Enumeration of possible stage of a Space on the Hub.

Value can be compared to a string:

assert SpaceStage.BUILDING == "BUILDING"

Taken from https://github.com/huggingface/moon-landing/blob/main/server/repo_types/SpaceInfo.ts#L61 (private url).

SpaceStorage

class huggingface_hub.SpaceStorage

< >

( valuenames = Nonemodule = Nonequalname = Nonetype = Nonestart = 1 )

Enumeration of persistent storage available for your Space on the Hub.

Value can be compared to a string:

assert SpaceStorage.SMALL == "small"

Taken from https://github.com/huggingface/moon-landing/blob/main/server/repo_types/SpaceHardwareFlavor.ts#L24 (private url).

SpaceVariable

class huggingface_hub.SpaceVariable

< >

( key: strvalues: dict )

Parameters

  • key (str) — Variable key. Example: "MODEL_REPO_ID"
  • value (str) — Variable value. Example: "the_model_repo_id".
  • description (str or None) — Description of the variable. Example: "Model Repo ID of the implemented model".
  • updatedAt (datetime or None) — datetime of the last update of the variable (if the variable has been updated at least once).

Contains information about the current variables of a Space.

SpaceTemplate

class huggingface_hub.SpaceTemplate

< >

( data: dict )

Parameters

  • name (str) — Human-friendly name of the template (e.g. "JupyterLab", "chatbot").
  • repo_id (str) — Repo id of the template Space (e.g. "SpacesExamples/jupyterlab").
  • sdk (str) — SDK the template is built with (e.g. "gradio", "docker", "static").
  • preferred_private (bool) — Whether Spaces created from this template are recommended to be private.

Contains information about a Space template available on the Hub.

Returned by HfApi.list_space_templates(). The repo_id can be passed as space_template to HfApi.create_repo() to seed a new Space from that template.

ZeroGpuQuota

class huggingface_hub.ZeroGpuQuota

< >

( data: dict )

Parameters

  • base (float) — Total quota, in GPU-seconds.
  • remaining (float) — Remaining quota, in GPU-seconds.
  • resets_at (datetime or None) — Date at which the quota will be reset. None if the quota has not been used yet.
  • overquota_used (float or None) — Overquota (paid) GPU-seconds consumed once the base quota is exhausted. PRO, Team and Enterprise users can purchase credits to go beyond the base quota at https://huggingface.co/settings/billing?add-credits=true.

Contains information about the ZeroGPU quota of the authenticated user.

The ZeroGPU quota is consumed each time you use a ZeroGPU Space (from the UI or through its API) and is reset periodically. See https://huggingface.co/docs/hub/spaces-zerogpu for more details.

Returned by HfApi.get_zero_gpu_quota().

Update on GitHub