Class: DurableHuggingfaceHub::Types::CachedRepoInfo

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

Overview

Information about a cached repository.

Represents a repository in the cache with all its revisions and files.

Examples:

repo = CachedRepoInfo.new(
  repo_id: "bert-base-uncased",
  repo_type: "model",
  revisions: [revision_info1, revision_info2],
  size: 1048576,
  last_accessed: Time.now,
  last_modified: Time.now
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#last_accessedTime? (readonly)

When the repository was last accessed

Returns:

  • (Time, nil)


173
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 173

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

#last_modifiedTime? (readonly)

When the repository was last modified

Returns:

  • (Time, nil)


178
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 178

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

#repo_idString (readonly)

Repository identifier

Returns:

  • (String)


153
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 153

attribute :repo_id, Types::String

#repo_typeString (readonly)

Type of repository (“model”, “dataset”, or “space”)

Returns:

  • (String)


158
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 158

attribute :repo_type, Types::String

#revisionsArray<CachedRevisionInfo> (readonly)

List of cached revisions for this repository

Returns:



163
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 163

attribute :revisions, Types::Array.of(CachedRevisionInfo)

#sizeInteger (readonly)

Total size of all revisions in this repository

Returns:

  • (Integer)


168
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 168

attribute :size, Types::Integer

Instance Method Details

#file_countInteger

Total number of files across all revisions.

Returns:

  • (Integer)

    Total file count



206
207
208
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 206

def file_count
  revisions.sum(&:file_count)
end

#revision_countInteger

Number of revisions cached for this repository.

Returns:

  • (Integer)

    Revision count



199
200
201
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 199

def revision_count
  revisions.length
end

#size_strString

Human-readable size string.

Returns:

  • (String)

    Size formatted as human-readable string



183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 183

def size_str
  units = ["B", "KB", "MB", "GB", "TB"]
  size = self.size.to_f
  unit_index = 0

  while size >= 1024 && unit_index < units.length - 1
    size /= 1024.0
    unit_index += 1
  end

  format("%.2f %s", size, units[unit_index])
end