Class: DurableHuggingfaceHub::SpaceCard

Inherits:
RepoCard
  • Object
show all
Defined in:
lib/durable_huggingface_hub/repo_card.rb

Overview

Space card for documenting Spaces (interactive demos).

Space cards provide information about Gradio/Streamlit apps including:

  • App description and usage

  • Technical requirements

  • Model dependencies

Examples:

Create a space card

card = SpaceCard.new(
  text: "# My Demo\n\nThis space demonstrates...",
  data: {
    "sdk" => "gradio",
    "sdk_version" => "3.0.0",
    "app_file" => "app.py"
  }
)

Instance Attribute Summary

Attributes inherited from RepoCard

#data, #text

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RepoCard

from_hub, #initialize, load, parse, #push_to_hub, #save, #to_s, #update_metadata

Constructor Details

This class inherits a constructor from DurableHuggingfaceHub::RepoCard

Class Method Details

.default_repo_typeString

Returns Default repository type for space cards.

Returns:

  • (String)

    Default repository type for space cards



398
399
400
# File 'lib/durable_huggingface_hub/repo_card.rb', line 398

def self.default_repo_type
  "space"
end

Instance Method Details

#validateArray<String>

Validate space card metadata.

Returns:

  • (Array<String>)

    List of validation errors



405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
# File 'lib/durable_huggingface_hub/repo_card.rb', line 405

def validate
  errors = []

  # Check for required fields
  errors << "sdk is required" unless @data["sdk"]
  errors << "app_file is required" unless @data["app_file"]

  # Validate SDK
  if @data["sdk"] && !["gradio", "streamlit", "docker", "static"].include?(@data["sdk"])
    errors << "sdk must be one of: gradio, streamlit, docker, static"
  end

  # Validate app_file
  if @data["app_file"] && !@data["app_file"].is_a?(String)
    errors << "app_file must be a string"
  end

  # Validate sdk_version format
  if @data["sdk_version"] && !@data["sdk_version"].is_a?(String)
    errors << "sdk_version must be a string"
  end

  errors
end