Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[env]

RUST_LOG = "info,tower_http=debug,ort=warn,encoderfile=debug"

[patch.crates-io]
esaxx-rs = { git = "https://github.com/mozilla-ai/esaxx-rs-dyn-msvc.git" }
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion encoderfile-py/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["cdylib"]

[dependencies.pyo3]
version = "0.27.0"
features = ["abi3"]
features = ["abi3", "extension-module"]

[dependencies.encoderfile]
path = "../encoderfile"
Expand Down
11 changes: 7 additions & 4 deletions encoderfile/src/builder/base_binary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ impl BaseBinaryResolver<'_> {

fn validate_binary(&self, path: &Path) -> Result<()> {
terminal::info("Validating binary...");
use std::os::unix::fs::PermissionsExt;

let meta = fs::metadata(path)
.with_context(|| format!("base binary missing at {}", path.display()))?;
Expand All @@ -114,9 +113,13 @@ impl BaseBinaryResolver<'_> {
anyhow::bail!("base binary is not a file: {}", path.display());
}

let mode = meta.permissions().mode();
if mode & 0o111 == 0 {
anyhow::bail!("base binary is not executable: {}", path.display());
#[cfg(not(target_os = "windows"))]
{
use std::os::unix::fs::PermissionsExt;
let mode = meta.permissions().mode();
if mode & 0o111 == 0 {
anyhow::bail!("base binary is not executable: {}", path.display());
}
}

terminal::success("Binary validated");
Expand Down
16 changes: 15 additions & 1 deletion encoderfile/tests/integration/test_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ tonic::include_proto!("encoderfile.metadata");

use encoderfile::generated::token_classification;

#[cfg(target_os = "windows")]
const BINARY_NAME: &str = "test.encoderfile.exe";

#[cfg(not(target_os = "windows"))]
const BINARY_NAME: &str = "test.encoderfile";

fn config(model_name: &String, model_path: &Path, output_path: &Path) -> String {
Expand Down Expand Up @@ -104,6 +108,11 @@ async fn test_build_encoderfile() -> Result<()> {
.status()
.expect("Failed to build encoderfile-runtime");

#[cfg(target_os = "windows")]
let base_binary_path = fs::canonicalize("../target/debug/encoderfile-runtime.exe")
.expect("Failed to canonicalize base binary path");

#[cfg(not(target_os = "windows"))]
let base_binary_path = fs::canonicalize("../target/debug/encoderfile-runtime")
.expect("Failed to canonicalize base binary path");

Expand Down Expand Up @@ -159,13 +168,18 @@ async fn test_build_encoderfile() -> Result<()> {
grpc_port,
)?;

println!("encoderfile spawned, waiting for it to become ready...");

wait_for_http(
format!("http://localhost:{http_port}/health").as_str(),
Duration::from_secs(10),
)
.await?;
println!("encoderfile is ready, sending inference requests...");
send_http_inference(&sample_text, http_port.to_string()).await?;
println!("http inference request successful");
send_grpc_inference(&sample_text, grpc_port.to_string()).await?;
println!("grpc inference request successful");

child.kill()?;
child.wait().ok();
Expand Down Expand Up @@ -212,7 +226,7 @@ async fn send_http_inference(sample_text: &str, http_port: String) -> Result<()>
}

async fn send_grpc_inference(sample_text: &str, grpc_port: String) -> Result<()> {
let mut client = token_classification::token_classification_inference_client::TokenClassificationInferenceClient::connect(format!("http://[::]:{grpc_port}/predict")).await?;
let mut client = token_classification::token_classification_inference_client::TokenClassificationInferenceClient::connect(format!("http://[::1]:{grpc_port}/predict")).await?;
let req = token_classification::TokenClassificationRequest {
inputs: vec![sample_text.to_owned()],
metadata: std::collections::HashMap::new(),
Expand Down
1 change: 1 addition & 0 deletions test_config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
encoderfile:
name: my-model-2
path: models/token_classification
base_binary_path: target/debug/encoderfile-runtime.exe
model_type: token_classification
output_path: ./test-model.encoderfile
transform: |
Expand Down
Loading