mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
# Backport This will backport the following commits from `main` to `8.16`: - [[ML] Trained Models: Fixes spaces sync to retrieve 10000 models (#202712)](https://github.com/elastic/kibana/pull/202712) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Dima Arnautov","email":"dmitrii.arnautov@elastic.co"},"sourceCommit":{"committedDate":"2024-12-03T14:29:28Z","message":"[ML] Trained Models: Fixes spaces sync to retrieve 10000 models (#202712)\n\n## Summary\r\n\r\nThe default page size for the /trained_models API is 100. As a result,\r\nthe spaces sync task only fetched the first 100 models, leaving the rest\r\nunassigned to spaces and therefore invisible in the ML UI.\r\n\r\nThis PR increases the page size to 10,000 to ensure all models are\r\nproperly assigned to Kibana spaces.\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"ded18eeaac82787ea57d4991bad28b983d43ad0c","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","v9.0.0","Feature:3rd Party Models","Team:ML","backport:version","v8.17.0","v8.18.0","v8.16.2"],"title":"[ML] Trained Models: Fixes spaces sync to retrieve 10000 models","number":202712,"url":"https://github.com/elastic/kibana/pull/202712","mergeCommit":{"message":"[ML] Trained Models: Fixes spaces sync to retrieve 10000 models (#202712)\n\n## Summary\r\n\r\nThe default page size for the /trained_models API is 100. As a result,\r\nthe spaces sync task only fetched the first 100 models, leaving the rest\r\nunassigned to spaces and therefore invisible in the ML UI.\r\n\r\nThis PR increases the page size to 10,000 to ensure all models are\r\nproperly assigned to Kibana spaces.\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"ded18eeaac82787ea57d4991bad28b983d43ad0c"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x","8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202712","number":202712,"mergeCommit":{"message":"[ML] Trained Models: Fixes spaces sync to retrieve 10000 models (#202712)\n\n## Summary\r\n\r\nThe default page size for the /trained_models API is 100. As a result,\r\nthe spaces sync task only fetched the first 100 models, leaving the rest\r\nunassigned to spaces and therefore invisible in the ML UI.\r\n\r\nThis PR increases the page size to 10,000 to ensure all models are\r\nproperly assigned to Kibana spaces.\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"ded18eeaac82787ea57d4991bad28b983d43ad0c"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Dima Arnautov <dmitrii.arnautov@elastic.co>
This commit is contained in:
parent
e3f3ba382b
commit
7e0ea54b45
4 changed files with 18 additions and 4 deletions
12
x-pack/plugins/ml/common/constants/trained_models.ts
Normal file
12
x-pack/plugins/ml/common/constants/trained_models.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default page for the trained_models endpoint is 100,
|
||||
* which is too small for the most cases, so we set it to 10000.
|
||||
*/
|
||||
export const DEFAULT_TRAINED_MODELS_PAGE_SIZE = 10000;
|
|
@ -20,6 +20,7 @@ import {
|
|||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
|
||||
import type { CloudSetup } from '@kbn/cloud-plugin/server';
|
||||
import { DEFAULT_TRAINED_MODELS_PAGE_SIZE } from '../../../common/constants/trained_models';
|
||||
import type { MlFeatures } from '../../../common/constants/app';
|
||||
import type { ModelService } from '../model_management/models_provider';
|
||||
import { modelsProvider } from '../model_management';
|
||||
|
@ -38,7 +39,6 @@ import {
|
|||
isTransformLinkReturnType,
|
||||
} from './types';
|
||||
import type { MlClient } from '../../lib/ml_client';
|
||||
import { DEFAULT_TRAINED_MODELS_PAGE_SIZE } from '../../routes/trained_models';
|
||||
|
||||
export class AnalyticsManager {
|
||||
private _trainedModels: estypes.MlTrainedModelConfig[] = [];
|
||||
|
|
|
@ -17,6 +17,7 @@ import type {
|
|||
} from '@kbn/ml-trained-models-utils';
|
||||
import { isDefined } from '@kbn/ml-is-defined';
|
||||
import type { IScopedClusterClient } from '@kbn/core-elasticsearch-server';
|
||||
import { DEFAULT_TRAINED_MODELS_PAGE_SIZE } from '../../common/constants/trained_models';
|
||||
import { type MlFeatures, ML_INTERNAL_BASE_PATH } from '../../common/constants/app';
|
||||
import type { RouteInitialization } from '../types';
|
||||
import { wrapError } from '../client/error_wrapper';
|
||||
|
@ -44,8 +45,6 @@ import { mlLog } from '../lib/log';
|
|||
import { forceQuerySchema } from './schemas/anomaly_detectors_schema';
|
||||
import { modelsProvider } from '../models/model_management';
|
||||
|
||||
export const DEFAULT_TRAINED_MODELS_PAGE_SIZE = 10000;
|
||||
|
||||
export function filterForEnabledFeatureModels<
|
||||
T extends TrainedModelConfigResponse | estypes.MlTrainedModelConfig
|
||||
>(models: T[], enabledFeatures: MlFeatures) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
type IScopedClusterClient,
|
||||
SavedObjectsClient,
|
||||
} from '@kbn/core/server';
|
||||
import { DEFAULT_TRAINED_MODELS_PAGE_SIZE } from '../../common/constants/trained_models';
|
||||
import type { TrainedModelJob, MLSavedObjectService } from './service';
|
||||
import { ML_JOB_SAVED_OBJECT_TYPE } from '../../common/types/saved_objects';
|
||||
|
||||
|
@ -86,7 +87,9 @@ export function mlFunctionsFactory(client: IScopedClusterClient) {
|
|||
},
|
||||
async getTrainedModels() {
|
||||
try {
|
||||
return await client.asInternalUser.ml.getTrainedModels();
|
||||
return await client.asInternalUser.ml.getTrainedModels({
|
||||
size: DEFAULT_TRAINED_MODELS_PAGE_SIZE,
|
||||
});
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue