Skip to content

Commit c0986b0

Browse files
committed
Refactor gRPC Client and Protobuf Namespace
- Updated the gRPC client implementation to use the new Grpc.Protobuf namespace for all client calls. - Changed the namespace from Weaviate.Client.gRPC to Weaviate.Client.Grpc for consistency. - Modified all references to V1 types to use Grpc.Protobuf.V1 in the client code. - Updated proto files to include the csharp_namespace option for proper namespace mapping. - Removed the obsolete file_replication.proto and adjusted the batch.proto for better structure. - Enhanced the BatchStreamRequest and BatchStreamReply messages for improved functionality. - Added a new GenerativeContextualAI message to the generative.proto file. - Updated the proto_sync.sh script to automatically add the csharp_namespace option to new proto files.
1 parent 4ef1ff1 commit c0986b0

33 files changed

+339
-341
lines changed

src/Weaviate.Client.Tests/Unit/TestFilters.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Reflection;
2+
using Weaviate.Client.Grpc.Protobuf.V1;
23
using Weaviate.Client.Models;
3-
using Weaviate.V1;
44

55
namespace Weaviate.Client.Tests.Unit;
66

@@ -201,11 +201,11 @@ public void Filter_ContainsNone()
201201
var uuid2 = Guid.NewGuid();
202202
var f1 = Filter.Property("uuids").ContainsNone(new[] { uuid1, uuid2 });
203203

204-
var expectedF1 = new V1.Filters
204+
var expectedF1 = new Filters
205205
{
206-
Target = new V1.FilterTarget() { Property = "uuids" },
207-
Operator = V1.Filters.Types.Operator.ContainsNone,
208-
ValueTextArray = new V1.TextArray() { Values = { uuid1.ToString(), uuid2.ToString() } },
206+
Target = new FilterTarget() { Property = "uuids" },
207+
Operator = Filters.Types.Operator.ContainsNone,
208+
ValueTextArray = new TextArray() { Values = { uuid1.ToString(), uuid2.ToString() } },
209209
};
210210

211211
// Act
@@ -222,21 +222,21 @@ public void Filter_Not()
222222
var uuid2 = Guid.NewGuid();
223223
var f1 = Filter.Not(Filter.ID.ContainsAny(new[] { uuid1, uuid2 }));
224224

225-
var expectedF1 = new V1.Filters
225+
var expectedF1 = new Filters
226226
{
227227
Filters_ =
228228
{
229-
new V1.Filters
229+
new Filters
230230
{
231-
Target = new V1.FilterTarget() { Property = "_id" },
232-
Operator = V1.Filters.Types.Operator.ContainsAny,
233-
ValueTextArray = new V1.TextArray()
231+
Target = new FilterTarget() { Property = "_id" },
232+
Operator = Filters.Types.Operator.ContainsAny,
233+
ValueTextArray = new TextArray()
234234
{
235235
Values = { uuid1.ToString(), uuid2.ToString() },
236236
},
237237
},
238238
},
239-
Operator = V1.Filters.Types.Operator.Not,
239+
Operator = Filters.Types.Operator.Not,
240240
};
241241

242242
// Act

src/Weaviate.Client.Tests/Unit/TestGrpcCancellation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Weaviate.Client.Grpc;
2+
using Weaviate.Client.Grpc.Protobuf.V1;
23
using Weaviate.Client.Tests.Unit.Mocks;
3-
using Weaviate.V1;
44

55
namespace Weaviate.Client.Tests.Unit;
66

src/Weaviate.Client.Tests/Unit/TestResults.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void SearchReply_Builds_GenerativeGroupByResult_Response()
4141
JsonParser jsonParser = new JsonParser(
4242
JsonParser.Settings.Default.WithIgnoreUnknownFields(true)
4343
);
44-
V1.SearchReply reply = jsonParser.Parse<V1.SearchReply>(json);
44+
Grpc.Protobuf.V1.SearchReply reply = jsonParser.Parse<Grpc.Protobuf.V1.SearchReply>(json);
4545

4646
Assert.NotNull(reply);
4747

src/Weaviate.Client/DataClient.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Collections;
22
using System.Collections.Frozen;
3-
using System.Diagnostics;
43
using Weaviate.Client.Models;
54
using Weaviate.Client.Rest.Dto;
65
using Weaviate.Client.Validation;
@@ -193,7 +192,7 @@ public async Task<BatchInsertResponse> InsertMany(
193192
.Select(
194193
(r, idx) =>
195194
{
196-
var o = new V1.BatchObject
195+
var o = new Grpc.Protobuf.V1.BatchObject
197196
{
198197
Collection = _collectionName,
199198
Uuid = (r.ID ?? Guid.NewGuid()).ToString(),
@@ -205,7 +204,7 @@ public async Task<BatchInsertResponse> InsertMany(
205204
{
206205
foreach (var reference in r.References!)
207206
{
208-
var strp = new Weaviate.V1.BatchObject.Types.SingleTargetRefProps()
207+
var strp = new Grpc.Protobuf.V1.BatchObject.Types.SingleTargetRefProps()
209208
{
210209
PropName = reference.Name,
211210
Uuids = { reference.TargetID.Select(id => id.ToString()) },
@@ -218,15 +217,15 @@ public async Task<BatchInsertResponse> InsertMany(
218217
if (r.Vectors != null)
219218
{
220219
o.Vectors.AddRange(
221-
r.Vectors.Select(v => new V1.Vectors
220+
r.Vectors.Select(v => new Grpc.Protobuf.V1.Vectors
222221
{
223222
Name = v.Key,
224223
VectorBytes = v.Value.ToByteString(),
225224
Type = typeof(System.Collections.IEnumerable).IsAssignableFrom(
226225
v.Value.ValueType
227226
)
228-
? V1.Vectors.Types.VectorType.MultiFp32
229-
: V1.Vectors.Types.VectorType.SingleFp32,
227+
? Grpc.Protobuf.V1.Vectors.Types.VectorType.MultiFp32
228+
: Grpc.Protobuf.V1.Vectors.Types.VectorType.SingleFp32,
230229
})
231230
);
232231
}
@@ -312,7 +311,7 @@ public async Task<BatchReferenceReturn> ReferenceAddMany(
312311
CancellationToken cancellationToken = default
313312
)
314313
{
315-
var stopwatch = Stopwatch.StartNew();
314+
var stopwatch = System.Diagnostics.Stopwatch.StartNew();
316315

317316
var result = await _client.RestClient.ReferenceAddMany(
318317
_collectionName,

src/Weaviate.Client/Errors.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Weaviate.Client.gRPC;
1+
using Weaviate.Client.Grpc;
22
using Weaviate.Client.Rest;
33

44
namespace Weaviate.Client;
@@ -131,5 +131,3 @@ public override string ToString()
131131
return $"{base.ToString()} ResourceType: {ResourceType}.";
132132
}
133133
}
134-
135-
// TODO WeaviateUnauthorizedException, WeaviateUnauthenticatedException, WeaviateBadRequestException

src/Weaviate.Client/Models/Aggregate.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
namespace Weaviate.Client.Models;
22

3+
using V1 = Grpc.Protobuf.V1;
4+
35
public partial record AggregateGroupByResult
46
{
57
public partial record Group
@@ -103,7 +105,7 @@ internal static AggregateResult FromGrpcReply(V1.AggregateReply reply)
103105
}
104106

105107
internal static Aggregate.Property FromGrpcProperty(
106-
Weaviate.V1.AggregateReply.Types.Aggregations.Types.Aggregation x
108+
V1.AggregateReply.Types.Aggregations.Types.Aggregation x
107109
)
108110
{
109111
return x.AggregationCase switch

src/Weaviate.Client/Models/Filter.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Weaviate.V1;
1+
using Weaviate.Client.Grpc.Protobuf.V1;
22

33
namespace Weaviate.Client.Models;
44

@@ -116,7 +116,7 @@ internal TypedValue(PropertyFilter parent)
116116

117117
public partial record Filter
118118
{
119-
internal V1.Filters InternalFilter { get; init; } = new V1.Filters();
119+
internal Filters InternalFilter { get; init; } = new Filters();
120120

121121
protected Filter() { }
122122

@@ -269,7 +269,7 @@ public record PropertyFilter : Filter
269269
{
270270
FilterTarget? _target;
271271

272-
internal PropertyFilter(FilterTarget target, V1.Filters parentFilter)
272+
internal PropertyFilter(FilterTarget target, Filters parentFilter)
273273
{
274274
InternalFilter = parentFilter;
275275
_target = target;
@@ -400,13 +400,12 @@ internal NestedFilter(Filters.Types.Operator op, params Filter[] filters) =>
400400
}
401401

402402
public record AndNestedFilter(params Filter[] filters)
403-
: NestedFilter(V1.Filters.Types.Operator.And, filters) { }
403+
: NestedFilter(Filters.Types.Operator.And, filters) { }
404404

405405
public record OrNestedFilter(params Filter[] filters)
406-
: NestedFilter(V1.Filters.Types.Operator.Or, filters) { }
406+
: NestedFilter(Filters.Types.Operator.Or, filters) { }
407407

408-
public record NotNestedFilter(Filter filter)
409-
: NestedFilter(V1.Filters.Types.Operator.Not, filter) { }
408+
public record NotNestedFilter(Filter filter) : NestedFilter(Filters.Types.Operator.Not, filter) { }
410409

411410
public record TimeFilter : TypedValue<DateTime>
412411
{

src/Weaviate.Client/Models/Sort.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
namespace Weaviate.Client.Models;
22

3+
using V1 = Grpc.Protobuf.V1;
4+
35
public record Sort
46
{
57
private Sort() { }

src/Weaviate.Client/Models/TargetVectors.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
namespace Weaviate.Client.Models;
22

3+
using V1 = Grpc.Protobuf.V1;
4+
35
public class TargetVectors : IEnumerable<string>
46
{
57
public List<string> Targets { get; } = new List<string>();
@@ -68,7 +70,6 @@ public static TargetVectors ManualWeights(
6870
)
6971
{
7072
var dict = weights.ToDictionary(w => w.name, w => w.weight.ToList());
71-
7273
return new TargetVectors(dict.Keys, V1.CombinationMethod.TypeManual, dict);
7374
}
7475

@@ -78,7 +79,6 @@ public static TargetVectors RelativeScore(
7879
)
7980
{
8081
var dict = weights.ToDictionary(w => w.name, w => w.weight.ToList());
81-
8282
return new TargetVectors(dict.Keys, V1.CombinationMethod.TypeRelativeScore, dict);
8383
}
8484
}

src/Weaviate.Client/Models/Tenant.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
namespace Weaviate.Client.Models;
22

3+
using V1 = Grpc.Protobuf.V1;
4+
35
public enum TenantActivityStatus
46
{
57
[System.Runtime.Serialization.EnumMember(Value = "unspecified")]

0 commit comments

Comments
 (0)