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

fix doc and sdk version api #83

Merged
merged 2 commits into from
Feb 23, 2022
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 example/HelloMilvus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DataType } from "@zilliz/milvus2-sdk-node/dist/milvus/types/Common";
import { InsertReq } from "@zilliz/milvus2-sdk-node/dist/milvus/types/Data";

const milvusClient = new MilvusClient("localhost:19530");
const collectionManager = milvusClient.collectionManager;
const collectionManager = MilvusClient.collectionManager;

console.log("Milvus SDK Info: ", milvusClient.sdkInfo);

Expand Down
7 changes: 6 additions & 1 deletion milvus/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ export class Client {
this.client = client;
}

/**
* @ignore
*/
checkCollectionName(data: any) {
if (!data || !data.collection_name) {
throw new Error(ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
}
}

/**
* @ignore
*/
checkCollectionAndPartitionName(data: any) {
if (!data || !data.collection_name || !data.partition_name) {
throw new Error(ERROR_REASONS.COLLECTION_PARTITION_NAME_ARE_REQUIRED);
Expand Down
2 changes: 1 addition & 1 deletion milvus/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Client } from "./Client";
import { Collection } from "./Collection";
import { ERROR_REASONS } from "./const/ErrorReason";

import { DataType, DataTypeMap, DslType, SegmentState } from "./types/Common";
import { DataType, DataTypeMap, DslType } from "./types/Common";
import {
CalcDistanceReq,
DeleteEntitiesReq,
Expand Down
6 changes: 3 additions & 3 deletions milvus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class MilvusClient {
this.dataManager = new Data(this.client, this.collectionManager);
}

get sdkInfo() {
static get sdkInfo() {
return {
version: sdkInfo.version,
recommandMilvus: sdkInfo.milvusVersion,
Expand All @@ -69,10 +69,10 @@ export class MilvusClient {
// Each node contains the same system info, so get version from first one.
const curMilvusVersion =
res.response.nodes_info[0]?.infos?.system_info?.build_version;
if (curMilvusVersion !== this.sdkInfo.recommandMilvus) {
if (curMilvusVersion !== MilvusClient.sdkInfo.recommandMilvus) {
console.warn("------- Warning ---------");
console.warn(
`Node sdk ${this.sdkInfo.version} recommend Milvus Version ${this.sdkInfo.recommandMilvus}.\nDifferent version may cause some error.`
`Node sdk ${MilvusClient.sdkInfo.version} recommend Milvus Version ${MilvusClient.sdkInfo.recommandMilvus}.\nDifferent version may cause some error.`
);
return { error_code: ErrorCode.SUCCESS, match: false };
}
Expand Down
1 change: 0 additions & 1 deletion test/Index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { MilvusClient } from "../milvus";

import { GENERATE_NAME, IP } from "../const";
import { DataType } from "../milvus/types/Common";
import { ErrorCode } from "../milvus/types/Response";
import { genCollectionParams, VECTOR_FIELD_NAME } from "../utils/test";
import { ERROR_REASONS } from "../milvus/const/ErrorReason";
Expand Down
4 changes: 2 additions & 2 deletions test/MilvusClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ describe("Milvus client ", () => {
});

it("Expect get node sdk info", async () => {
expect(milvusClient.sdkInfo.version).toEqual(sdkInfo.version);
expect(milvusClient.sdkInfo.recommandMilvus).toEqual(sdkInfo.milvusVersion);
expect(MilvusClient.sdkInfo.version).toEqual(sdkInfo.version);
expect(MilvusClient.sdkInfo.recommandMilvus).toEqual(sdkInfo.milvusVersion);
});

it("Check version should success", async () => {
Expand Down