mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08:00
retry downloading the benchmarks datasets
This commit is contained in:
parent
087da5621a
commit
84a784834e
@ -80,7 +80,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
let url = format!("{}/{}.{}.gz", BASE_URL, dataset, extension);
|
let url = format!("{}/{}.{}.gz", BASE_URL, dataset, extension);
|
||||||
eprintln!("downloading: {}", url);
|
eprintln!("downloading: {}", url);
|
||||||
let bytes = download_dataset(url.clone())?;
|
let bytes = retry(|| download_dataset(url.clone()), 10)?;
|
||||||
eprintln!("{} downloaded successfully", url);
|
eprintln!("{} downloaded successfully", url);
|
||||||
eprintln!("uncompressing in {}", out_file.display());
|
eprintln!("uncompressing in {}", out_file.display());
|
||||||
uncompress_in_file(bytes, &out_file)?;
|
uncompress_in_file(bytes, &out_file)?;
|
||||||
@ -89,6 +89,15 @@ fn main() -> anyhow::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn retry<Ok, Err>(fun: impl Fn() -> Result<Ok, Err>, times: usize) -> Result<Ok, Err> {
|
||||||
|
for _ in 0..times {
|
||||||
|
if let ok @ Ok(_) = fun() {
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fun()
|
||||||
|
}
|
||||||
|
|
||||||
fn download_dataset<U: IntoUrl>(url: U) -> anyhow::Result<Cursor<Bytes>> {
|
fn download_dataset<U: IntoUrl>(url: U) -> anyhow::Result<Cursor<Bytes>> {
|
||||||
let bytes =
|
let bytes =
|
||||||
reqwest::blocking::Client::builder().timeout(None).build()?.get(url).send()?.bytes()?;
|
reqwest::blocking::Client::builder().timeout(None).build()?.get(url).send()?.bytes()?;
|
||||||
|
Loading…
Reference in New Issue
Block a user