Managing your Space runtime
Check the HfApi documentation page for the reference of methods to manage your Space on the Hub.
- Duplicate a Space: duplicate_space()
- Fetch current runtime: get_space_runtime()
- Manage secrets: add_space_secret() and delete_space_secret()
- Manage hardware: request_space_hardware()
- Manage state: pause_space(), restart_space(), set_space_sleep_time()
Data structures
SpaceRuntime
class huggingface_hub.SpaceRuntime
< source >( data: Dict )
Parameters
- stage (
str
) — Current stage of the space. Example: RUNNING. - hardware (
str
orNone
) — Current hardware of the space. Example: “cpu-basic”. Can beNone
if Space isBUILDING
for the first time. - requested_hardware (
str
orNone
) — Requested hardware. Can be different thanhardware
especially if the request has just been made. Example: “t4-medium”. Can beNone
if no hardware has been requested yet. - sleep_time (
int
orNone
) — Number of seconds the Space will be kept alive after the last request. By default (if value isNone
), 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. - 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
< source >( value names = None module = None qualname = None type = None start = 1 )
Enumeration of hardwares available to run your Space on the Hub.
Taken from https://github.com/huggingface/moon-landing/blob/main/server/repo_types/SpaceInfo.ts#L73 (private url).
SpaceStage
class huggingface_hub.SpaceStage
< source >( value names = None module = None qualname = None type = None start = 1 )
Enumeration of possible stage of a Space on the Hub.
Taken from https://github.com/huggingface/moon-landing/blob/main/server/repo_types/SpaceInfo.ts#L61 (private url).
SpaceStorage
class huggingface_hub.SpaceStorage
< source >( value names = None module = None qualname = None type = None start = 1 )
Enumeration of persistent storage available for your Space on the Hub.
Taken from https://github.com/huggingface/moon-landing/blob/main/server/repo_types/SpaceHardwareFlavor.ts#L24 (private url).
SpaceVariable
class huggingface_hub.SpaceVariable
< source >( key: str values: 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.