Class: DurableHuggingfaceHub::Types::SpaceInfo

Inherits:
Struct
  • Object
show all
Includes:
Loadable
Defined in:
lib/durable_huggingface_hub/types/space_info.rb

Overview

Information about a Space repository on HuggingFace Hub.

Spaces are interactive ML demos and applications hosted on HuggingFace Hub.

Examples:

Creating a SpaceInfo from API response

space_info = SpaceInfo.from_hash({
  "id" => "gradio/hello-world",
  "sdk" => "gradio",
  "tags" => ["gradio", "demo"],
  "likes" => 100
})

Accessing space information

space_info.id      # => "gradio/hello-world"
space_info.sdk     # => "gradio"
space_info.runtime # => {"stage" => "RUNNING"}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authorString? (readonly)

Returns Author/organization name.

Returns:

  • (String, nil)

    Author/organization name



64
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 64

attribute :author, Types::OptionalString.default(nil)

#card_dataHash? (readonly)

Returns Space card metadata.

Returns:

  • (Hash, nil)

    Space card metadata



80
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 80

attribute :card_data, Types::OptionalHash.default(nil)

#created_atTime? (readonly)

Returns Repository creation timestamp.

Returns:

  • (Time, nil)

    Repository creation timestamp



68
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 68

attribute :created_at, Types::OptionalTimestamp.default(nil)

#disabledBoolean? (readonly)

Returns Whether the repository is disabled.

Returns:

  • (Boolean, nil)

    Whether the repository is disabled



56
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 56

attribute :disabled, Types::OptionalBool.default(nil)

#gatedBoolean, ... (readonly)

Returns Gated access status.

Returns:

  • (Boolean, String, nil)

    Gated access status



52
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 52

attribute :gated, Types::OptionalGated.default(nil)

#idString (readonly)

Returns Space repository ID.

Returns:

  • (String)

    Space repository ID



28
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 28

attribute :id, Types::RepoId

#last_modifiedTime? (readonly)

Returns Timestamp of last modification.

Returns:

  • (Time, nil)

    Timestamp of last modification



36
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 36

attribute :last_modified, Types::OptionalTimestamp.default(nil)

#likesInteger? (readonly)

Returns Number of likes/stars.

Returns:

  • (Integer, nil)

    Number of likes/stars



60
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 60

attribute :likes, Types::OptionalInteger.default(nil)

#privateBoolean? (readonly)

Returns Whether the repository is private.

Returns:

  • (Boolean, nil)

    Whether the repository is private



48
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 48

attribute :private, Types::OptionalBool.default(nil)

#runtimeHash? (readonly)

Returns Runtime information (stage, hardware, etc.).

Returns:

  • (Hash, nil)

    Runtime information (stage, hardware, etc.)



76
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 76

attribute :runtime, Types::OptionalHash.default(nil)

#sdkString? (readonly)

Returns SDK used (e.g., “gradio”, “streamlit”, “static”).

Returns:

  • (String, nil)

    SDK used (e.g., “gradio”, “streamlit”, “static”)



72
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 72

attribute :sdk, Types::OptionalString.default(nil)

#shaString? (readonly)

Returns Git commit SHA of the current revision.

Returns:

  • (String, nil)

    Git commit SHA of the current revision



32
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 32

attribute :sha, Types::OptionalString.default(nil)

#siblingsArray<Hash>? (readonly)

Returns List of files in the repository.

Returns:

  • (Array<Hash>, nil)

    List of files in the repository



44
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 44

attribute :siblings, Types::OptionalFileSiblings.default(nil)

#tagsArray<String> (readonly)

Returns Tags associated with the space.

Returns:

  • (Array<String>)

    Tags associated with the space



40
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 40

attribute :tags, Types::StringArray.default([].freeze)

Instance Method Details

#disabled?Boolean

Checks if the repository is disabled.

Returns:

  • (Boolean)

    True if disabled



121
122
123
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 121

def disabled?
  disabled == true
end

#file_namesArray<String>

Returns the list of file names in the repository.

Returns:

  • (Array<String>)

    File names



85
86
87
88
89
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 85

def file_names
  return [] if siblings.nil?

  siblings.map { |s| s[:rfilename] || s["rfilename"] }.compact
end

#gated?Boolean

Checks if the repository is gated.

Returns:

  • (Boolean)

    True if gated



109
110
111
112
113
114
115
116
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 109

def gated?
  case gated
  when true, "auto", "manual"
    true
  else
    false
  end
end

#has_tag?(tag) ⇒ Boolean

Checks if the space has a specific tag.

Parameters:

  • tag (String)

    Tag to check for

Returns:

  • (Boolean)

    True if the tag is present



95
96
97
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 95

def has_tag?(tag)
  tags.include?(tag)
end

#inspectString

Returns a detailed inspection string.

Returns:

  • (String)

    Inspection string



152
153
154
155
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 152

def inspect
  "#<#{self.class.name} id=#{id.inspect} sdk=#{sdk.inspect} " \
    "stage=#{runtime_stage.inspect}>"
end

#public?Boolean

Checks if the repository is public.

Returns:

  • (Boolean)

    True if public



102
103
104
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 102

def public?
  !private
end

#running?Boolean

Checks if the space is currently running.

Returns:

  • (Boolean)

    True if running



135
136
137
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 135

def running?
  runtime_stage == "RUNNING"
end

#runtime_stageString?

Returns the runtime stage if available.

Returns:

  • (String, nil)

    Runtime stage (e.g., “RUNNING”, “STOPPED”)



128
129
130
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 128

def runtime_stage
  runtime&.dig("stage") || runtime&.dig(:stage)
end

#to_sString

Returns a short description of the space.

Returns:

  • (String)

    Description string



142
143
144
145
146
147
# File 'lib/durable_huggingface_hub/types/space_info.rb', line 142

def to_s
  parts = [id]
  parts << "(#{sdk})" if sdk
  parts << "[#{runtime_stage}]" if runtime_stage
  parts.join(" ")
end