-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ml): add new ml model listing endpoint to platform client (#736)
* feat(ml): add new ml model listing endpoint to platform client Add new ml model lsiting endpoint (/rest/organizations/{organizationId}/machinelearning/configuration/modelslisting) to platform client with interfaces
- Loading branch information
1 parent
4b39e9e
commit f6a2300
Showing
6 changed files
with
165 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/resources/MachineLearning/ModelListing/ModelListing.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import API from '../../../APICore.js'; | ||
import Resource from '../../Resource.js'; | ||
import {MLListingModel} from './ModelListingInterfaces.js'; | ||
|
||
export default class ModelListing extends Resource { | ||
static baseUrl = `/rest/organizations/${API.orgPlaceholder}/machinelearning/configuration/modellisting`; | ||
|
||
list(engineIds?: string[]) { | ||
return this.api.get<MLListingModel[]>(this.buildPath(ModelListing.baseUrl, {engineIds})); | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
src/resources/MachineLearning/ModelListing/ModelListingInterfaces.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
export interface MLListingModel { | ||
/** | ||
* The model display name in the Coveo Administration console. | ||
* | ||
* @Example `MyModelDisplayName` | ||
*/ | ||
modelDisplayName: string; | ||
/** | ||
* The unique identifier of the target machine learning model. | ||
* | ||
* @Example `My_Model_ID` | ||
*/ | ||
modelId: string; | ||
/** | ||
* The id of the engine. | ||
* | ||
* @Example `topclicks` | ||
*/ | ||
engineId: string; | ||
/** | ||
* The date and time the model was last updated. | ||
* | ||
* @Example `1691762520000` | ||
**/ | ||
estimatedPreviousModelUpdateTime: number; | ||
/** | ||
* The date and time the model is scheduled to start its next update. | ||
* | ||
* @Example `1691762520000` | ||
*/ | ||
nextModelUpdateTime: number; | ||
/** | ||
* Version of the platform. | ||
* | ||
* @Example `2` | ||
*/ | ||
platformVersion: 1 | 2; | ||
/** | ||
* The model size statistic. Depending on the model type, this value represents the number of items or queries on which the model was built. | ||
* | ||
* @Example `5` | ||
*/ | ||
modelSizeStatistic: number; | ||
readyForAssociation: boolean; | ||
/** | ||
* The current status of the model | ||
*/ | ||
modelStatusInfo: MLModelStatusInfo; | ||
/** | ||
* The associations related to this model | ||
* | ||
*/ | ||
modelAssociations: MLModelAssociation[]; | ||
} | ||
|
||
export interface MLModelStatusInfo { | ||
/** | ||
* The status of the model. | ||
* | ||
* @Example `ACTIVE` | ||
*/ | ||
modelStatus: | ||
| 'ARCHIVED' | ||
| 'SOON_TO_BE_ARCHIVED' | ||
| 'BUILD_IN_PROGRESS' | ||
| 'ERROR' | ||
| 'ERROR_INTERNAL' | ||
| 'LIMITED' | ||
| 'NOT_ASSOCIATED' | ||
| 'ACTIVE' | ||
| 'INACTIVE'; | ||
/** | ||
* The remaining days until the model is archived. | ||
* | ||
* @Example `4` | ||
*/ | ||
daysUntilArchival?: number; | ||
} | ||
|
||
export interface MLModelAssociation { | ||
/** | ||
* The unique identifier of the query pipeline to which the model is associated. | ||
* | ||
* @Example `38b08160-d7d4-4626-8e03-53587c23415d` | ||
*/ | ||
parentId: string; | ||
/** | ||
* The unique identifier of the model association. | ||
* | ||
* @Example `917af358-13fd-4c8e-94af-7cf649bddc48` | ||
*/ | ||
id: string; | ||
/** | ||
* The name of the query pipeline or case assist configuration the model is associated with. | ||
* | ||
* @Example `association name` | ||
*/ | ||
name: string; | ||
/** | ||
* The type of the association. | ||
* | ||
* @Example `QUERY_PIPELINE` | ||
*/ | ||
associationType: 'QUERY_PIPELINE' | 'CASE_ASSIST'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './ModelListing.js'; | ||
export * from './ModelListingInterfaces.js'; |
42 changes: 42 additions & 0 deletions
42
src/resources/MachineLearning/ModelListing/tests/ModelListing.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import API from '../../../../APICore.js'; | ||
import ModelListing from '../ModelListing.js'; | ||
|
||
jest.mock('../../../../APICore.js'); | ||
|
||
const APIMock: jest.Mock<API> = API as any; | ||
|
||
describe('ModelListing', () => { | ||
let modelListing: ModelListing; | ||
const api = new APIMock() as jest.Mocked<API>; | ||
const serverlessApi = new APIMock() as jest.Mocked<API>; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
modelListing = new ModelListing(api, serverlessApi); | ||
}); | ||
|
||
describe('list', () => { | ||
it('should make a GET call to the ModelListing base url', () => { | ||
modelListing.list(); | ||
|
||
expect(api.get).toHaveBeenCalledTimes(1); | ||
expect(api.get).toHaveBeenCalledWith(ModelListing.baseUrl); | ||
}); | ||
|
||
it('should make a GET call to the ModelListing base url if empty array is passed', () => { | ||
modelListing.list([]); | ||
|
||
expect(api.get).toHaveBeenCalledTimes(1); | ||
expect(api.get).toHaveBeenCalledWith(ModelListing.baseUrl); | ||
}); | ||
|
||
it('should make a GET call to the ModelListing base url with provided list of engineIds', () => { | ||
const engines = ['first', 'second']; | ||
const expectedUrl = `${ModelListing.baseUrl}?engineIds=${engines[0]}&engineIds=${engines[1]}`; | ||
modelListing.list(engines); | ||
|
||
expect(api.get).toHaveBeenCalledTimes(1); | ||
expect(api.get).toHaveBeenCalledWith(expectedUrl); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters