Skip to content

Commit

Permalink
v0.2.6 add mirror support
Browse files Browse the repository at this point in the history
  • Loading branch information
Mon-ius committed May 13, 2024
1 parent 04e9007 commit ff433e1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@

🎈Rust-based interface for Huggingface 🤗 download.

`./hdf "https://huggingface.co/deepseek-ai/DeepSeek-V2"`
> For public,
`./hdf https://huggingface.co/deepseek-ai/DeepSeek-V2`

> For Gated
`./hdf https://huggingface.co/meta-llama/Meta-Llama-3-70B -t hf_xxxxxxxxxx`

> For Custom Save path
`./hdf https://huggingface.co/meta-llama/Meta-Llama-3-70B -t hf_xxxxxxxxxx -d /data/llm`

> Download with mirror
`./hdf https://huggingface.co/meta-llama/Meta-Llama-3-70B -t hf_xxxxxxxxxx -d /data/llm -m hf-mirror.com`

For a more convinent user experience, execute:

Expand Down
2 changes: 1 addition & 1 deletion hfd-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hfd-cli"
version = "0.2.5"
version = "0.2.6"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion hfd-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let start_time = std::time::Instant::now();

let cli = Cli::parse();
let _ = _rt(&cli.url, cli.opt.token.as_deref(), cli.opt.dir.as_deref());
let _ = _rt(&cli.url, cli.opt.token.as_deref(), cli.opt.dir.as_deref(), cli.opt.mirror.as_deref());
println!("Processing time: {:?}", start_time.elapsed());
Ok(())
}
12 changes: 10 additions & 2 deletions hfd-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ impl HfClient {
self
}

pub fn apply_endpoint(mut self, _endpoint: Option<&str>) -> Self{
if let Some(ep) = _endpoint {
self.hf_url = self.hf_url.with_endpoint(ep);
}
self
}

async fn list_files(&self) -> Result<Vec<String>, Box<dyn std::error::Error>> {
let client = reqwest::Client::builder()
.pool_idle_timeout(Duration::from_secs(1))
Expand Down Expand Up @@ -238,11 +245,12 @@ impl HfClient {
}
}

pub fn _rt(_url: &str, _token: Option<&str>, _dir: Option<&str>) -> Result<(), Box<dyn std::error::Error>> {
pub fn _rt(_url: &str, _token: Option<&str>, _dir: Option<&str>, _mir: Option<&str>) -> Result<(), Box<dyn std::error::Error>> {
let rt = tokio::runtime::Builder::new_multi_thread().enable_all().build()?;
let hfc = HfClient::build(_url)?
.apply_token(_token)
.apply_root(_dir);
.apply_root(_dir)
.apply_endpoint(_mir);

let _ = rt.block_on(hfc.download_all());
Ok(())
Expand Down

0 comments on commit ff433e1

Please sign in to comment.