Skip to content

Commit 8045850

Browse files
committed
Migrated python client to gRPC
1 parent 5b24bb8 commit 8045850

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2744
-6730
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ create_store(
3434
query_model="all-minilm-l6-v2",
3535
)
3636
```
37-
- [`ahnlich-client-rs`](ahnlich/client/): Rust client for `ahnlich-db` and `ahnlich-ai` with support for connection pooling.
38-
- [`ahnlich-client-py`](sdk/ahnlich-client-py/): Python client for `ahnlich-db` and `ahnlich-ai` with support for connection pooling.
37+
- [`ahnlich-client-rs`](ahnlich/client/): Rust client for `ahnlich-db` and `ahnlich-ai`.
38+
- [`ahnlich-client-py`](sdk/ahnlich-client-py/): Python client for `ahnlich-db` and `ahnlich-ai`.
3939

4040
- [`ahnlich-cli`](ahnlich/cli/): CLI for querying `ahnlich-db` and `ahnlich-ai`
4141

TODO.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@
33
- [x] Fixing FIXMEs in DB test
44
- [ ] Fixing AI tests to use new grpc methods
55
- [x] Fixing ahnlich client tests to use new grpc methods
6-
- [ ] Fixing ahnlich client README documentation that still references creating connection pools and TCP stuff
6+
- [x] Fixing ahnlich client README documentation that still references creating connection pools and TCP stuff
77
- [X] Fixing DSL to use grpc methods
88
- [x] Renaming grpc_types to ahnlich_types
9-
- [ ] Fixing CLI to use grpc methods
9+
- [x] Fixing CLI to use grpc methods
1010
- [ ] Starting Python rewrite to use new grpc methods
1111

1212

13-
14-
### REWRITE NOTES:
15-
- Client DB tests are flaky:
16-
```rust
17-
thread 'grpc::db::test::test_simple_pipeline' panicked at /Users/davidonuh/Sandbox/rust/ahnlich/ahnlich/utils/src/server.rs:68:33:
18-
Could not set up ahnlich-db with allocator_size
19-
20-
thread 'grpc::db::test::test_simple_pipeline' panicked at client/src/grpc/db.rs:584:14:
21-
Could not initialize client: Tonic(tonic::transport::Error(Transport, ConnectError(ConnectError("tcp connect error", Os { code: 61, kind: ConnectionRefused, message: "Connection refused" }))))
22-
```
13+
## Python Rewrite
14+
- [ ] Create a blocking client that wraps around betterproto async client
15+
- [ ] Create CI step that checks that `grpc-update-client` does not produce any diffs so that our clients are always up to date.
16+
- [X] Update tests.
17+
- [ ] Fix Demo embed and demo tracing.
18+
- [ ] Migrate README to reflect grpc client.

ahnlich/client/src/ai.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ mod test {
413413
}
414414

415415
#[tokio::test]
416-
async fn test_pool_commands_fail_if_server_not_exist() {
416+
async fn test_ai_client_init_fail_if_server_not_exist() {
417417
let host = "127.0.0.1";
418418
let port = 1234;
419419
let ai_client = AiClient::new(format!("{host}:{port}")).await;

ahnlich/client/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ mod test {
612612
}
613613

614614
#[tokio::test]
615-
async fn test_pool_commands_fail_if_server_not_exist() {
615+
async fn test_db_client_init_fail_if_server_not_exist() {
616616
let host = "127.0.0.1";
617617
let port = 1234;
618618
let address = format!("{host}:{port}");

ahnlich/types/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{
44
path::PathBuf,
55
};
66
use walkdir::WalkDir;
7-
// TODO: this would serve as a stand in replacement for the types crate
7+
88
fn main() -> Result<()> {
99
// Get the current package directory
1010
let manifest_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));

ahnlich/types/src/ai/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
pub mod query;
12
pub mod execution_provider;
23
pub mod models;
3-
pub mod pipeline;
44
pub mod preprocess;
5-
pub mod query;
65
pub mod server;
6+
pub mod pipeline;

ahnlich/types/src/ai/models.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
// This file is @generated by prost-build.
2-
#[derive(
3-
serde::Serialize,
4-
serde::Deserialize,
5-
Clone,
6-
Copy,
7-
Debug,
8-
PartialEq,
9-
Eq,
10-
Hash,
11-
PartialOrd,
12-
Ord,
13-
::prost::Enumeration,
14-
)]
2+
#[derive(serde::Serialize, serde::Deserialize)]
3+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
154
#[repr(i32)]
165
pub enum AiModel {
176
AllMiniLmL6V2 = 0,

ahnlich/types/src/ai/pipeline.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ pub mod ai_query {
2020
#[prost(message, tag = "4")]
2121
CreatePredIndex(super::super::query::CreatePredIndex),
2222
#[prost(message, tag = "5")]
23-
CreateNonLinearAlgorithmIndex(super::super::query::CreateNonLinearAlgorithmIndex),
23+
CreateNonLinearAlgorithmIndex(
24+
super::super::query::CreateNonLinearAlgorithmIndex,
25+
),
2426
#[prost(message, tag = "6")]
2527
DropPredIndex(super::super::query::DropPredIndex),
2628
#[prost(message, tag = "7")]

ahnlich/types/src/ai/query.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ pub struct GetSimN {
6363
#[prost(uint64, tag = "4")]
6464
pub closest_n: u64,
6565
/// Algorithm to use for similarity search
66-
#[prost(
67-
enumeration = "super::super::algorithm::algorithms::Algorithm",
68-
tag = "5"
69-
)]
66+
#[prost(enumeration = "super::super::algorithm::algorithms::Algorithm", tag = "5")]
7067
pub algorithm: i32,
7168
/// Preprocessing actions to apply to input before querying
7269
#[prost(enumeration = "super::preprocess::PreprocessAction", tag = "6")]

ahnlich/types/src/ai/server.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ pub struct CreateIndex {
5959
#[prost(uint64, tag = "1")]
6060
pub created_indexes: u64,
6161
}
62-
#[derive(Eq, PartialOrd, Ord, Hash, Clone, PartialEq, ::prost::Message)]
62+
#[derive(Eq, PartialOrd, Ord, Hash)]
63+
#[derive(Clone, PartialEq, ::prost::Message)]
6364
pub struct AiStoreInfo {
6465
#[prost(string, tag = "1")]
6566
pub name: ::prost::alloc::string::String,

ahnlich/types/src/algorithm/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pub mod algorithms;
21
pub mod nonlinear;
2+
pub mod algorithms;

ahnlich/types/src/algorithm/nonlinear.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
// This file is @generated by prost-build.
2-
#[derive(
3-
serde::Serialize,
4-
serde::Deserialize,
5-
Clone,
6-
Copy,
7-
Debug,
8-
PartialEq,
9-
Eq,
10-
Hash,
11-
PartialOrd,
12-
Ord,
13-
::prost::Enumeration,
14-
)]
2+
#[derive(serde::Serialize, serde::Deserialize)]
3+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
154
#[repr(i32)]
165
pub enum NonLinearAlgorithm {
176
KdTree = 0,

ahnlich/types/src/client.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// This file is @generated by prost-build.
2-
#[derive(PartialOrd, Ord, Eq, Clone, PartialEq, ::prost::Message)]
2+
#[derive(PartialOrd, Ord, Eq)]
3+
#[derive(Clone, PartialEq, ::prost::Message)]
34
pub struct ConnectedClient {
45
#[prost(string, tag = "1")]
56
pub address: ::prost::alloc::string::String,

ahnlich/types/src/db/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1+
pub mod server;
12
pub mod pipeline;
23
pub mod query;
3-
pub mod server;

ahnlich/types/src/db/pipeline.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ pub mod db_query {
2222
#[prost(message, tag = "5")]
2323
CreatePredIndex(super::super::query::CreatePredIndex),
2424
#[prost(message, tag = "6")]
25-
CreateNonLinearAlgorithmIndex(super::super::query::CreateNonLinearAlgorithmIndex),
25+
CreateNonLinearAlgorithmIndex(
26+
super::super::query::CreateNonLinearAlgorithmIndex,
27+
),
2628
#[prost(message, tag = "7")]
2729
DropPredIndex(super::super::query::DropPredIndex),
2830
#[prost(message, tag = "8")]

ahnlich/types/src/db/query.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ pub struct GetSimN {
5858
#[prost(uint64, tag = "3")]
5959
pub closest_n: u64,
6060
/// The algorithm to use for similarity computation.
61-
#[prost(
62-
enumeration = "super::super::algorithm::algorithms::Algorithm",
63-
tag = "4"
64-
)]
61+
#[prost(enumeration = "super::super::algorithm::algorithms::Algorithm", tag = "4")]
6562
pub algorithm: i32,
6663
/// The predicate condition to apply.
6764
#[prost(message, optional, tag = "5")]

ahnlich/types/src/db/server.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ pub struct CreateIndex {
5454
}
5555
#[derive(Clone, PartialEq, ::prost::Message)]
5656
pub struct ServerResponse {
57-
#[prost(
58-
oneof = "server_response::Response",
59-
tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10"
60-
)]
57+
#[prost(oneof = "server_response::Response", tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10")]
6158
pub response: ::core::option::Option<server_response::Response>,
6259
}
6360
/// Nested message and enum types in `ServerResponse`.
@@ -86,7 +83,8 @@ pub mod server_response {
8683
CreateIndex(super::CreateIndex),
8784
}
8885
}
89-
#[derive(Hash, Eq, Ord, PartialOrd, Clone, PartialEq, ::prost::Message)]
86+
#[derive(Hash, Eq, Ord, PartialOrd)]
87+
#[derive(Clone, PartialEq, ::prost::Message)]
9088
pub struct StoreInfo {
9189
#[prost(string, tag = "1")]
9290
pub name: ::prost::alloc::string::String,

ahnlich/types/src/keyval.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ pub struct StoreEntry {
3434
#[prost(message, optional, tag = "2")]
3535
pub value: ::core::option::Option<StoreValue>,
3636
}
37-
#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)]
37+
#[derive(serde::Serialize, serde::Deserialize)]
38+
#[derive(Clone, PartialEq, ::prost::Message)]
3839
pub struct StoreValue {
3940
#[prost(map = "string, message", tag = "1")]
40-
pub value:
41-
::std::collections::HashMap<::prost::alloc::string::String, super::metadata::MetadataValue>,
41+
pub value: ::std::collections::HashMap<
42+
::prost::alloc::string::String,
43+
super::metadata::MetadataValue,
44+
>,
4245
}

ahnlich/types/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
pub mod ai;
2-
pub mod algorithm;
3-
pub mod client;
4-
pub mod db;
5-
pub mod keyval;
1+
pub mod shared;
2+
pub mod utils;
63
pub mod metadata;
74
pub mod predicates;
5+
pub mod client;
6+
pub mod keyval;
87
pub mod server_types;
98
pub mod services;
10-
pub mod shared;
11-
pub mod similarity;
12-
pub mod utils;
9+
pub mod algorithm;
1310
pub mod version;
11+
pub mod db;
12+
pub mod ai;
13+
pub mod similarity;

ahnlich/types/src/metadata.rs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,14 @@
11
// This file is @generated by prost-build.
2-
#[derive(
3-
serde::Serialize,
4-
serde::Deserialize,
5-
PartialOrd,
6-
Ord,
7-
Hash,
8-
Eq,
9-
Clone,
10-
PartialEq,
11-
::prost::Message,
12-
)]
2+
#[derive(serde::Serialize, serde::Deserialize, PartialOrd, Ord, Hash, Eq)]
3+
#[derive(Clone, PartialEq, ::prost::Message)]
134
pub struct MetadataValue {
145
#[prost(oneof = "metadata_value::Value", tags = "2, 3")]
156
pub value: ::core::option::Option<metadata_value::Value>,
167
}
178
/// Nested message and enum types in `MetadataValue`.
189
pub mod metadata_value {
19-
#[derive(
20-
serde::Serialize,
21-
serde::Deserialize,
22-
PartialOrd,
23-
Ord,
24-
Hash,
25-
Eq,
26-
Clone,
27-
PartialEq,
28-
::prost::Oneof,
29-
)]
10+
#[derive(serde::Serialize, serde::Deserialize, PartialOrd, Ord, Hash, Eq)]
11+
#[derive(Clone, PartialEq, ::prost::Oneof)]
3012
pub enum Value {
3113
#[prost(string, tag = "2")]
3214
RawString(::prost::alloc::string::String),

0 commit comments

Comments
 (0)