Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from Milvus 2.3.0 to 2.3.10 #61

Merged
merged 1 commit into from
Feb 29, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
matrix:
# TODO: Test against latest previews too. This currently doesn't work because preview releases don't publish
# a milvus-standalone-docker-compose.yml
milvus_version: [v2.3.0]
milvus_version: [v2.3.10]

steps:
- name: Checkout
Expand Down
5 changes: 3 additions & 2 deletions Milvus.Client.Tests/CollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,9 @@ public async Task Create_in_non_existing_database_fails()
"foo",
new[] { FieldSchema.Create<long>("id", isPrimaryKey: true) }));

Assert.Equal(MilvusErrorCode.UnexpectedError, exception.ErrorCode);
Assert.Equal("ErrorCode: UnexpectedError Reason: database:non_existing_db not found", exception.Message);
// Expected: UnexpectedError, Actual: 65535
// Assert.Equal(MilvusErrorCode.UnexpectedError, exception.ErrorCode);
Assert.Equal("ErrorCode: 65535 Reason: database:non_existing_db not found", exception.Message);
}

public CollectionTests(MilvusFixture milvusFixture)
Expand Down
19 changes: 4 additions & 15 deletions Milvus.Client.Tests/DataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,15 @@ public async Task Insert_Drop()
Assert.Equal(2, Assert.Single(result.Data));

mutationResult = await Collection.DeleteAsync("id in [2]");
Assert.Collection(mutationResult.Ids.LongIds!, i => Assert.Equal(2, i));
// Starting with Milvus 2.3.2, Delete no longer seems to return the deleted IDs
// Assert.Collection(mutationResult.Ids.LongIds!, i => Assert.Equal(2, i));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yhmo this specifically looks suspect; deleteCnt is correct on the MutationResult returned by the delete operation; but IDs is empty (though it used to be populated).

Assert.Equal(1, mutationResult.DeleteCount);
Assert.Equal(0, mutationResult.InsertCount);
Assert.Equal(0, mutationResult.UpsertCount);
ulong timestamp = mutationResult.Timestamp;

results = await Collection.QueryAsync(
"id in [2]",
new()
{
ConsistencyLevel = ConsistencyLevel.Customized,
GuaranteeTimestamp = timestamp
});
new() { ConsistencyLevel = ConsistencyLevel.Strong });
result = Assert.IsType<FieldData<long>>(Assert.Single(results));
Assert.Empty(result.Data);
}
Expand Down Expand Up @@ -110,13 +106,6 @@ public async Task Collection_waitForFlush()
[Fact]
public async Task FlushAllAsync_and_wait()
{
// Waiting for FlushAllAsync can take around a minute.
// To make the developer inner loop quicker, we run this test only on CI.
if (Environment.GetEnvironmentVariable("CI") == null)
{
return;
}

await InsertDataAsync(9, 10);

// Flush all
Expand All @@ -130,7 +119,7 @@ public async Task FlushAllAsync_and_wait()
await Client.WaitForFlushAllAsync(timestamp);

IEnumerable<PersistentSegmentInfo> segmentInfos = await Collection.GetPersistentSegmentInfosAsync();
Assert.True(segmentInfos.All(p => p.State == SegmentState.Flushed));
Assert.True(segmentInfos.All(p => p.State is SegmentState.Flushed or SegmentState.Sealed));
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion Milvus.Client.Tests/IndexTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ await Collection.CreateIndexAsync(

MilvusException exception = await Assert.ThrowsAsync<MilvusException>(
() => Collection.DescribeIndexAsync("float_vector"));
Assert.Equal(MilvusErrorCode.IndexNotExist, exception.ErrorCode);
Assert.Equal(MilvusErrorCode.IndexNotFound, exception.ErrorCode);
}

public async Task InitializeAsync()
Expand Down
2 changes: 1 addition & 1 deletion Milvus.Client.Tests/TestContainer/MilvusBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Milvus.Client.Tests.TestContainer;

public class MilvusBuilder : ContainerBuilder<MilvusBuilder, MilvusContainer, MilvusConfiguration>
{
public const string MilvusImage = "milvusdb/milvus:v2.3.0"; // TODO: Configurable
public const string MilvusImage = "milvusdb/milvus:v2.3.10"; // TODO: Configurable
public const ushort MilvusGrpcPort = 19530;
public const ushort MilvusManagementPort = 9091;

Expand Down
1 change: 1 addition & 0 deletions Milvus.Client.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Jaccard/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Milvus/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=pymilvus/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=quantizes/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=quantizing/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tanimoto/@EntryIndexedValue">True</s:Boolean>
Expand Down
1 change: 1 addition & 0 deletions Milvus.Client/Milvus.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<Protobuf Include="Protos\proto\common.proto" GrpcServices="Client" Access="internal" />
<Protobuf Include="Protos\proto\schema.proto" GrpcServices="Client" ProtoRoot="Protos\proto" Access="internal" />
<Protobuf Include="Protos\proto\milvus.proto" GrpcServices="Client" ProtoRoot="Protos\proto" Access="internal" />
<Protobuf Include="Protos\proto\msg.proto" GrpcServices="Client" ProtoRoot="Protos\proto" Access="internal" />
<Protobuf Include="Protos\proto\feder.proto" GrpcServices="Client" ProtoRoot="Protos\proto" Access="internal" />
</ItemGroup>

Expand Down
5 changes: 5 additions & 0 deletions Milvus.Client/MilvusClient.Collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ public async Task<MilvusCollection> CreateCollectionAsync(
grpcCollectionSchema.Fields.Add(grpcField);
}

#pragma warning disable CS0612 // Schema-level AutoID is obsolete, but still there in pymilvus
grpcCollectionSchema.AutoID = schema.Fields.Any(static p => p.AutoId);
#pragma warning restore CS0612 // Type or member is obsolete

var request = new CreateCollectionRequest
{
Expand Down Expand Up @@ -169,6 +171,8 @@ await InvokeAsync(GrpcClient.HasCollectionAsync, request, static r => r.Status,
/// <param name="cancellationToken">
/// The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None" />.
/// </param>
// ShowType and CollectionNames are obsolete, but seem required and is still used in pymilvus
#pragma warning disable CS0612
public async Task<IReadOnlyList<MilvusCollectionInfo>> ListCollectionsAsync(
IReadOnlyList<string>? collectionNames = null,
CollectionFilter filter = CollectionFilter.All,
Expand Down Expand Up @@ -200,6 +204,7 @@ await InvokeAsync(GrpcClient.ShowCollectionsAsync, request, static r => r.Status

return collections;
}
#pragma warning restore CS0612

/// <summary>
/// Flushes collection data to disk, required only in order to get up-to-date statistics.
Expand Down
10 changes: 5 additions & 5 deletions Milvus.Client/MilvusClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,7 @@ await GrpcClient.CheckHealthAsync(new CheckHealthRequest(),
_log.HealthCheckFailed(response.Reasons);
}

return new MilvusHealthState(response.IsHealthy, response.Status.Reason,
(MilvusErrorCode)response.Status.ErrorCode);
return new MilvusHealthState(response.IsHealthy, response.Status.Reason, (MilvusErrorCode)response.Status.Code);
}

/// <summary>
Expand Down Expand Up @@ -378,12 +377,13 @@ internal async Task<TResponse> InvokeAsync<TRequest, TResponse>(

TResponse response = await func(request, _callOptions.WithCancellationToken(cancellationToken)).ConfigureAwait(false);
Grpc.Status status = getStatus(response);
var code = (MilvusErrorCode)status.Code;

if (status.ErrorCode != Grpc.ErrorCode.Success)
if (code != MilvusErrorCode.Success)
{
_log.OperationFailed(callerName, (MilvusErrorCode)status.ErrorCode, status.Reason);
_log.OperationFailed(callerName, code, status.Reason);

throw new MilvusException((MilvusErrorCode)status.ErrorCode, status.Reason);
throw new MilvusException(code, status.Reason);
}

return response;
Expand Down
2 changes: 1 addition & 1 deletion Milvus.Client/MilvusCollection.Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ await _client.InvokeAsync(_client.GrpcClient.GetQuerySegmentInfoAsync, request,
.ConfigureAwait(false);

return response.Infos.Select(i => new QuerySegmentInfoResult(
i.CollectionID, i.IndexName, i.IndexID, i.MemSize, i.NodeID, i.NumRows, i.PartitionID, i.SegmentID,
i.CollectionID, i.IndexName, i.IndexID, i.MemSize, i.NodeIds, i.NumRows, i.PartitionID, i.SegmentID,
(SegmentState)i.State))
.ToList();
}
Expand Down
10 changes: 5 additions & 5 deletions Milvus.Client/MilvusCollection.Partition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ await _client.InvokeAsync(_client.GrpcClient.ShowPartitionsAsync, request, stati
{
for (int i = 0; i < response.PartitionIDs.Count; i++)
{
partitions.Add(new MilvusPartition(
response.PartitionIDs[i],
response.PartitionNames[i],
response.CreatedUtcTimestamps[i],
response.InMemoryPercentages?.Count > 0 ? response.InMemoryPercentages[i] : -1));
partitions.Add(
new MilvusPartition(
response.PartitionIDs[i],
response.PartitionNames[i],
response.CreatedUtcTimestamps[i]));
}
}

Expand Down
78 changes: 6 additions & 72 deletions Milvus.Client/MilvusErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,76 +7,10 @@ namespace Milvus.Client;
/// </summary>
public enum MilvusErrorCode
{
Success = Grpc.ErrorCode.Success,
UnexpectedError = Grpc.ErrorCode.UnexpectedError,
ConnectFailed = Grpc.ErrorCode.ConnectFailed,
PermissionDenied = Grpc.ErrorCode.PermissionDenied,
CollectionNotExists = Grpc.ErrorCode.CollectionNotExists,
IllegalArgument = Grpc.ErrorCode.IllegalArgument,
IllegalDimension = Grpc.ErrorCode.IllegalDimension,
IllegalIndexType = Grpc.ErrorCode.IllegalIndexType,
IllegalCollectionName = Grpc.ErrorCode.IllegalCollectionName,
IllegalTopk = Grpc.ErrorCode.IllegalTopk,
IllegalRowRecord = Grpc.ErrorCode.IllegalRowRecord,
IllegalVectorId = Grpc.ErrorCode.IllegalVectorId,
IllegalSearchResult = Grpc.ErrorCode.IllegalSearchResult,
FileNotFound = Grpc.ErrorCode.FileNotFound,
MetaFailed = Grpc.ErrorCode.MetaFailed,
CacheFailed = Grpc.ErrorCode.CacheFailed,
CannotCreateFolder = Grpc.ErrorCode.CannotCreateFolder,
CannotCreateFile = Grpc.ErrorCode.CannotCreateFile,
CannotDeleteFolder = Grpc.ErrorCode.CannotDeleteFolder,
CannotDeleteFile = Grpc.ErrorCode.CannotDeleteFile,
BuildIndexError = Grpc.ErrorCode.BuildIndexError,
IllegalNlist = Grpc.ErrorCode.IllegalNlist,
IllegalMetricType = Grpc.ErrorCode.IllegalMetricType,
OutOfMemory = Grpc.ErrorCode.OutOfMemory,
IndexNotExist = Grpc.ErrorCode.IndexNotExist,
EmptyCollection = Grpc.ErrorCode.EmptyCollection,
UpdateImportTaskFailure = Grpc.ErrorCode.UpdateImportTaskFailure,
CollectionNameNotFound = Grpc.ErrorCode.CollectionNameNotFound,
CreateCredentialFailure = Grpc.ErrorCode.CreateCredentialFailure,
UpdateCredentialFailure = Grpc.ErrorCode.UpdateCredentialFailure,
DeleteCredentialFailure = Grpc.ErrorCode.DeleteCredentialFailure,
GetCredentialFailure = Grpc.ErrorCode.GetCredentialFailure,
ListCredUsersFailure = Grpc.ErrorCode.ListCredUsersFailure,
GetUserFailure = Grpc.ErrorCode.GetUserFailure,
CreateRoleFailure = Grpc.ErrorCode.CreateRoleFailure,
DropRoleFailure = Grpc.ErrorCode.DropRoleFailure,
OperateUserRoleFailure = Grpc.ErrorCode.OperateUserRoleFailure,
SelectRoleFailure = Grpc.ErrorCode.SelectRoleFailure,
SelectUserFailure = Grpc.ErrorCode.SelectUserFailure,
SelectResourceFailure = Grpc.ErrorCode.SelectResourceFailure,
OperatePrivilegeFailure = Grpc.ErrorCode.OperatePrivilegeFailure,
SelectGrantFailure = Grpc.ErrorCode.SelectGrantFailure,
RefreshPolicyInfoCacheFailure = Grpc.ErrorCode.RefreshPolicyInfoCacheFailure,
ListPolicyFailure = Grpc.ErrorCode.ListPolicyFailure,
NotShardLeader = Grpc.ErrorCode.NotShardLeader,
NoReplicaAvailable = Grpc.ErrorCode.NoReplicaAvailable,
SegmentNotFound = Grpc.ErrorCode.SegmentNotFound,
ForceDeny = Grpc.ErrorCode.ForceDeny,
RateLimit = Grpc.ErrorCode.RateLimit,
NodeIdnotMatch = Grpc.ErrorCode.NodeIdnotMatch,
UpsertAutoIdtrue = Grpc.ErrorCode.UpsertAutoIdtrue,
InsufficientMemoryToLoad = Grpc.ErrorCode.InsufficientMemoryToLoad,
MemoryQuotaExhausted = Grpc.ErrorCode.MemoryQuotaExhausted,
DiskQuotaExhausted = Grpc.ErrorCode.DiskQuotaExhausted,
TimeTickLongDelay = Grpc.ErrorCode.TimeTickLongDelay,
NotReadyServe = Grpc.ErrorCode.NotReadyServe,

/// <summary>
/// Coord is switching from standby mode to active mode
/// </summary>
NotReadyCoordActivating = Grpc.ErrorCode.NotReadyCoordActivating,

/// <summary>
/// Service availability.
/// NA: Not Available.
/// </summary>
DataCoordNa = Grpc.ErrorCode.DataCoordNa,

/// <summary>
/// Internal error code.
/// </summary>
DdrequestRace = Grpc.ErrorCode.DdrequestRace
Success = 0,
UnexpectedError = 1,
RateLimit = 8,
ForceDeny = 9,
CollectionNotFound = 100,
IndexNotFound = 700
}
11 changes: 2 additions & 9 deletions Milvus.Client/MilvusPartition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ public sealed class MilvusPartition
internal MilvusPartition(
long partitionId,
string partitionName,
ulong creationTimestamp,
long inMemoryPercentage)
ulong creationTimestamp)
{
PartitionId = partitionId;
PartitionName = partitionName;
CreationTimestamp = creationTimestamp;
InMemoryPercentage = inMemoryPercentage;
}

/// <summary>
Expand All @@ -31,11 +29,6 @@ internal MilvusPartition(
/// </summary>
public string PartitionName { get; }

/// <summary>
/// Load percentage on query node.
/// </summary>
public long InMemoryPercentage { get; }

/// <summary>
/// An opaque identifier for the point in time in which the partition was created. Can be passed to
/// <see cref="MilvusCollection.SearchAsync{T}" /> or <see cref="MilvusCollection.QueryAsync" /> as a <i>guarantee
Expand All @@ -50,5 +43,5 @@ internal MilvusPartition(
/// Return string value of <see cref="MilvusPartition"/>.
/// </summary>
public override string ToString()
=> $"MilvusPartition: {{{nameof(PartitionName)}: {PartitionName}, {nameof(PartitionId)}: {PartitionId}, {nameof(CreationTimestamp)}:{CreationTimestamp}, {nameof(InMemoryPercentage)}: {InMemoryPercentage}}}";
=> $"MilvusPartition: {{{nameof(PartitionName)}: {PartitionName}, {nameof(PartitionId)}: {PartitionId}, {nameof(CreationTimestamp)}:{CreationTimestamp}}}";
}
6 changes: 3 additions & 3 deletions Milvus.Client/QuerySegmentResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal QuerySegmentInfoResult(
string indexName,
long indexId,
long memSize,
long nodeId,
IReadOnlyList<long> nodeIds,
long numRows,
long partitionId,
long segmentId,
Expand All @@ -20,7 +20,7 @@ internal QuerySegmentInfoResult(
IndexName = indexName;
IndexId = indexId;
MemSize = memSize;
NodeId = nodeId;
NodeIds = nodeIds;
NumRows = numRows;
PartitionId = partitionId;
SegmentId = segmentId;
Expand Down Expand Up @@ -50,7 +50,7 @@ internal QuerySegmentInfoResult(
/// <summary>
/// Node id.
/// </summary>
public long NodeId { get; }
public IReadOnlyList<long> NodeIds { get; }

/// <summary>
/// Number of rows.
Expand Down
Loading