durable_huggingface_hub 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +29 -0
  3. data/.rubocop.yml +108 -0
  4. data/CHANGELOG.md +127 -0
  5. data/README.md +547 -0
  6. data/Rakefile +106 -0
  7. data/devenv.lock +171 -0
  8. data/devenv.nix +15 -0
  9. data/devenv.yaml +8 -0
  10. data/huggingface_hub.gemspec +63 -0
  11. data/lib/durable_huggingface_hub/authentication.rb +245 -0
  12. data/lib/durable_huggingface_hub/cache.rb +508 -0
  13. data/lib/durable_huggingface_hub/configuration.rb +191 -0
  14. data/lib/durable_huggingface_hub/constants.rb +145 -0
  15. data/lib/durable_huggingface_hub/errors.rb +412 -0
  16. data/lib/durable_huggingface_hub/file_download.rb +831 -0
  17. data/lib/durable_huggingface_hub/hf_api.rb +1278 -0
  18. data/lib/durable_huggingface_hub/repo_card.rb +430 -0
  19. data/lib/durable_huggingface_hub/types/cache_info.rb +298 -0
  20. data/lib/durable_huggingface_hub/types/commit_info.rb +149 -0
  21. data/lib/durable_huggingface_hub/types/dataset_info.rb +158 -0
  22. data/lib/durable_huggingface_hub/types/model_info.rb +154 -0
  23. data/lib/durable_huggingface_hub/types/space_info.rb +158 -0
  24. data/lib/durable_huggingface_hub/types/user.rb +179 -0
  25. data/lib/durable_huggingface_hub/types.rb +205 -0
  26. data/lib/durable_huggingface_hub/utils/auth.rb +174 -0
  27. data/lib/durable_huggingface_hub/utils/headers.rb +220 -0
  28. data/lib/durable_huggingface_hub/utils/http.rb +329 -0
  29. data/lib/durable_huggingface_hub/utils/paths.rb +230 -0
  30. data/lib/durable_huggingface_hub/utils/progress.rb +217 -0
  31. data/lib/durable_huggingface_hub/utils/retry.rb +165 -0
  32. data/lib/durable_huggingface_hub/utils/validators.rb +236 -0
  33. data/lib/durable_huggingface_hub/version.rb +8 -0
  34. data/lib/huggingface_hub.rb +205 -0
  35. metadata +334 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 06a07c82312c48d5aa31f0a14bdc6b3c59b623dc5a557408ed8c18e83d43ffcf
4
+ data.tar.gz: 32398bb88e28325b3f5a61356b94513f159579380c13b6fbfd5cdb2cb491dabb
5
+ SHA512:
6
+ metadata.gz: 2796f5bca481a6910f558435adb79c989252584cbaaf0a552774f29fe78952e715a8a667b5de420dd7670dcbb348982f8132aaf56f68490d0c05a38fdfae8645
7
+ data.tar.gz: 4d67ed42b115fc43ec4f5fc9c54d2a52afe5776c16dfe081a3d3eb9e355dec552acf7cb30bfda5590a3ac780477fdafc98d2da888b15d04b5659536ba39421f1
data/.editorconfig ADDED
@@ -0,0 +1,29 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ charset = utf-8
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.rb]
12
+ indent_style = space
13
+ indent_size = 2
14
+
15
+ [*.yml]
16
+ indent_style = space
17
+ indent_size = 2
18
+
19
+ [*.md]
20
+ trim_trailing_whitespace = false
21
+ max_line_length = off
22
+
23
+ [Gemfile]
24
+ indent_style = space
25
+ indent_size = 2
26
+
27
+ [Rakefile]
28
+ indent_style = space
29
+ indent_size = 2
data/.rubocop.yml ADDED
@@ -0,0 +1,108 @@
1
+ require:
2
+ - rubocop-minitest
3
+ - rubocop-rake
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 3.0
7
+ NewCops: enable
8
+ Exclude:
9
+ - 'vendor/**/*'
10
+ - 'tmp/**/*'
11
+ - 'reference/**/*'
12
+ - 'philosophy/**/*'
13
+ - 'durableprogramming-coding-standards/**/*'
14
+
15
+ # Style preferences
16
+ Style/StringLiterals:
17
+ Enabled: true
18
+ EnforcedStyle: double_quotes
19
+
20
+ Style/StringLiteralsInInterpolation:
21
+ Enabled: true
22
+ EnforcedStyle: double_quotes
23
+
24
+ Style/FrozenStringLiteralComment:
25
+ Enabled: true
26
+ EnforcedStyle: always
27
+
28
+ Style/Documentation:
29
+ Enabled: false # We use YARD instead
30
+
31
+ Style/ClassAndModuleChildren:
32
+ Enabled: false # Allow nested module definitions
33
+
34
+ Style/GuardClause:
35
+ Enabled: true
36
+ MinBodyLength: 3
37
+
38
+ # Layout preferences
39
+ Layout/LineLength:
40
+ Max: 120
41
+ Exclude:
42
+ - 'test/**/*'
43
+
44
+ Layout/MultilineMethodCallIndentation:
45
+ EnforcedStyle: indented
46
+
47
+ Layout/FirstArrayElementIndentation:
48
+ EnforcedStyle: consistent
49
+
50
+ Layout/FirstHashElementIndentation:
51
+ EnforcedStyle: consistent
52
+
53
+ # Metrics
54
+ Metrics/BlockLength:
55
+ Exclude:
56
+ - 'test/**/*'
57
+ - 'Rakefile'
58
+ - '*.gemspec'
59
+
60
+ Metrics/MethodLength:
61
+ Max: 20
62
+ Exclude:
63
+ - 'test/**/*'
64
+
65
+ Metrics/ClassLength:
66
+ Max: 200
67
+ Exclude:
68
+ - 'test/**/*'
69
+
70
+ Metrics/ModuleLength:
71
+ Max: 200
72
+ Exclude:
73
+ - 'test/**/*'
74
+
75
+ Metrics/AbcSize:
76
+ Max: 20
77
+ Exclude:
78
+ - 'test/**/*'
79
+
80
+ # Naming
81
+ Naming/FileName:
82
+ Exclude:
83
+ - 'Gemfile'
84
+ - 'Rakefile'
85
+
86
+ Naming/MethodParameterName:
87
+ MinNameLength: 1 # Allow single letter params like 'a', 'b' for math
88
+
89
+ # Lint
90
+ Lint/UnusedMethodArgument:
91
+ AllowUnusedKeywordArguments: true
92
+
93
+ Lint/MissingSuper:
94
+ Enabled: false # Sometimes we intentionally don't call super
95
+
96
+ # Minitest specific
97
+ Minitest/MultipleAssertions:
98
+ Max: 10
99
+
100
+ Minitest/AssertEmptyLiteral:
101
+ Enabled: true
102
+
103
+ # Performance
104
+ Performance/StringReplacement:
105
+ Enabled: true
106
+
107
+ Performance/Caller:
108
+ Enabled: true
data/CHANGELOG.md ADDED
@@ -0,0 +1,127 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.2.0] - 2025-01-24
9
+
10
+ ### Added
11
+
12
+ #### Repository Management
13
+ - `HfApi#create_repo` - Create new repositories on the Hub
14
+ - `HfApi#delete_repo` - Delete repositories from the Hub
15
+ - `HfApi#update_repo_visibility` - Change repository visibility (public/private)
16
+ - `HfApi#update_repo_settings` - Update repository settings (LFS, protection, tags, etc.)
17
+ - `HfApi#move_repo` - Move or rename repositories
18
+ - `HfApi#duplicate_space` - Duplicate Space repositories
19
+ - `HfApi#list_repo_files` - List all files in a repository
20
+ - `HfApi#list_repo_tree` - Get hierarchical tree structure of repository contents
21
+
22
+ #### File Upload Operations
23
+ - `HfApi#upload_file` - Upload single files to repositories with multipart support
24
+ - `HfApi#upload_folder` - Upload entire folders to repositories
25
+ - `HfApi#delete_file` - Delete files from repositories
26
+ - `HfApi#delete_folder` - Delete folders and their contents from repositories
27
+ - LFS file detection and handling for large file uploads
28
+
29
+ #### Repository Cards
30
+ - `RepoCard` base class for repository documentation
31
+ - `ModelCard` for machine learning model documentation
32
+ - `DatasetCard` for dataset documentation
33
+ - `SpaceCard` for Spaces (interactive demos) documentation
34
+ - `RepoCard.load` - Load cards from local files
35
+ - `RepoCard.from_hub` - Load cards directly from the Hub
36
+ - `RepoCard#push_to_hub` - Upload cards to repositories
37
+ - Card validation with metadata checking
38
+ - YAML frontmatter parsing and generation
39
+
40
+ #### Cache Management
41
+ - `Cache.delete_file_safely` - Delete individual cached files
42
+ - `Cache.delete_revision_safely` - Delete entire cached revisions
43
+ - `Cache.delete_repository_safely` - Delete cached repositories
44
+ - Enhanced cache scanning with file metadata
45
+
46
+ ### Changed
47
+ - Improved error handling for authentication operations
48
+ - Enhanced HTTP client with better multipart form data support
49
+ - Updated documentation with complete API examples
50
+
51
+ ### Fixed
52
+ - File download edge cases with missing ETags
53
+ - Cache directory creation on first use
54
+ - Token file permissions handling
55
+
56
+ ## [0.1.0] - 2025-01-20
57
+
58
+ ### Added
59
+
60
+ #### Core Infrastructure
61
+ - `Configuration` singleton for global settings
62
+ - `Constants` module with Hub endpoints and configuration
63
+ - Comprehensive error hierarchy (`HfHubHTTPError`, `RepositoryNotFoundError`, etc.)
64
+ - `Version` class with semantic versioning support
65
+
66
+ #### Authentication
67
+ - `Authentication.login` - Interactive and programmatic login
68
+ - `Authentication.logout` - Remove stored credentials
69
+ - `Authentication.whoami` - Get current user information
70
+ - Token management with file-based storage
71
+ - Git credential helper integration
72
+ - Environment variable support (`HF_TOKEN`)
73
+
74
+ #### File Operations
75
+ - `FileDownload.hf_hub_download` - Download single files with caching
76
+ - `FileDownload.snapshot_download` - Download entire repositories
77
+ - `FileDownload.try_to_load_from_cache` - Check cache without downloading
78
+ - ETag-based cache validation
79
+ - Symlink-based storage optimization
80
+ - Progress bar support for downloads
81
+
82
+ #### Repository Information
83
+ - `HfApi#repo_info` - Get detailed repository information
84
+ - `HfApi#model_info` - Get model-specific information
85
+ - `HfApi#dataset_info` - Get dataset-specific information
86
+ - `HfApi#space_info` - Get Space-specific information
87
+ - `HfApi#repo_exists` - Check if repository exists
88
+ - `HfApi#get_hf_file_metadata` - Get file metadata without downloading
89
+
90
+ #### Search and Discovery
91
+ - `HfApi#list_models` - List and filter models
92
+ - `HfApi#list_datasets` - List and filter datasets
93
+ - `HfApi#list_spaces` - List and filter Spaces
94
+ - Support for filtering by author, tags, search queries
95
+ - Sorting by downloads, likes, creation date, etc.
96
+
97
+ #### Cache Management
98
+ - `Cache.scan_cache_dir` - Analyze cache contents
99
+ - `Cache.cached_assets_path` - Get path to cached assets
100
+ - Detailed cache statistics and metadata
101
+ - Support for custom cache directories
102
+
103
+ #### Type System
104
+ - `Types::ModelInfo` - Model metadata
105
+ - `Types::DatasetInfo` - Dataset metadata
106
+ - `Types::SpaceInfo` - Space metadata
107
+ - `Types::User` - User information
108
+ - `Types::CommitInfo` - Git commit details
109
+ - `Types::HFCacheInfo` - Cache structure information
110
+
111
+ #### Utilities
112
+ - `Utils::HttpClient` - HTTP client with retry logic and authentication
113
+ - `Utils::Retry` - Exponential backoff retry mechanism
114
+ - `Utils::Headers` - User-Agent and header management
115
+ - `Utils::Auth` - Token resolution and management
116
+ - `Utils::Validators` - Input validation helpers
117
+ - `Utils::Paths` - Path normalization and utilities
118
+ - `Utils::Progress` - Download progress tracking
119
+
120
+ ### Documentation
121
+ - Comprehensive README with examples
122
+ - API documentation with YARD
123
+ - Installation and setup guide
124
+ - Configuration examples
125
+
126
+ [0.2.0]: https://github.com/durableprogramming/huggingface-hub-ruby/compare/v0.1.0...v0.2.0
127
+ [0.1.0]: https://github.com/durableprogramming/huggingface-hub-ruby/releases/tag/v0.1.0