Hub Python Library documentation

管理您的 Space 运行时

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

管理您的 Space 运行时

请查阅 HfApi 文档页面,以获取用于在 Hub 上管理您的 Space 的方法参考。

数据结构

SpaceRuntime

类 huggingface_hub.SpaceRuntime

< >

( data: dict )

参数

  • stage (str) — 空间当前所处的阶段。示例:RUNNING。
  • hardware (str 或 None) — 当前 Space 的硬件。示例:“cpu-basic”。如果 Space 首次处于 BUILDING 状态,则可能为 None。
  • requested_hardware (str 或 None) — 请求的硬件。如果请求刚刚提交,它可能与 hardware 不同。示例:“t4-medium”。如果尚未请求任何硬件,则可以为 None。
  • sleep_time (int 或 None) — 在最后一次请求之后,Space 保持运行状态的秒数。默认情况下(如果值为 None),当 Space 运行在升级后的硬件上时,它将永远不会进入休眠状态;而在免费的 ‘cpu-basic’ 硬件上,它将在 48 小时后进入休眠。更多详情,请参阅 https://huggingface.co/docs/hub/spaces-gpus#sleep-time。
  • volumes (list[Volume] 或 None) — 挂载在 Space 中的卷列表。每个卷都是一个 Volume 对象,描述其类型、源、挂载路径以及可选设置。如果没有附加任何卷,则为 None。
  • raw (dict) — 来自服务器的原始响应。包含有关 Space 运行时的更多信息,例如副本数量、CPU 数量、内存大小等。

包含有关 Space 当前运行时的信息。

SpaceHardware

类 huggingface_hub.SpaceHardware

< >

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

在 Hub 上运行您的 Space 时,可枚举的可用硬件列表。

Value 可以与字符串进行比较:

assert SpaceHardware.CPU_BASIC == "cpu-basic"

取自 https://github.com/huggingface-internal/moon-landing/blob/main/server/repo_types/SpaceHardwareFlavor.ts(私有链接)。

SpaceStage

class huggingface_hub.SpaceStage

< >

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

Hub 上 Space 可能处于的阶段枚举。

Value 可以与字符串进行比较:

assert SpaceStage.BUILDING == "BUILDING"

取自 https://github.com/huggingface/moon-landing/blob/main/server/repo_types/SpaceInfo.ts#L61(私有 URL)。

SpaceStorage

类 huggingface_hub.SpaceStorage

< >

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

在 Hub 上为您的 Space 可用的持久存储列表。

Value 可以与字符串进行比较:

assert SpaceStorage.SMALL == "small"

取自 https://github.com/huggingface/moon-landing/blob/main/server/repo_types/SpaceHardwareFlavor.ts#L24(私有 URL)。

SpaceVariable

类 huggingface_hub.SpaceVariable

< >

( key: strvalues: dict )

参数

  • key (str) — 变量键。示例:"MODEL_REPO_ID"
  • value (str) — 变量值。示例:"the_model_repo_id"。
  • description (str 或 None) — 变量的描述。示例:"Model Repo ID of the implemented model"。
  • updatedAt (datetime 或 None) — 变量最后一次更新的时间(如果该变量至少被更新过一次)。

包含有关 Space 当前变量的信息。

SpaceTemplate

class huggingface_hub.SpaceTemplate

< >

( data: dict )

参数

  • name (str) — 模板的易读名称(例如 "JupyterLab"、"chatbot")。
  • repo_id (str) — 模板 Space 的仓库 ID(例如 "SpacesExamples/jupyterlab")。
  • sdk (str) — 构建该模板所使用的 SDK(例如 "gradio"、"docker"、"static")。
  • preferred_private (bool) — 是否建议从此模板创建的 Spaces 为私有。

包含有关 Hub 上可用 Space 模板的信息。

由 HfApi.list_space_templates() 返回。repo_id 可以作为 space_template 传递给 HfApi.create_repo(),以从该模板初始化一个新的 Space。

ZeroGpuQuota

类 huggingface_hub.ZeroGpuQuota

< >

( data: dict )

参数

  • base (float) — 总配额,以 GPU 秒为单位。
  • remaining (float) — 剩余配额,以 GPU 秒为单位。
  • resets_at (datetime 或 None) — 配额重置的日期。如果配额尚未使用,则为 None。
  • overquota_used (float 或 None) — 基础配额用尽后消耗的超额(付费)GPU 秒数。PRO、Team 和 Enterprise 用户可以在 https://huggingface.co/settings/billing?add-credits=true 购买积分以超出基础配额。

包含有关已认证用户的 ZeroGPU 配额的详细信息。

每次使用 ZeroGPU Space(通过 UI 或其 API)时,都会消耗 ZeroGPU 配额,并且该配额会定期重置。有关更多详细信息,请参阅 https://huggingface.co/docs/hub/spaces-zerogpu。

由 HfApi.get_zero_gpu_quota() 返回。

Update on GitHub