Hub Python Library
  • 🌍GET STARTED
    • Home
    • Quickstart
    • Installation
  • 🌍HOW-TO GUIDES
    • Overview
    • Download files
    • Upload files
    • BAFileSystem
    • Repository
    • Search
    • Inference
    • Community Tab
    • Collections
    • Cache
    • Model Cards
    • Manage your Space
    • Integrate a library
    • Webhooks server
  • 🌍CONCEPTUAL GUIDES
    • Git vs HTTP paradigm
  • 🌍REFERENCE
    • Overview
    • Login and logout
    • Environment variables
    • Managing local and online repositories
    • BOINC AI Hub API
    • Downloading files
    • Mixins & serialization methods
    • Inference Client
    • BaFileSystem
    • Utilities
    • Discussions and Pull Requests
    • Cache-system reference
    • Repo Cards and Repo Card Data
    • Space runtime
    • Collections
    • TensorBoard logger
    • Webhooks server
Powered by GitBook
On this page
  • Managing your Space runtime
  • Data structures
  1. REFERENCE

Space runtime

PreviousRepo Cards and Repo Card DataNextCollections

Last updated 1 year ago

Managing your Space runtime

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

  • Duplicate a Space:

  • Fetch current runtime:

  • Manage secrets: and

  • Manage hardware:

  • Manage state: , ,

Data structures

SpaceRuntime

class huggingface_hub.SpaceRuntime

( data: typing.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 than 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 .

  • 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:

Copied

assert SpaceHardware.CPU_BASIC == "cpu-basic"

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:

Copied

assert SpaceStage.BUILDING == "BUILDING"

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:

Copied

assert SpaceStorage.SMALL == "small"

SpaceVariable

class huggingface_hub.SpaceVariable

( key: strvalues: typing.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) — datetime of the last update of the variable.

Contains information about the current variables of a Space.

Taken from (private url).

Taken from (private url).

Taken from (private url).

🌍
HfApi
duplicate_space()
get_space_runtime()
add_space_secret()
delete_space_secret()
request_space_hardware()
pause_space()
restart_space()
set_space_sleep_time()
<source>
https://huggingface.co/docs/hub/spaces-gpus#sleep-time
<source>
https://github.com/huggingface/moon-landing/blob/main/server/repo_types/SpaceInfo.ts#L73
<source>
https://github.com/huggingface/moon-landing/blob/main/server/repo_types/SpaceInfo.ts#L61
<source>
https://github.com/huggingface/moon-landing/blob/main/server/repo_types/SpaceHardwareFlavor.ts#L24
<source>