-
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(mlx): add the modelassociations call (#905)
* feat(mlx): add the modelassociations call * fix: add documentation and test
- Loading branch information
1 parent
0bfe261
commit 89522c3
Showing
7 changed files
with
118 additions
and
0 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
18 changes: 18 additions & 0 deletions
18
src/resources/MachineLearning/ModelAssociations/ModelAssociations.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,18 @@ | ||
import API from '../../../APICore.js'; | ||
import {PageModel} from '../../BaseInterfaces.js'; | ||
import Resource from '../../Resource.js'; | ||
import {AssociationItem, ModelAssociationsListParams} from './ModelAssociationsInterfaces.js'; | ||
|
||
export default class ModelAssociations extends Resource { | ||
static baseUrl = `/rest/organizations/${API.orgPlaceholder}/machinelearning/configuration/querypipelines`; | ||
|
||
/** | ||
* Lists the organization associations corresponding to the specified pipelineId. | ||
* @param pipelineId The unique identifier of the query pipeline. | ||
* @param params The pagination parameters. | ||
* @returns A list of associated models | ||
*/ | ||
list(pipelineId: string, params: ModelAssociationsListParams): Promise<PageModel<AssociationItem>> { | ||
return this.api.get(this.buildPath(`${ModelAssociations.baseUrl}/${pipelineId}/associations`, params)); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/resources/MachineLearning/ModelAssociations/ModelAssociationsInterfaces.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,62 @@ | ||
import {ConditionModel} from '../../Pipelines/index.js'; | ||
import {MLModelStatus} from '../MachineLearningInterfaces.js'; | ||
|
||
export interface ModelAssociationsListParams { | ||
/* | ||
* The 0-based number of the page of results to list. Default: 0 | ||
*/ | ||
page: number; | ||
/* | ||
* The maximum number of results to include per page.. Default: 100 | ||
*/ | ||
pageSize: number; | ||
} | ||
export interface AssociationItem { | ||
/** | ||
* The unique identifier of the model association. | ||
*/ | ||
associationId: string; | ||
/** | ||
* The unique identifier of the target machine learning model. | ||
*/ | ||
modelId: string; | ||
/** | ||
* The id of the engine. | ||
*/ | ||
engineId?: string; | ||
/** | ||
* The name of the model configuration. | ||
*/ | ||
modelDisplayName?: string; | ||
/** | ||
* The current status of the model. | ||
* @example { modelStatus: "BUILDING", daysUntilArchival : 3 } | ||
*/ | ||
modelStatusInfo?: { | ||
/** | ||
* The status of the model. | ||
* @example "ACTIVE" | ||
*/ | ||
modelStatus: MLModelStatus; | ||
/** | ||
* The remaining days until the model is archived. | ||
*/ | ||
daysUntilArchival?: number; | ||
}; | ||
/** | ||
* The condition that must be met to trigger the model association. | ||
*/ | ||
condition?: ConditionModel; | ||
/** | ||
* The position at which this model association is evaluated in the query pipeline, relative to other model associations. | ||
*/ | ||
position: number; | ||
/** | ||
* Whether the Coveo Administration Console should show the advanced configuration for this association. | ||
*/ | ||
useAdvancedConfiguration?: boolean; | ||
/** | ||
* The additional parameters to send to Coveo ML. | ||
*/ | ||
customQueryParameters?: {submodel: string}; | ||
} |
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 './ModelAssociations.js'; | ||
export * from './ModelAssociationsInterfaces.js'; |
26 changes: 26 additions & 0 deletions
26
src/resources/MachineLearning/ModelAssociations/tests/ModelAssociations.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,26 @@ | ||
import API from '../../../../APICore.js'; | ||
import ModelAssociations from '../ModelAssociations.js'; | ||
|
||
jest.mock('../../../../APICore'); | ||
|
||
describe('ModelAssociations', () => { | ||
let modelAssociations: ModelAssociations; | ||
const api = new API({accessToken: 'some-token'}); | ||
const serverlessApi = new API({accessToken: 'some-token'}); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
modelAssociations = new ModelAssociations(api, serverlessApi); | ||
}); | ||
|
||
describe('createPQSModel', () => { | ||
it('should make a GET call to the specific IAPRConfiguration url', async () => { | ||
const pipelineId = '123'; | ||
await modelAssociations.list(pipelineId, {page: 1, pageSize: 25}); | ||
expect(api.get).toHaveBeenCalledTimes(1); | ||
expect(api.get).toHaveBeenCalledWith( | ||
`${ModelAssociations.baseUrl}/${pipelineId}/associations?page=1&pageSize=25`, | ||
); | ||
}); | ||
}); | ||
}); |
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
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