Skip to content

Commit

Permalink
refactor: wasmtime update
Browse files Browse the repository at this point in the history
update wasmtime to 28.0.1
update wasi-nn context
update other minor crates
forward wasi-nn
  • Loading branch information
ruslanti committed Feb 19, 2025
1 parent d864d6c commit ab374ff
Show file tree
Hide file tree
Showing 21 changed files with 486 additions and 737 deletions.
734 changes: 357 additions & 377 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ tokio = { version = "1", features = ["full"] }
tokio-util = { version = "0.7", features = ["codec"] }
tracing = "0.1"
hyper = { version = "1", features = ["full"] }
http = "1.1.0"
http = "1.2.0"
async-trait = "0.1"
wasmtime = { version = "20.0.2" }
wasmtime-wasi = { version = "20.0.2" }
wasi-common = { version = "20.0.2" }
wasmtime-wasi-nn = { version = "20.0.2" }
wasmtime = { version = "29.0.1", git = "https://github.com/G-Core/wasmtime.git", branch = "wasi_nn_candle_backend"}
wasmtime-wasi = { version = "29.0.1", git = "https://github.com/G-Core/wasmtime.git", branch = "wasi_nn_candle_backend"}
wasi-common = { version = "29.0.1", git = "https://github.com/G-Core/wasmtime.git", branch = "wasi_nn_candle_backend"}
wasmtime-wasi-nn = { version = "29.0.1", features = ["openvino", "candle"], git = "https://github.com/G-Core/wasmtime.git", branch = "wasi_nn_candle_backend"}
wasmtime-wasi-http = { version = "29.0.1", git = "https://github.com/G-Core/wasmtime.git", branch = "wasi_nn_candle_backend"}
wasmtime-environ = { version = "29.0.1", git = "https://github.com/G-Core/wasmtime.git", branch = "wasi_nn_candle_backend"}

clap = { version = "4", features = ["derive"] }
moka = { version = "0.12", features = ["sync"] }
smol_str = { version = "0.2.1", features = ["serde"] }
smol_str = { version = "0.3.2", features = ["serde"] }
anyhow = "1.0"

[workspace.lints.rust]
Expand Down
23 changes: 0 additions & 23 deletions crates/candle-wasi-nn/Cargo.toml

This file was deleted.

201 changes: 0 additions & 201 deletions crates/candle-wasi-nn/src/lib.rs

This file was deleted.

3 changes: 0 additions & 3 deletions crates/dictionary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ description = "dictionary host function"

[dependencies]
reactor = { path = "../reactor" }
anyhow = {workspace = true}
tracing = {workspace = true}
async-trait = {workspace = true}
wasmtime = {workspace = true}

[lints]
workspace = true
4 changes: 2 additions & 2 deletions crates/dictionary/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub struct Dictionary {

#[async_trait]
impl dictionary::Host for Dictionary {
async fn get(&mut self, name: String) -> anyhow::Result<Option<String>> {
Ok(self.inner.get(&name).map(|v| v.to_string()))
async fn get(&mut self, name: String) -> Option<String> {
self.inner.get(&name).map(|v| v.to_string())
}
}

Expand Down
12 changes: 5 additions & 7 deletions crates/http-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ anyhow = {workspace = true}
tracing = {workspace = true}
hyper = { workspace = true }
tokio = { workspace = true }
hyper-util = { version = "0.1.3", features = ["client", "client-legacy", "http1", "tokio"] }
http-body-util = "0.1.1"
pin-project = "1.1.3"
log = "0.4.20"
url = "2.5.0"
tower-service = "0.3.2"
hyper-util = { version = "0.1.10", features = ["client", "client-legacy", "http1", "tokio"] }
http-body-util = "0.1.2"
pin-project = "1.1.8"
tower-service = "0.3.3"
smol_str = {workspace = true}

[dev-dependencies]
claims = "0.7"
claims = "0.8"
tracing-test = "0.2"
mock-http-connector = "0.3"
24 changes: 17 additions & 7 deletions crates/http-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,22 @@ impl<C> Host for Backend<C>
where
C: Connect + Clone + Send + Sync + 'static,
{
async fn send_request(&mut self, req: Request) -> Result<Result<Response, HttpError>> {
async fn send_request(&mut self, req: Request) -> Result<Response, HttpError> {
// check the limit of sub requests
if self.max_sub_requests == 0 {
return Ok(Err(HttpError::TooManyRequests));
return Err(HttpError::TooManyRequests);
} else {
self.max_sub_requests -= 1;
}

let request = self.make_request(req)?;
let res = self.client.request(request).await?;
let request = self
.make_request(req)
.map_err(|_| HttpError::RequestError)?;
let res = self
.client
.request(request)
.await
.map_err(|_| HttpError::RequestError)?;

let status = res.status().as_u16();
let (parts, body) = res.into_parts();
Expand All @@ -304,16 +310,20 @@ where
None
};

let body_bytes = body.collect().await?.to_bytes();
let body_bytes = body
.collect()
.await
.map_err(|_| HttpError::RequestError)?
.to_bytes();
let body = Some(body_bytes.to_vec());

trace!(?status, ?headers, len = body_bytes.len(), "reply");

Ok(Ok(Response {
Ok(Response {
status,
headers,
body,
}))
})
}
}

Expand Down
13 changes: 3 additions & 10 deletions crates/http-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ stats = ["runtime/stats"]
[dependencies]
anyhow = { workspace = true }
tokio = { workspace = true }
tokio-util = { workspace = true }
hyper = { workspace = true }
http = { workspace = true }
wasmtime = { workspace = true }
wasmtime-wasi = { workspace = true }
wasmtime-wasi-nn = { workspace = true }
wasi-common = { workspace = true }
wasmtime-wasi-http = { workspace = true }
tracing = { workspace = true }
smol_str = { workspace = true }
reactor = { path = "../reactor" }
Expand All @@ -29,23 +29,16 @@ dictionary = { path = "../dictionary" }
secret = { path = "../secret" }
nanoid = "0.4"
bytesize = "1.3.0"
futures = "0.3.30"
once_cell = "1.19"
prometheus = { version = "0.13.3", features = ["process"], optional = true }
serde = "1.0"
clickhouse = { version = "0.13", optional = true }
chrono = "0.4"
async-trait = "0.1"
wasmtime-wasi-http = "20.0.2"
hyper-util = { version = "0.1", features = ["server", "server-graceful"] }
http-body-util = "0.1"
bytes = "1.6"
bytes = "1.10"

[target.'cfg(target_family = "unix")'.dependencies]
shellflip = "2.1.1"

[dev-dependencies]
claims = "0.7"
claims = "0.8"
test-case = "3.3"
tracing-test = "0.2"

Loading

0 comments on commit ab374ff

Please sign in to comment.