AryanBagade opened a new pull request, #6833:
URL: https://github.com/apache/opendal/pull/6833
Enable HuggingFace Spaces support by extending the repo_type enum and URL
templates to allow reading/listing Space repositories like models and datasets.
# Which issue does this PR close?
Part of #6830
# Rationale for this change
Currently, the HuggingFace service only supports `model` and `dataset`
repository types. Users cannot access HuggingFace Spaces, which are an
important repository type for hosting ML demos and applications.
This change enables full support for Spaces by:
- Adding `Space` to the `RepoType` enum
- Implementing URL patterns following HuggingFace's Spaces API structure
- Allowing users to read files and list directories from Spaces
repositories
# What changes are included in this PR?
**Core changes:**
- Added `Space` variant to `RepoType` enum in `backend.rs`
- Removed error that blocked space repo_type
- Added URL patterns for Spaces API in `core.rs`:
* `hf_path_info`: `/api/spaces/{repo_id}/paths-info/{revision}`
* `hf_list`: `/api/spaces/{repo_id}/tree/{revision}/{path}`
* `hf_resolve`: `/spaces/{repo_id}/resolve/{revision}/{path}`
- Updated builder documentation to reflect space support
**Tests added:**
- `build_accepts_space_repo_type` -> Verifies builder accepts "space"
- `test_hf_path_info_url_space` -> Tests paths-info URL generation
- `test_hf_list_url_space` -> Tests tree listing URL generation
- `test_hf_resolve_url_space` -> Tests file resolve URL generation
# Are there any user-facing changes?
**Yes - New Features:**
Users can now access HuggingFace Spaces by setting `repo_type("space")`:
```rust
let builder = Huggingface::default()
.repo_type("space") // NEW!
.repo_id("username/space-name")
.revision("main");
let op = Operator::new(builder)?.finish();
// Can now read/list files from Spaces!
```
<!---
If there are any breaking changes to public APIs, please add the
`breaking-changes` label.
-->
No breaking changes, Fully backward compatible with existing model and
dataset usage.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]