Skip to main content

ara2/
lib.rs

1use ara2_sys::araclient;
2
3pub mod dvm_metadata;
4mod endpoint;
5mod error;
6mod model;
7mod session;
8
9pub use dvm_metadata::{
10    CompilationInfo, DatasetInfo, DeploymentInfo, DvmMetadata, InputSpec, ModelInfo, OutputSpec,
11    PpaMetrics, has_metadata, read_labels, read_labels_from_file, read_metadata,
12    read_metadata_from_file,
13};
14pub use endpoint::{DramStatistics, Endpoint, State};
15pub use error::Error;
16pub use model::{
17    DEFAULT_TIMEOUT_MS, InputQuantization, InputTensor, Model, ModelOutputType, ModelTiming,
18    OutputQuantization, OutputTensor,
19};
20pub use session::{Session, SocketType};
21
22/// Default socket path for the ARA-2 proxy service.
23pub const DEFAULT_SOCKET: &str = "/var/run/ara2.sock";
24
25pub(crate) fn open_library() -> Result<araclient, error::Error> {
26    unsafe { Ok(araclient::new("libaraclient.so.1")?) }
27}
28
29#[cfg(test)]
30pub(crate) mod tests {
31    use crate::Session;
32
33    /// Create a test session connected to the local ARA-2 proxy.
34    ///
35    /// Panics if the proxy is not running or the socket is not available.
36    pub fn test_session() -> Session {
37        Session::create_via_unix_socket(crate::DEFAULT_SOCKET)
38            .expect("Failed to connect to ARA-2 proxy. Is ara2-proxy running?")
39    }
40
41    /// Get the test model path from the ARA2_TEST_MODEL environment variable.
42    ///
43    /// Panics if the variable is not set.
44    pub fn test_model_path() -> std::path::PathBuf {
45        std::env::var("ARA2_TEST_MODEL")
46            .expect("ARA2_TEST_MODEL env var must be set to a .dvm file path")
47            .into()
48    }
49}