Skip to content

Commit e6125ad

Browse files
authored
Merge pull request #75 from nbigaouette/update-dependencies
Upgrade dependencies
2 parents 850d8f1 + 9253687 commit e6125ad

File tree

7 files changed

+25
-18
lines changed

7 files changed

+25
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
### Changed
1616

1717
- Fix Windows i686 compilation ([#70](https://github.com/nbigaouette/onnxruntime-rs/pull/70))
18+
- Upgrade dependencies ([#75](https://github.com/nbigaouette/onnxruntime-rs/pull/75))
1819

1920
## [0.0.11] - 2021-02-22
2021

onnxruntime-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ keywords = ["neuralnetworks", "onnx", "bindings"]
1818

1919
[build-dependencies]
2020
bindgen = { version = "0.55", optional = true }
21-
ureq = "1.5.1"
21+
ureq = "2.1"
2222

2323
# Used on Windows
2424
zip = "0.5"

onnxruntime-sys/build.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,9 @@ where
122122
P: AsRef<Path>,
123123
{
124124
let resp = ureq::get(source_url)
125-
.timeout_connect(1_000) // 1 second
126125
.timeout(std::time::Duration::from_secs(300))
127-
.call();
128-
129-
if resp.error() {
130-
panic!("ERROR: Failed to download {}: {:#?}", source_url, resp);
131-
}
126+
.call()
127+
.unwrap_or_else(|err| panic!("ERROR: Failed to download {}: {:?}", source_url, err));
132128

133129
let len = resp
134130
.header("Content-Length")

onnxruntime/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ name = "integration_tests"
1919
required-features = ["model-fetching"]
2020

2121
[dependencies]
22-
onnxruntime-sys = {version = "0.0.11", path = "../onnxruntime-sys"}
22+
onnxruntime-sys = { version = "0.0.11", path = "../onnxruntime-sys" }
2323

2424
lazy_static = "1.4"
25-
ndarray = "0.13"
25+
ndarray = "0.15"
2626
thiserror = "1.0"
2727
tracing = "0.1"
2828

2929
# Enabled with 'model-fetching' feature
30-
ureq = {version = "1.5.1", optional = true}
30+
ureq = { version = "2.1", optional = true }
3131

3232
[dev-dependencies]
3333
image = "0.23"
34-
test-env-log = {version = "0.2", default-features = false, features = ["trace"]}
34+
test-env-log = { version = "0.2", default-features = false, features = ["trace"] }
3535
tracing-subscriber = "0.2"
36-
ureq = "1.5.1"
36+
ureq = "2.1"
3737

3838
[features]
3939
# Fetch model from ONNX Model Zoo (https://github.com/onnx/models)

onnxruntime/src/download.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ impl AvailableOnnxModel {
7979
);
8080

8181
let resp = ureq::get(url)
82-
.timeout_connect(1_000) // 1 second
8382
.timeout(Duration::from_secs(180)) // 3 minutes
84-
.call();
83+
.call()
84+
.map_err(Box::new)
85+
.map_err(OrtDownloadError::UreqError)?;
8586

8687
assert!(resp.has("Content-Length"));
8788
let len = resp

onnxruntime/src/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ pub enum OrtDownloadError {
140140
/// Generic input/output error
141141
#[error("Error downloading data to file: {0}")]
142142
IoError(#[from] io::Error),
143+
#[cfg(feature = "model-fetching")]
144+
/// Download error by ureq
145+
#[error("Error downloading data to file: {0}")]
146+
UreqError(#[from] Box<ureq::Error>),
143147
/// Error getting content-length from an HTTP GET request
144148
#[error("Error getting content-length")]
145149
ContentLengthError,

onnxruntime/tests/integration_tests.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use std::{
55
time::Duration,
66
};
77

8+
use onnxruntime::error::OrtDownloadError;
9+
810
mod download {
911
use super::*;
1012

@@ -294,16 +296,17 @@ mod download {
294296
}
295297
}
296298

297-
fn get_imagenet_labels() -> Result<Vec<String>, io::Error> {
299+
fn get_imagenet_labels() -> Result<Vec<String>, OrtDownloadError> {
298300
// Download the ImageNet class labels, matching SqueezeNet's classes.
299301
let labels_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("synset.txt");
300302
if !labels_path.exists() {
301303
let url = "https://s3.amazonaws.com/onnx-model-zoo/synset.txt";
302304
println!("Downloading {:?} to {:?}...", url, labels_path);
303305
let resp = ureq::get(url)
304-
.timeout_connect(1_000) // 1 second
305306
.timeout(Duration::from_secs(180)) // 3 minutes
306-
.call();
307+
.call()
308+
.map_err(Box::new)
309+
.map_err(OrtDownloadError::UreqError)?;
307310

308311
assert!(resp.has("Content-Length"));
309312
let len = resp
@@ -323,5 +326,7 @@ fn get_imagenet_labels() -> Result<Vec<String>, io::Error> {
323326
}
324327
let file = BufReader::new(fs::File::open(labels_path).unwrap());
325328

326-
file.lines().collect()
329+
file.lines()
330+
.map(|line| line.map_err(|io_err| OrtDownloadError::IoError(io_err)))
331+
.collect()
327332
}

0 commit comments

Comments
 (0)