Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions crates/skippy-hf-hub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rustdoc-args = ["--cfg", "docsrs"]

# The `hf-xet` package exposes its Rust library as `xet`.
[package.metadata.cargo-machete]
ignored = ["hf-xet"]
ignored = ["hf-xet", "tower-http"]

[dependencies]
bytes = "1"
Expand All @@ -38,7 +38,7 @@ pathdiff = "0.2"
percent-encoding = "2"
tokio-util = { version = "0.7", features = ["io"] }
tracing = "0.1"
hf-xet = "1.5.3"
hf-xet = "1.6"
sha2 = "0.11"

[features]
Expand All @@ -47,14 +47,20 @@ blocking = ["tokio/rt"]
rustls-tls = ["reqwest/rustls"]
socks = ["reqwest/socks"]

[target.'cfg(not(target_family = "wasm"))'.dependencies]
# Reqwest needs this version to follow redirects for bracketed filenames.
tower-http = { version = "0.6.9", default-features = false }

[target.'cfg(target_family = "wasm")'.dependencies]
# `tokio-retry` -> `rand` 0.8 -> `rand_core` 0.6 -> `getrandom` 0.2 transitively
# needs the `js` feature on wasm32 to compile.
getrandom = { version = "0.2", features = ["js"] }
gloo-timers = { version = "0.3", features = ["futures"] }
tokio = { version = "1", features = ["macros", "sync"] }
wasm-bindgen-futures = "0.4"

[dev-dependencies]
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread"] }
tempfile = "3"
serial_test = "3"
http = "1"
Expand Down
36 changes: 11 additions & 25 deletions crates/skippy-hf-hub/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
# Skippy HF Hub client

This is the Skippy-owned generic HF client, imported from the Apache-2.0
Hugging Face `hf-hub` lineage through the Mesh-LLM fork at
`c47b78835eeb98b7339718f8701adf80b8685446` (`hf-hub/`, published as
`mesh-llm-hf-hub` 1.0.2). The original license is included as `LICENSE`.
`SOURCE_PROVENANCE.json` records original and imported source hashes and local
changes. The import uses workspace versioning; the upstream source version
remains 1.0.2 in that provenance record.

Production changes beyond rustfmt are limited to boxing four inner download
futures before awaiting them, removing an uncalled private HEAD helper, and
treating empty or blank endpoint, home and cache variables as unset.
The public finishers remain async methods; their future representation and
allocation change. This restores the retained future-size tests, which also
failed against the unchanged pinned source on this toolchain. The relative
location predicate remains test-only with its classification test.

Token-precedence tests use
child-process environments instead of mutating the parent test environment;
all eight original precedence cases remain covered. The `hf_hub` library name
keeps consumer import paths and upstream examples intact; the actual Cargo
package identity and path dependency are `skippy-hf-hub`.

This source import does not establish standalone model acquisition acceptance.
Real download, cache reuse/removal, blocking/async and failure-path validation
remain part of the Skippy extraction acceptance gate.
Skippy maintains this Apache-2.0 client for model and package acquisition.
The current import comes from the Mesh-LLM fork at
[`d6411b8`](https://github.com/Mesh-LLM/hf-hub/commit/d6411b8c05284f617b96d00af91eef39a996cc8d),
which includes Hugging Face upstream main at `68a489d`. The original license
is included as `LICENSE`. `SOURCE_PROVENANCE.json` records the exact source
revision, source and import hashes, and local changes.

Skippy retains Hugging Face environment defaults, resumable HTTP and Xet
downloads, cache path admission and locking, and the request configuration
used by its model acquisition code. The Rust import remains `hf_hub` and the
workspace and crates.io package remain `skippy-hf-hub`.

## Original client documentation

Expand Down
102 changes: 55 additions & 47 deletions crates/skippy-hf-hub/SOURCE_PROVENANCE.json
Original file line number Diff line number Diff line change
@@ -1,66 +1,74 @@
{
"source_repository": "https://github.com/Mesh-LLM/hf-hub",
"source_commit": "c47b78835eeb98b7339718f8701adf80b8685446",
"source_commit": "d6411b8c05284f617b96d00af91eef39a996cc8d",
"source_path": "hf-hub",
"source_package": "mesh-llm-hf-hub",
"source_version": "1.0.2",
"source_version": "1.1.0",
"sha256": {
"src/blocking.rs": "1935644c61e5cb82060cfc9945ff5d04d2a2ce5af4e38c72e94f263cb6cbbc67",
"src/buckets/mod.rs": "ba94cb72475827fc7a679d97377d4bbbed575e06eef7594be48a3ed9f3d30295",
"src/buckets/sync.rs": "a4d44f9f65ac652e86826f422ffdcc1aea8f930c24209441b2df3ad75cf265df",
"src/cache/mod.rs": "fb7e12426dbc5aada673e3fd297248010e5ac98f645109d365a25dc3a25396f0",
"src/cache/storage.rs": "0cd8ec409a25fcafc44d6c72d839e1c9a24cdf1e4c71f08c0c28c156a6fea56d",
"src/client.rs": "0af0b8d2717edabbc9a673ac63bbefe11b2872982fff918a2723a309f93593bc",
"src/constants.rs": "ab742819b90a62c3e1fdb63d98bf12b4f38b3fc440e29fa80dfe13cb2a869417",
"src/error.rs": "5f6084578ebf7608bd2a68f1871205ff4571c5b999b2677b77c0fac596273391",
"src/lib.rs": "cfbfa538d3c0fe3f43e6b3b2a2f0591bcb8a3ae384bbb2d155f76dc27626fbb8",
"src/buckets/mod.rs": "2419723d58548bc26ac106137f981e7445389685eb04e49c7384e255df226916",
"src/buckets/sync.rs": "021eb0f9f050fa06835cf6137088edcb35368fce46a1f6e4d7bde61fce796520",
"src/cache/mod.rs": "aa41534a9e63ad85681ac1306fb5e2f786ae956098fb724ab5a36a372b9dc041",
"src/cache/storage.rs": "5109a5d811f08771acc49ac9b72717683caa31d477874a4e732eff466167c306",
"src/client.rs": "c814da1f12dd65d4ca044e63935a8bafcf74e2e4d59df50a2f5ed7c1be875e27",
"src/constants.rs": "bc3218bc5948720960c0caa5318861a1c19616d9decfb803496499e393b9bb9e",
"src/error.rs": "2187c67f38b265dff9f9cb89d2b8546578c181069e6f5a385fcf9c935f7bf7c3",
"src/lib.rs": "70d609d5ccc6eae354dd45ef03e87fb3f4027fcdcc10738d98e157bd960f91b8",
"src/pagination.rs": "1e36d0193e8808a9b3cad8c7b4912e48b9c21e35efa7f0c131e9763ccd29ca07",
"src/progress.rs": "472283af066d1e438d516d83c5b77fa73880893595abdb97dc0a9fcca027c645",
"src/repository/commits.rs": "0c3430475029361f9a41a049edbeeb3007ce4fa5e570838ca83a0cf689a06323",
"src/repository/diff.rs": "dbd33c566752ac3d4b921d997517fe4c37efdd0402a478a1ca86f79e2d892cd6",
"src/repository/download.rs": "82ee7da54146f15b09f65f5753b6ed850d00524983b4cc89d1b0bc579b76c047",
"src/repository/files.rs": "c64744b94d4db8626a804e8d3fb8646ff0d0c4c5c8de224b87c035b9137f2cc2",
"src/repository/listing.rs": "94c8a8c38845424f7c577ebd8f0830db230c99686170e3a069e15c8c9fd41c97",
"src/repository/mod.rs": "f0128d8efa206f1909932b5044f6e3674a12066bc06ad62ad65d9a0d66413451",
"src/repository/repo_type.rs": "54bb833ba0c2bc9a2b7b39cc29e921ebdad7d1bb184edf03015cfe56e34ae682",
"src/repository/upload.rs": "5af0493b0ebdd56b54f0b08f7c3f6ffc7d1f4dcae28c25f601968e729da36233",
"src/retry.rs": "19e94a9f14d5f918a80aef41e7177398bd2832a0119d048d8508529095a7a8b1",
"src/spaces.rs": "f95703b394e3182a1ff7bc294b83188e5361dea3944297a4e3fcbcc38b4b9810",
"src/users.rs": "11c196c1696d3671b9357cde25292eb41bbbd140b5afd3c3caa9a29ef5985f6a",
"src/xet.rs": "557393651930464f819627943a784d3177c0c852be48330f9a914c17ea7d95ce",
"src/repository/commits.rs": "83d3bbaa002b2b2242df2998781967415aa645e8dd1f644dc11d74685cc5a7fe",
"src/repository/diff.rs": "7c26a26e8de1a0a6a6fe493968bbe1a3723323e62edc6cd652345e44c6d5ed93",
"src/repository/download.rs": "88093ddead119bb9fa905760102120163ae10337a6b1c9eeb5b54a82f2c22be0",
"src/repository/files.rs": "e54450ac6cc97296833e5614301c296ee065a7b02a04428e8594baf6bc69d8a9",
"src/repository/listing.rs": "94e9c670a7607a346e6b712d1d2db71ddc774a88b8643df0201107488081fabc",
"src/repository/mod.rs": "d4316b81f49b4a1deebcdbf17be2d2de5f24798791c02059c02ff058b7392505",
"src/repository/repo_type.rs": "69e19736e993fc44eb2aa70f133bbd9f459e1bae4c3ca49aaa85e370d9d5495c",
"src/repository/upload.rs": "37d7ddaea88af1cd883f4fac3180121ce5afe60c83eda333f5a3257d8727f84f",
"src/retry.rs": "952b0a04098ade1089824f35f322253d806bf2079811c032bff245fa6d8eddc4",
"src/spaces.rs": "8d4b2efb059438834a76f2e0b76c0c95a7def6ca3ef5521208fa8df270b38856",
"src/test_support.rs": "2bd20f8fbf8297c53b688908b2a2c7c8c1ada8afcce948fa5dc37ab089d646b2",
"src/users.rs": "fc984cb85698bedb79bba9780c4d60a8c3b9622fafae3388eb9099667f441c93",
"src/xet.rs": "9cf984f745ef55903602ae67edf4c1a2ce65618bef13030f5bae803287190e46",
"tests/future_size.rs": "a1f7a586f8c4ba7c55be6e9c94a15c0ecef7f8533aedadca95c1454f50237e6f"
},
"local_deltas": [
"rustfmt --edition 2024 over all Rust sources and tests",
"src/client.rs: preserve eight token-precedence scenarios in subprocess environments with a filtered child assertion worker",
"src/client.rs: remove uncalled private head_with_relative_redirects; retain is_relative_location and its classification test under cfg(test)",
"src/constants.rs, src/client.rs: treat an empty or whitespace-only HF_ENDPOINT, HF_HOME, XDG_CACHE_HOME, HF_HUB_CACHE, HUGGINGFACE_HUB_CACHE or HF_TOKEN_PATH as unset; the empty-variable case is tested in a child process",
"src/repository/download.rs: box the four inner download implementation futures before awaiting them inside existing public async finishers; signatures remain async, while future representation and allocation change; original 2048/4096-byte limits retained"
"Use the Skippy workspace package identity, Rust library name hf_hub, and existing reqwest TLS defaults; format sources with workspace rustfmt.",
"Retain Hugging Face endpoint, token, and cache environment defaults and isolated subprocess tests; retain configurable request timeout and shared HTTP client builder.",
"Keep same-origin metadata redirect handling and origin validation for authenticated download HEAD requests.",
"Retain validated cache commit and ETag admission, the scoped cache lookup and cached revision helpers, and workspace cache lock behavior.",
"Retain HTTP range and Xet stream resumption, including byte-count validation and force-download handling; retain and separate the loopback download tests.",
"Retain boxed download futures and the future size regression tests.",
"Stage local-directory transfers for atomic publication, keep cached commits paired with conditional ETags, and preserve local User-Agent and LFS wire compatibility."
],
"imported_sha256": {
"src/blocking.rs": "ca8360d3688bb7a28f40012cc169c372e2cb53e91a99fb4915746a14b186d1d8",
"src/buckets/mod.rs": "4319afd7f0ab8d8604f1facdc48c2f4c63dac7b3da173c16c30c96cd4e46e559",
"src/buckets/sync.rs": "8feefbfaa9a43c98be87dd1b30cd8c0fffea66d8b010e93cd2ac210c5dd5e4c0",
"src/cache/mod.rs": "fb7e12426dbc5aada673e3fd297248010e5ac98f645109d365a25dc3a25396f0",
"src/cache/storage.rs": "6848eb6cf13b836d582f1797c60be98c2723492b59ed327a7356579ddb0c8dd4",
"src/client.rs": "6567e1d850d291480a2793cc7cbf8e6a773e6f28e471339b4b869907b675538e",
"src/constants.rs": "ab742819b90a62c3e1fdb63d98bf12b4f38b3fc440e29fa80dfe13cb2a869417",
"src/error.rs": "4b3aeb8a9f3eaed8e0a6d7bf16f470acaf11d38f3b587966baaa006e7017a0b6",
"src/lib.rs": "bf6bbc049c84fb0c183db4d295837513763b0c295e821f0faee6be836c01d89b",
"src/buckets/mod.rs": "56974b7e791ade178e719e17ac71c2a93ebd5f43492a37fcff9f27a3d045b567",
"src/buckets/sync.rs": "d3976676a12fcaec95e33d7e79d1e6bc72757d07b7dc18abc650e440d282c1bd",
"src/cache/mod.rs": "94efb1f3921a2a0834a76889914cb71aafb252425243cf210343a085320f1e7c",
"src/cache/storage.rs": "d2c7aeb27b4a671fa2c3779c53384ad89b859348d8e236977103bca69e639b15",
"src/client.rs": "fe8ea3dd91926ace8ff60437a1416296ec33d52c7c28881a29244e046a402af2",
"src/constants.rs": "34d97259c711ccece77966d56a9c95009650a7620d8fa6aa4f104fa3d8949b06",
"src/error.rs": "3dc93fadd8d44779d3dbe2a3ea5b413eb5c3ee78a027e4be327470684626eabf",
"src/lib.rs": "cb5d2bcdfec107aeb59acec101387b1fa064482be4a1c12d7331470e5437dfee",
"src/pagination.rs": "8735ab942120711d391f761bdf7e9f4f5de76a1e923722cfcafa98c77c8aff00",
"src/progress.rs": "9bdc1a9ca8b89f39a48d9045fdc55558d7660bad684ce9a61cc215c98a94c92e",
"src/repository/commits.rs": "a9beb194ee45b30636844de7a85cf0fc5fe83698c1c77202da2fb33a2912f3a5",
"src/repository/diff.rs": "d75a0064385b96d36c678aff8aa65909b58634a5c3336de8f96490561fa40ac5",
"src/repository/download.rs": "1289dd4617039ed3b04e985159c36ad2f1edaa868d5bc4e998ddc86b38c04209",
"src/repository/files.rs": "80eb8d67d577bf32eab83544eca49cdca391eab808c769dce5c15b4bf9c22b1d",
"src/repository/listing.rs": "d829e36e498066ee5815dbf5f4a6a98f41b647f6a40ea14d91a1e591c17cf318",
"src/repository/mod.rs": "b479c9fcf8c6547f31e27369f04b103faff8bb77176cca3027e1836c41ce2941",
"src/repository/repo_type.rs": "edf5e6da044ffc565db8afd5a8ce07c8116bc394d897702b8a8173a52d079f66",
"src/repository/upload.rs": "b8cfacd31e6cacbc59aff2946a84bfc19af63ec330996af6be9cfa1c96b244b6",
"src/retry.rs": "6985995d0030322161b5ec750e95f87e76c87316bb0ca68764ada365bcacb474",
"src/spaces.rs": "c9a564254dd9b1ab8c01ec0353d2b12a506363e59e4d4fc4e4e545cfb8e6274c",
"src/users.rs": "c1a451f77d79264120537769eddfc920d4879fbb27a4e37b839135d4c147cf89",
"src/xet.rs": "d204a9b93cb85a423074012c8cc5e1ef6a8839c252d26e018acae39ca0f84588",
"src/repository/commit_admission.rs": "323e6ea195dcacc062a8616ae37535400243d96038daf248013126bd351e1b7c",
"src/repository/commits.rs": "2a24d49b66d1855a655acff80846be1921bab99331e2f09617c4ff27e49a8b35",
"src/repository/diff.rs": "5c69579f477107f141342763aa21e79940e89ee055da2eff452a1248537773b2",
"src/repository/download.rs": "21f06c112638366c36e4fc71de48b17f6c66fefd7b4a9cb20f44e149d1ec41d3",
"src/repository/download/local.rs": "0d50030ae5f654de64a390234d9c6a29ae32e90164337bb6cd53ece70aecc108",
"src/repository/download/resume_tests.rs": "fdd3a6b8e7569388a2e5a4a6c6d8a1045e8211df6d8a7c46b5a4f00ca15fb9f0",
"src/repository/download/tests.rs": "a33b6828e490659a258c81e4c1d93cffea812f570adc925b56bc310694368790",
"src/repository/files.rs": "4c35cde3fbb95b03e66baf4c884d03cd90a7ccca55dd07dbf653ad82f2010b81",
"src/repository/listing.rs": "c74c704002b87c38356747b1d7553c5b9de4a7f7af3a7cdc001360f4b5493766",
"src/repository/mod.rs": "3d050ef9c6d9a38a966780a9635c5c6b420cb6e0fa6db7f87cf4f694099a7a9c",
"src/repository/repo_type.rs": "6f3c55caeeb0e2889a0851b1d50682eb801522385d079c8e8aa62972cc62840a",
"src/repository/upload.rs": "18fbee7f5a61536ec4cb3ea71da19a07a2a391e5c9a33ef38793569fbf78f59e",
"src/retry.rs": "939263be307dd593fcda96b73c723c291b149ac0cb9e64dbd17f4e3834a736ff",
"src/spaces.rs": "3c9234e4df134fbaf20816b40f98b7f48b85746296e955fa3f7ba11f9409a782",
"src/test_support.rs": "e46de3cee35d316f010977cf90fd626afc28dc5770bec5ec43ee92ff89f01049",
"src/users.rs": "222a3731ada511d7d58c6cb961980504a40d566bb31c94442a00d3a915f736ae",
"src/xet.rs": "e6c0ec51118b163cb7f03a3de45134cf22b2f8ca7fc234795482c07e590a6ed7",
"tests/future_size.rs": "9a99115c6326140d92a56adc903a94f14b6dc45fd9e2b8f718bba89c0e44ac21"
}
}
69 changes: 60 additions & 9 deletions crates/skippy-hf-hub/src/buckets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,16 @@ impl HFBucket {
/// # Parameters
///
/// - `prefix`: filter results to entries under this prefix.
/// - `recursive` (default `false`): traverse subdirectories.
/// - `recursive`: traverse subdirectories. Only sent to the Hub when set; when unset the Hub's default applies,
/// which is a recursive listing. Pass `false` to list only the immediate children of `prefix`.
#[builder(finish_fn = send, derive(Debug, Clone))]
pub fn list_tree(
&self,
/// Filter results to entries under this prefix.
#[builder(into)]
prefix: Option<String>,
/// Traverse subdirectories.
#[builder(default)]
recursive: bool,
recursive: Option<bool>,
) -> HFResult<impl Stream<Item = HFResult<BucketTreeEntry>> + '_> {
let bucket_id = self.bucket_id();
let url_str = format!(
Expand All @@ -167,8 +167,8 @@ impl HFBucket {
}

let mut query = vec![];
if recursive {
query.push(("recursive".to_string(), "true".to_string()));
if let Some(recursive) = recursive {
query.push(("recursive".to_string(), recursive.to_string()));
}

Ok(self.hf_client.paginate(url, query, None))
Expand Down Expand Up @@ -1168,7 +1168,7 @@ impl HFClient {
}
}

#[cfg(feature = "blocking")]
#[cfg(all(feature = "blocking", not(target_family = "wasm")))]
#[bon]
impl crate::blocking::HFClientSync {
/// Blocking counterpart of [`HFClient::create_bucket`]. See the async method for parameters
Expand Down Expand Up @@ -1240,7 +1240,7 @@ impl crate::blocking::HFClientSync {
}
}

#[cfg(feature = "blocking")]
#[cfg(all(feature = "blocking", not(target_family = "wasm")))]
#[bon]
impl crate::blocking::HFBucketSync {
/// Blocking counterpart of [`HFBucket::info`].
Expand All @@ -1255,14 +1255,14 @@ impl crate::blocking::HFBucketSync {
pub fn list_tree(
&self,
#[builder(into)] prefix: Option<String>,
#[builder(default)] recursive: bool,
recursive: Option<bool>,
) -> HFResult<Vec<BucketTreeEntry>> {
self.runtime.block_on(async move {
let stream = self
.inner
.list_tree()
.maybe_prefix(prefix)
.recursive(recursive)
.maybe_recursive(recursive)
.send()?;
futures::pin_mut!(stream);
let mut items = Vec::new();
Expand Down Expand Up @@ -1424,3 +1424,54 @@ mod tests {
assert!(bare.size.is_none() && bare.mtime.is_none() && bare.content_type.is_none());
}
}

#[cfg(all(test, not(target_family = "wasm")))]
mod list_tree_tests {
use futures::TryStreamExt;

use super::BucketTreeEntry;
use crate::test_support::mock_hub;

const EMPTY_PAGE: &str = "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: 2\r\nConnection: close\r\n\r\n[]";

async fn list_tree_against(request_line: &str, recursive: Option<bool>) {
let (client, server) = mock_hub(&[(request_line, EMPTY_PAGE)]).await;
let entries: crate::HFResult<Vec<BucketTreeEntry>> = match client
.bucket("my-org", "my-bucket")
.list_tree()
.prefix("data")
.maybe_recursive(recursive)
.send()
{
Ok(stream) => stream.try_collect().await,
Err(err) => Err(err),
};
server.abort();
let entries = entries
.unwrap_or_else(|err| panic!("expected request `{request_line}` to match: {err}"));
assert!(entries.is_empty());
}

#[tokio::test]
async fn list_tree_omits_the_recursive_flag_by_default() {
list_tree_against("GET /api/buckets/my-org/my-bucket/tree/data HTTP/1.1", None).await;
}

#[tokio::test]
async fn list_tree_sends_recursive_false_when_set() {
list_tree_against(
"GET /api/buckets/my-org/my-bucket/tree/data?recursive=false HTTP/1.1",
Some(false),
)
.await;
}

#[tokio::test]
async fn list_tree_sends_recursive_true_when_set() {
list_tree_against(
"GET /api/buckets/my-org/my-bucket/tree/data?recursive=true HTTP/1.1",
Some(true),
)
.await;
}
}
Loading
Loading