Class: DurableHuggingfaceHub::Types::HFCacheInfo
- Includes:
- Loadable
- Defined in:
- lib/durable_huggingface_hub/types/cache_info.rb
Overview
Comprehensive cache information.
Contains information about the entire cache directory including all repositories.
Instance Attribute Summary collapse
-
#cache_dir ⇒ Pathname
readonly
Path to the cache directory.
-
#repos ⇒ Array<CachedRepoInfo>
readonly
List of cached repositories.
-
#size ⇒ Integer
readonly
Total size of the cache in bytes.
Instance Method Summary collapse
-
#file_count ⇒ Integer
Total number of files across all repositories and revisions.
-
#repo_count ⇒ Integer
Number of repositories in the cache.
-
#repos_by_last_accessed ⇒ Array<CachedRepoInfo>
Get repositories sorted by last accessed time (most recent first).
-
#repos_by_last_modified ⇒ Array<CachedRepoInfo>
Get repositories sorted by last modified time (most recent first).
-
#repos_by_size ⇒ Array<CachedRepoInfo>
Get repositories sorted by size (largest first).
-
#revision_count ⇒ Integer
Total number of revisions across all repositories.
-
#size_str ⇒ String
Human-readable size string.
Instance Attribute Details
#cache_dir ⇒ Pathname (readonly)
Path to the cache directory
227 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 227 attribute :cache_dir, Types::PathnameType |
#repos ⇒ Array<CachedRepoInfo> (readonly)
List of cached repositories
232 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 232 attribute :repos, Types::Array.of(CachedRepoInfo) |
#size ⇒ Integer (readonly)
Total size of the cache in bytes
237 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 237 attribute :size, Types::Integer |
Instance Method Details
#file_count ⇒ Integer
Total number of files across all repositories and revisions.
272 273 274 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 272 def file_count repos.sum(&:file_count) end |
#repo_count ⇒ Integer
Number of repositories in the cache.
258 259 260 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 258 def repo_count repos.length end |
#repos_by_last_accessed ⇒ Array<CachedRepoInfo>
Get repositories sorted by last accessed time (most recent first).
286 287 288 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 286 def repos_by_last_accessed repos.compact.sort_by { |repo| repo.last_accessed || Time.at(0) }.reverse end |
#repos_by_last_modified ⇒ Array<CachedRepoInfo>
Get repositories sorted by last modified time (most recent first).
293 294 295 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 293 def repos_by_last_modified repos.compact.sort_by { |repo| repo.last_modified || Time.at(0) }.reverse end |
#repos_by_size ⇒ Array<CachedRepoInfo>
Get repositories sorted by size (largest first).
279 280 281 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 279 def repos_by_size repos.sort_by { |repo| -repo.size } end |
#revision_count ⇒ Integer
Total number of revisions across all repositories.
265 266 267 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 265 def revision_count repos.sum(&:revision_count) end |
#size_str ⇒ String
Human-readable size string.
242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 242 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 |