Skip to content

Commit ff13f33

Browse files
Update dependencies and versions in Cargo files and add Python README
- Updated versions for several dependencies in Cargo.lock and Cargo.toml, including candle packages and aws SDKs, to enhance functionality and compatibility. - Introduced a new README.md for the Python extension, detailing build instructions and usage guidelines. - Added AWS feature support in Rust and Python modules to improve cloud integration capabilities.
1 parent 24522cb commit ff13f33

8 files changed

Lines changed: 381 additions & 206 deletions

File tree

Cargo.lock

Lines changed: 340 additions & 199 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ version = "0.7.0"
2020

2121
[workspace.dependencies]
2222
pdf-extract = "0.9.0"
23-
candle-nn = { version = "0.9.1" }
24-
candle-transformers = { version = "0.9.1" }
25-
candle-core = { version = "0.9.1" }
26-
candle-flash-attn = { version = "0.9.1" }
23+
candle-nn = { version = "0.9.2" }
24+
candle-transformers = { version = "0.9.2" }
25+
candle-core = { version = "0.9.2" }
26+
candle-flash-attn = { version = "0.9.2" }
2727
processors-rs = { path = "processors", version = "=0.7.0" }
2828

2929
strum = "0.27.1"

python/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ strum = {workspace = true}
1717
strum_macros = {workspace = true}
1818

1919
[features]
20+
default = ["extension-module", "ort", "audio", "aws"]
2021
extension-module = ["pyo3/extension-module"]
2122
mkl = ["embed_anything/mkl"]
2223
accelerate = ["embed_anything/accelerate"]
@@ -25,3 +26,4 @@ cudnn = ["embed_anything/cudnn"]
2526
metal = ["embed_anything/metal"]
2627
ort = ["embed_anything/ort"]
2728
audio = ["embed_anything/audio"]
29+
aws = ["embed_anything/aws"]

python/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# embed_anything Python extension
2+
3+
This crate is the Rust/PyO3 extension for the `embed_anything` Python package. It is **not** built with plain `cargo`.
4+
5+
## Building
6+
7+
From the **repository root** (not from this directory), use maturin so the extension links against your Python installation:
8+
9+
```bash
10+
# From repository root
11+
maturin develop # build and install in the current environment (editable)
12+
# or
13+
maturin build # build a wheel
14+
```
15+
16+
Or install the package (maturin is the build backend in `pyproject.toml`):
17+
18+
```bash
19+
pip install -e .
20+
```
21+
22+
Do **not** run `cargo build` in this directory or `cargo build -p embed_anything_python` from the root—the linker will fail with undefined Python symbols because cargo does not link libpython.

python/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pub mod config;
22
pub mod models;
3+
#[cfg(feature = "aws")]
34
pub mod s3_client;
45
use embed_anything::embeddings::embed::{TextEmbedder, VisionEmbedder};
56
use embed_anything::{

rust/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ model2vec-rs = "0.1.4"
7272

7373
# Logging
7474
log = "0.4"
75-
aws-sdk-s3 = {version = "1.110.0", features = ["rt-tokio"]}
76-
aws-config = {version = "1.8.10", features = ["behavior-version-latest"]}
77-
aws-credential-types = "1.2.8"
75+
aws-sdk-s3 = {version = "1.110.0", features = ["rt-tokio"], optional= true}
76+
aws-config = {version = "1.8.10", features = ["behavior-version-latest"], optional = true}
77+
aws-credential-types = {version = "1.2.8", optional = true}
7878

7979
[dev-dependencies]
8080
tempdir = "0.3.7"
@@ -97,6 +97,7 @@ flash-attn = ["cuda", "candle-transformers/flash-attn", "dep:candle-flash-attn"]
9797
metal = ["candle-core/metal", "candle-nn/metal"]
9898
audio = ["dep:symphonia"]
9999
ort = ["dep:ort",]
100+
aws = ["dep:aws-sdk-s3", "dep:aws-config", "dep:aws-credential-types"]
100101
rustls-tls = [
101102
"reqwest/rustls-tls",
102103
"hf-hub/rustls-tls",

rust/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub mod models;
7777
#[cfg(feature = "ort")]
7878
pub mod reranker;
7979
pub mod text_loader;
80+
#[cfg(feature = "aws")]
8081
pub mod s3_loader;
8182

8283
use anyhow::{Error, Result};

rust/src/models/idefics3/model.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ impl CustomOp1 for NonZero {
5555
CpuStorage::F16(vs) => self.nonzero(vs, layout),
5656
CpuStorage::F32(vs) => self.nonzero(vs, layout),
5757
CpuStorage::F64(vs) => self.nonzero(vs, layout),
58+
CpuStorage::I16(vs) => self.nonzero(vs, layout),
59+
CpuStorage::I32(vs) => self.nonzero(vs, layout),
60+
CpuStorage::F8E4M3(vs) => self.nonzero(vs, layout),
61+
CpuStorage::F6E2M3(vs) => self.nonzero(vs, layout),
62+
CpuStorage::F6E3M2(vs) => self.nonzero(vs, layout),
63+
CpuStorage::F4(vs) => self.nonzero(vs, layout),
64+
CpuStorage::F8E8M0(vs) => self.nonzero(vs, layout)
5865
};
5966
let index_len = layout.dims().len();
6067
let result_len = result.len() / index_len;

0 commit comments

Comments
 (0)