Skip to content

Update Dependencies #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
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
4 changes: 2 additions & 2 deletions onnxruntime-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ keywords = ["neuralnetworks", "onnx", "bindings"]
[dependencies]

[build-dependencies]
bindgen = {version = "0.55", optional = true}
ureq = "1.5.1"
bindgen = { version = "0.56", optional = true }
ureq = "2"

# Used on Windows
zip = "0.5"
Expand Down
14 changes: 9 additions & 5 deletions onnxruntime-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
/// WARNING: If version is changed, bindings for all platforms will have to be re-generated.
/// To do so, run this:
/// cargo build --package onnxruntime-sys --features generate-bindings
const ORT_VERSION: &str = "1.5.2";
const ORT_VERSION: &str = "1.6.0";

/// Base Url from which to download pre-built releases/
const ORT_RELEASE_BASE_URL: &str = "https://github.com/microsoft/onnxruntime/releases/download";
Expand Down Expand Up @@ -106,15 +106,19 @@ fn generate_bindings(include_dir: &Path) {
}

fn download<P: AsRef<Path>>(source_url: &str, target_file: P) {
let resp = ureq::get(source_url)
.timeout_connect(1_000) // 1 second
let agent = ureq::AgentBuilder::new()
.timeout_read(std::time::Duration::from_secs(1)) // 1 second
.timeout(std::time::Duration::from_secs(300))
.call();
.build();

if resp.error() {
let resp = agent.get(source_url).call();

if resp.is_err() {
panic!("ERROR: Failed to download {}: {:#?}", source_url, resp);
}

let resp = resp.unwrap();

let len = resp
.header("Content-Length")
.and_then(|s| s.parse::<usize>().ok())
Expand Down
10 changes: 5 additions & 5 deletions onnxruntime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ name = "integration_tests"
required-features = ["model-fetching"]

[dependencies]
onnxruntime-sys = {version = "0.0.10", path = "../onnxruntime-sys"}
onnxruntime-sys = { version = "0.0.10", path = "../onnxruntime-sys" }

lazy_static = "1.4"
ndarray = "0.13"
ndarray = "0.14"
thiserror = "1.0"
tracing = "0.1"

# Enabled with 'model-fetching' feature
ureq = {version = "1.5.1", optional = true}
ureq = { version = "2", optional = true }

[dev-dependencies]
image = "0.23"
test-env-log = {version = "0.2", default-features = false, features = ["trace"]}
test-env-log = { version = "0.2", default-features = false, features = ["trace"] }
tracing-subscriber = "0.2"
ureq = "1.5.1"
ureq = "2.0"

[features]
# Fetch model from ONNX Model Zoo (https://github.com/onnx/models)
Expand Down
13 changes: 9 additions & 4 deletions onnxruntime/src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,15 @@ impl AvailableOnnxModel {
"Downloading file, please wait....",
);

let resp = ureq::get(url)
.timeout_connect(1_000) // 1 second
.timeout(Duration::from_secs(180)) // 3 minutes
.call();
let agent = ureq::AgentBuilder::new()
.timeout_connect(Duration::from_secs(1)) // 1 second .timeout_read(std::time::Duration::from_secs(1)) // 1 second
.timeout(Duration::from_secs(180)) // 3 minutes .timeout(std::time::Duration::from_secs(180))// 3 minutes
.build();

let resp = agent
.get(url)
.call()
.map_err(OrtDownloadError::DownloadError)?;

assert!(resp.has("Content-Length"));
let len = resp
Expand Down
4 changes: 4 additions & 0 deletions onnxruntime/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ pub enum OrtApiError {
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum OrtDownloadError {
/// Generic download error
#[cfg(feature = "model-fetching")]
#[error("Error downloading data")]
DownloadError(#[from] ureq::Error),
/// Generic input/output error
#[error("Error downloading data to file: {0}")]
IoError(#[from] io::Error),
Expand Down