Skip to content

Commit

Permalink
Merge branch '8.8' into backport/8.8/pr-156586
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored May 5, 2023
2 parents 8382b45 + 0d6161a commit 001a119
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/plugins/saved_search/server/saved_objects/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export function getSavedSearchObjectType(
columns: schema.arrayOf(schema.string(), { defaultValue: [] }),
sort: schema.oneOf(
[
schema.arrayOf(schema.arrayOf(schema.string(), { minSize: 2, maxSize: 2 })),
schema.arrayOf(schema.string(), { minSize: 2, maxSize: 2 }),
schema.arrayOf(schema.arrayOf(schema.string(), { maxSize: 2 })),
schema.arrayOf(schema.string(), { maxSize: 2 }),
],
{ defaultValue: [] }
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,13 @@ export const BUILT_IN_MODEL_TYPE = i18n.translate(
{ defaultMessage: 'built-in' }
);

export const CURATED_MODEL_TYPE = i18n.translate(
'xpack.ml.trainedModels.modelsList.curatedModelLabel',
{ defaultMessage: 'curated' }
);
export const ELASTIC_MODEL_TYPE = 'elastic';

export const BUILT_IN_MODEL_TAG = 'prepackaged';

export const CURATED_MODEL_TAG = 'curated';
export const ELASTIC_MODEL_TAG = 'elastic';

export const CURATED_MODEL_DEFINITIONS = {
export const ELASTIC_MODEL_DEFINITIONS = {
'.elser_model_1': {
config: {
input: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
TRAINED_MODEL_TYPE,
} from '@kbn/ml-trained-models-utils';
import {
CURATED_MODEL_TAG,
ELASTIC_MODEL_TAG,
MODEL_STATE,
} from '@kbn/ml-trained-models-utils/src/constants/trained_models';
import { useTrainedModelsApiService } from '../services/ml_api_service/trained_models';
Expand Down Expand Up @@ -357,7 +357,7 @@ export function useModelActions({
icon: 'download',
type: 'icon',
isPrimary: true,
available: (item) => item.tags.includes(CURATED_MODEL_TAG),
available: (item) => item.tags.includes(ELASTIC_MODEL_TAG),
enabled: (item) => !item.state && !isLoading,
onClick: async (item) => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import {
} from '@kbn/ml-trained-models-utils';
import { isDefined } from '@kbn/ml-is-defined';
import {
CURATED_MODEL_DEFINITIONS,
CURATED_MODEL_TAG,
CURATED_MODEL_TYPE,
ELASTIC_MODEL_DEFINITIONS,
ELASTIC_MODEL_TAG,
ELASTIC_MODEL_TYPE,
MODEL_STATE,
} from '@kbn/ml-trained-models-utils/src/constants/trained_models';
import { TechnicalPreviewBadge } from '../components/technical_preview_badge';
Expand Down Expand Up @@ -143,8 +143,8 @@ export const ModelsList: FC<Props> = ({
[]
);

const isCuratedModel = useCallback(
(item: ModelItem) => item.tags.includes(CURATED_MODEL_TAG),
const isElasticModel = useCallback(
(item: ModelItem) => item.tags.includes(ELASTIC_MODEL_TAG),
[]
);

Expand Down Expand Up @@ -196,7 +196,7 @@ export const ModelsList: FC<Props> = ({
model.model_type,
...Object.keys(model.inference_config),
...(isBuiltInModel(model as ModelItem) ? [BUILT_IN_MODEL_TYPE] : []),
...(isCuratedModel(model as ModelItem) ? [CURATED_MODEL_TYPE] : []),
...(isElasticModel(model as ModelItem) ? [ELASTIC_MODEL_TYPE] : []),
],
}
: {}),
Expand Down Expand Up @@ -285,11 +285,11 @@ export const ModelsList: FC<Props> = ({
: '';
});

const curatedModels = models.filter((model) =>
CURATED_MODEL_DEFINITIONS.hasOwnProperty(model.model_id)
const elasticModels = models.filter((model) =>
ELASTIC_MODEL_DEFINITIONS.hasOwnProperty(model.model_id)
);
if (curatedModels.length > 0) {
for (const model of curatedModels) {
if (elasticModels.length > 0) {
for (const model of elasticModels) {
if (model.state === MODEL_STATE.STARTED) {
// no need to check for the download status if the model has been deployed
continue;
Expand Down Expand Up @@ -545,7 +545,7 @@ export const ModelsList: FC<Props> = ({
selectable: (item) =>
!isPopulatedObject(item.pipelines) &&
!isBuiltInModel(item) &&
!(isCuratedModel(item) && !item.state),
!(isElasticModel(item) && !item.state),
onSelectionChange: (selectedItems) => {
setSelectedModels(selectedItems);
},
Expand Down Expand Up @@ -584,13 +584,13 @@ export const ModelsList: FC<Props> = ({

const resultItems = useMemo<ModelItem[]>(() => {
const idSet = new Set(items.map((i) => i.model_id));
const notDownloaded: ModelItem[] = Object.entries(CURATED_MODEL_DEFINITIONS)
const notDownloaded: ModelItem[] = Object.entries(ELASTIC_MODEL_DEFINITIONS)
.filter(([modelId]) => !idSet.has(modelId))
.map(([modelId, modelDefinition]) => {
return {
model_id: modelId,
type: [CURATED_MODEL_TYPE],
tags: [CURATED_MODEL_TAG],
type: [ELASTIC_MODEL_TYPE],
tags: [ELASTIC_MODEL_TAG],
putModelConfig: modelDefinition.config,
description: modelDefinition.description,
} as ModelItem;
Expand Down

0 comments on commit 001a119

Please sign in to comment.