diff --git a/Cargo.lock b/Cargo.lock index 522cdb5..bf30c60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -242,7 +242,7 @@ dependencies = [ [[package]] name = "openvino" -version = "0.3.0" +version = "0.3.1" dependencies = [ "float-cmp", "openvino-sys", @@ -251,11 +251,11 @@ dependencies = [ [[package]] name = "openvino-finder" -version = "0.3.0" +version = "0.3.1" [[package]] name = "openvino-sys" -version = "0.3.0" +version = "0.3.1" dependencies = [ "cmake", "lazy_static", diff --git a/crates/openvino-finder/Cargo.toml b/crates/openvino-finder/Cargo.toml index 6b04270..ec3e114 100644 --- a/crates/openvino-finder/Cargo.toml +++ b/crates/openvino-finder/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "openvino-finder" -version = "0.3.0" +version = "0.3.1" description = "A helper crate for finding OpenVINO installations on a system." license = "Apache-2.0" readme = "README.md" diff --git a/crates/openvino-sys/Cargo.toml b/crates/openvino-sys/Cargo.toml index 41b01f9..379d115 100644 --- a/crates/openvino-sys/Cargo.toml +++ b/crates/openvino-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "openvino-sys" -version = "0.3.0" +version = "0.3.1" license = "Apache-2.0" description = "Low-level bindings for OpenVINO (use the `openvino` crate for easier-to-use bindings)." readme = "README.md" @@ -24,11 +24,11 @@ links = "inference_engine_c_api" [dependencies] lazy_static = {version = "1.4", optional = true } libloading = {version = "0.7", optional = true } -openvino-finder = {version = "0.3.0", path = "../openvino-finder" } +openvino-finder = {version = "0.3.1", path = "../openvino-finder" } [build-dependencies] cmake = "0.1.45" -openvino-finder = {version = "0.3.0", path = "../openvino-finder" } +openvino-finder = {version = "0.3.1", path = "../openvino-finder" } [features] default = ["cpu"] diff --git a/crates/openvino-sys/README.md b/crates/openvino-sys/README.md index 74e5a58..f934d9c 100644 --- a/crates/openvino-sys/README.md +++ b/crates/openvino-sys/README.md @@ -10,5 +10,5 @@ information, including build instructions. [C API]: https://docs.openvinotoolkit.org/2020.1/ie_c_api/groups.html [openvino-sys]: https://crates.io/crates/openvino-sys [openvino]: https://crates.io/crates/openvino -[README]: https://github.com/abrown/openvino/blob/rust-bridge/inference-engine/ie_bridges/rust/README.md +[README]: https://github.com/intel/openvino-rs [upstream]: upstream diff --git a/crates/openvino-sys/src/lib.rs b/crates/openvino-sys/src/lib.rs index cecf683..58f2e2c 100644 --- a/crates/openvino-sys/src/lib.rs +++ b/crates/openvino-sys/src/lib.rs @@ -1,3 +1,20 @@ +//! This crate provides low-level, unsafe, Rust bindings to OpenVINO™ using its [C API]. If you are +//! looking to use OpenVINO™ from Rust, you likely should look at the ergonomic, safe bindings in +//! [openvino], which depends on this crate. See the repository [README] for more information, +//! including build instructions. +//! +//! [C API]: https://docs.openvinotoolkit.org/2020.1/ie_c_api/groups.html +//! [openvino-sys]: https://crates.io/crates/openvino-sys +//! [openvino]: https://crates.io/crates/openvino +//! [README]: https://github.com/intel/openvino-rs/tree/main/crates/openvino-sys +//! +//! An example interaction with raw [openvino-sys]: +//! ``` +//! # use std::ffi::CStr; +//! openvino_sys::library::load().expect("to have an OpenVINO library available"); +//! let version = unsafe { CStr::from_ptr(openvino_sys::ie_c_api_version().api_version) }; +//! assert!(version.to_string_lossy().starts_with("2.1")); +//! ``` #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] @@ -38,16 +55,3 @@ pub mod library { } } } - -#[cfg(test)] -mod tests { - use super::*; - use std::ffi::CStr; - - #[test] - fn check_version() { - load().expect("to have an OpenVINO library available"); - let version = unsafe { CStr::from_ptr(ie_c_api_version().api_version) }; - assert!(version.to_string_lossy().starts_with("2.1")); - } -} diff --git a/crates/openvino/Cargo.toml b/crates/openvino/Cargo.toml index ba9f644..e4c231a 100644 --- a/crates/openvino/Cargo.toml +++ b/crates/openvino/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "openvino" -version = "0.3.0" +version = "0.3.1" license = "Apache-2.0" description = "High-level bindings for OpenVINO." readme = "README.md" @@ -13,7 +13,7 @@ exclude = [ ] [dependencies] -openvino-sys = { path = "../openvino-sys", version = "0.3.0" } +openvino-sys = { path = "../openvino-sys", version = "0.3.1" } thiserror = "1.0.20" [dev-dependencies] @@ -21,3 +21,6 @@ float-cmp = "0.8" [features] runtime-linking = ["openvino-sys/runtime-linking"] + +[package.metadata.docs.rs] +features = ["runtime-linking"] diff --git a/crates/openvino/README.md b/crates/openvino/README.md index b7fa71f..36db207 100644 --- a/crates/openvino/README.md +++ b/crates/openvino/README.md @@ -7,4 +7,4 @@ repository [README] for more information, such as build instructions. > This crate is currently experimental--its API surface is subject to change. [openvino]: https://crates.io/crates/openvino -[README]: https://github.com/abrown/openvino/blob/rust-bridge/inference-engine/ie_bridges/rust/README.md +[README]: https://github.com/intel/openvino-rs diff --git a/crates/openvino/src/core.rs b/crates/openvino/src/core.rs index 53dbe51..5ea79af 100644 --- a/crates/openvino/src/core.rs +++ b/crates/openvino/src/core.rs @@ -105,13 +105,3 @@ impl Core { Ok(ExecutableNetwork { instance }) } } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn construct_core() { - let _ = Core::new(None).unwrap(); - } -} diff --git a/crates/openvino/src/error.rs b/crates/openvino/src/error.rs index e626cf5..65908f6 100644 --- a/crates/openvino/src/error.rs +++ b/crates/openvino/src/error.rs @@ -55,8 +55,8 @@ impl InferenceError { } } -/// Enumberate setup failures: in some cases, this library calls library loading code that may fail -/// in a different way (i.e., [LoadingError]) than the calls in to the OpenVINO libraries (i.e., +/// Enumerate setup failures: in some cases, this library will call library-loading code that may +/// fail in a different way (i.e., [LoadingError]) than the calls to the OpenVINO libraries (i.e., /// [InferenceError]). #[derive(Debug, Error)] pub enum SetupError { diff --git a/crates/openvino/src/lib.rs b/crates/openvino/src/lib.rs index 9f5949e..38f9675 100644 --- a/crates/openvino/src/lib.rs +++ b/crates/openvino/src/lib.rs @@ -1,3 +1,19 @@ +//! The [openvino] crate provides high-level, ergonomic, safe Rust bindings to OpenVINO. See the +//! repository [README] for more information, such as build instructions. +//! +//! [openvino]: https://crates.io/crates/openvino +//! [README]: https://github.com/intel/openvino-rs +//! +//! Check the loaded version of OpenVINO: +//! ``` +//! assert!(openvino::version().starts_with("2.1")) +//! ``` +//! +//! Most interaction with OpenVINO begins with instantiating a [Core]: +//! ``` +//! let _ = openvino::Core::new(None).expect("to instantiate the OpenVINO library"); +//! ``` + mod blob; mod core; mod error; @@ -29,13 +45,3 @@ pub fn version() -> String { unsafe { openvino_sys::ie_version_free(&mut ie_version as *mut openvino_sys::ie_version_t) }; str_version } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn check_version() { - assert!(version().starts_with("2.1"),) - } -} diff --git a/crates/xtask/src/bump.rs b/crates/xtask/src/bump.rs index 95b45ca..fbcb625 100644 --- a/crates/xtask/src/bump.rs +++ b/crates/xtask/src/bump.rs @@ -58,7 +58,7 @@ impl BumpCommand { } // Add a Git commit. - let commit_message = format!("'Release v{}'", next_version_str); + let commit_message = format!("Release v{}", next_version_str); if self.git { println!("> add Git commit: {}", &commit_message); if !self.dry_run && self.git { diff --git a/crates/xtask/src/publish.rs b/crates/xtask/src/publish.rs index aebd5cc..05f1b84 100644 --- a/crates/xtask/src/publish.rs +++ b/crates/xtask/src/publish.rs @@ -1,5 +1,5 @@ -use crate::util::{get_crates, path_to_crates, Crate}; -use anyhow::{anyhow, Context, Result}; +use crate::util::{exec, get_crates, path_to_crates, Crate}; +use anyhow::{anyhow, Result}; use std::{process::Command, thread::sleep, time::Duration}; use structopt::StructOpt; @@ -7,7 +7,7 @@ use structopt::StructOpt; #[structopt(name = "bump")] pub struct PublishCommand { /// Tag the current commit and push the tags to the default upstream; equivalent to `git tag - /// v[version]` and `git push v[version]`. + /// v[version] && git push origin v[version]`. #[structopt(long)] git: bool, /// Do not publish any crates; instead, simply print the actions that would have been taken. @@ -43,13 +43,19 @@ impl PublishCommand { for krate in PUBLICATION_ORDER { println!("> publish {}", krate); if !self.dry_run { - assert!(Command::new("cargo") - .arg("publish") - .current_dir(crates_dir.clone().join(krate)) - .arg("--no-verify") - .status() - .with_context(|| format!("failed to run cargo publish on '{}' crate", krate))? - .success()); + let crate_dir = crates_dir.clone().join(krate); + let exec_result = exec( + Command::new("cargo") + .arg("publish") + .arg("--no-verify") + .current_dir(&crate_dir), + ); + + // We want to continue even if a crate does not publish: this allows us to re-run + // the `publish` command if uploading one or more crates fails. + if let Err(e) = exec_result { + println!("Failed to publish crate {}, continuing:\n {}", krate, e); + } // Hopefully this gives crates.io enough time for subsequent publications to work. sleep(Duration::from_secs(20)); @@ -61,18 +67,8 @@ impl PublishCommand { if self.git { println!("> push Git tag: {}", tag); if !self.dry_run { - assert!(Command::new("git") - .arg("tag") - .arg(&tag) - .status() - .with_context(|| format!("failed to run `git tag {}` command", &tag))? - .success()); - assert!(Command::new("git") - .arg("push") - .arg(&tag) - .status() - .with_context(|| format!("failed to run `git push {}` command", &tag))? - .success()); + exec(Command::new("git").arg("tag").arg(&tag))?; + exec(Command::new("git").arg("push").arg("origin").arg(&tag))?; } } diff --git a/crates/xtask/src/util.rs b/crates/xtask/src/util.rs index 872454f..5aaf980 100644 --- a/crates/xtask/src/util.rs +++ b/crates/xtask/src/util.rs @@ -1,9 +1,19 @@ -use anyhow::{Context, Result}; +use anyhow::{anyhow, Context, Result}; use semver::Version; -use std::fs; use std::path::PathBuf; +use std::{fs, process::Command}; use toml::Value; +/// Convenience wrapper for executing commands. +pub fn exec(command: &mut Command) -> Result<()> { + let status = command.status()?; + if status.success() { + Ok(()) + } else { + Err(anyhow!("failed to execute: {:?}", &command)) + } +} + /// Determine the path to the `crates` directory`. pub fn path_to_crates() -> Result { Ok(PathBuf::from(file!())