Skip to content

Commit

Permalink
Merge pull request #292 from chroma-core/aprJS
Browse files Browse the repository at this point in the history
JS client parity and broken out tests
  • Loading branch information
jeffchuber authored Apr 18, 2023
2 parents 6821ea6 + 65fd786 commit abdf9b5
Show file tree
Hide file tree
Showing 17 changed files with 622 additions and 190 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/chroma-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
- name: Test
run: python -m pytest
- name: Integration Test
run: bin/integration-test
run: bin/integration-test
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ Chroma is a rapidly developing project. We welcome PR contributors and ideas for
## License

[Apache 2.0](./LICENSE)

4 changes: 4 additions & 0 deletions chromadb/server/fastapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(self, settings):
self.router.add_api_route("/api/v1", self.root, methods=["GET"])
self.router.add_api_route("/api/v1/reset", self.reset, methods=["POST"])
self.router.add_api_route("/api/v1/version", self.version, methods=["GET"])
self.router.add_api_route("/api/v1/heartbeat", self.heartbeat, methods=["GET"])
self.router.add_api_route("/api/v1/persist", self.persist, methods=["POST"])
self.router.add_api_route("/api/v1/raw_sql", self.raw_sql, methods=["POST"])

Expand Down Expand Up @@ -124,6 +125,9 @@ def app(self):
def root(self):
return {"nanosecond heartbeat": self._api.heartbeat()}

def heartbeat(self):
return self.root()

def persist(self):
self._api.persist()

Expand Down
6 changes: 3 additions & 3 deletions clients/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chromadb",
"version": "1.3.1",
"version": "1.4.0",
"description": "A JavaScript interface for chroma",
"keywords": [],
"author": "",
Expand Down Expand Up @@ -31,8 +31,8 @@
"test:run": "jest --runInBand",
"test:runfull": "PORT=8001 jest --runInBand",
"test:update": "run-s db:clean db:run && jest --runInBand --updateSnapshot && run-s db:clean",
"db:clean": "cd ../.. && docker-compose -f docker-compose-js-tests.yml down --volumes",
"db:run": "cd ../.. && docker-compose -f docker-compose-js-tests.yml up --detach && sleep 5",
"db:clean": "cd ../.. && docker-compose -f docker-compose.test.yml down --volumes",
"db:run": "cd ../.. && docker-compose -f docker-compose.test.yml up --detach && sleep 5",
"clean": "rimraf dist",
"build": "run-s clean build:*",
"build:main": "tsc -p tsconfig.json",
Expand Down
120 changes: 120 additions & 0 deletions clients/js/src/generated/api/default-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,36 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
options: localVarRequestOptions,
};
},
/**
*
* @summary Heartbeat
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
heartbeat: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/v1/heartbeat`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary List Collections
Expand Down Expand Up @@ -607,6 +637,36 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(updateCollection, localVarRequestOptions, configuration)

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Version
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
version: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/v1/version`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
Expand Down Expand Up @@ -725,6 +785,16 @@ export const DefaultApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.getNearestNeighbors(collectionName, queryEmbedding, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @summary Heartbeat
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async heartbeat(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<any>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.heartbeat(options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @summary List Collections
Expand Down Expand Up @@ -800,6 +870,16 @@ export const DefaultApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.updateCollection(collectionName, updateCollection, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @summary Version
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async version(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<any>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.version(options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
}
};

Expand Down Expand Up @@ -904,6 +984,15 @@ export const DefaultApiFactory = function (configuration?: Configuration, basePa
getNearestNeighbors(collectionName: any, queryEmbedding: QueryEmbedding, options?: any): AxiosPromise<any> {
return localVarFp.getNearestNeighbors(collectionName, queryEmbedding, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Heartbeat
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
heartbeat(options?: any): AxiosPromise<any> {
return localVarFp.heartbeat(options).then((request) => request(axios, basePath));
},
/**
*
* @summary List Collections
Expand Down Expand Up @@ -972,6 +1061,15 @@ export const DefaultApiFactory = function (configuration?: Configuration, basePa
updateCollection(collectionName: any, updateCollection: UpdateCollection, options?: any): AxiosPromise<any> {
return localVarFp.updateCollection(collectionName, updateCollection, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Version
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
version(options?: any): AxiosPromise<any> {
return localVarFp.version(options).then((request) => request(axios, basePath));
},
};
};

Expand Down Expand Up @@ -1300,6 +1398,17 @@ export class DefaultApi extends BaseAPI {
return DefaultApiFp(this.configuration).getNearestNeighbors(requestParameters.collectionName, requestParameters.queryEmbedding, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Heartbeat
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public heartbeat(options?: AxiosRequestConfig) {
return DefaultApiFp(this.configuration).heartbeat(options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary List Collections
Expand Down Expand Up @@ -1379,4 +1488,15 @@ export class DefaultApi extends BaseAPI {
public updateCollection(requestParameters: DefaultApiUpdateCollectionRequest, options?: AxiosRequestConfig) {
return DefaultApiFp(this.configuration).updateCollection(requestParameters.collectionName, requestParameters.updateCollection, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Version
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public version(options?: AxiosRequestConfig) {
return DefaultApiFp(this.configuration).version(options).then((request) => request(this.axios, this.basePath));
}
}
Loading

0 comments on commit abdf9b5

Please sign in to comment.