Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Rename curated model type to elastic #156684

Merged
merged 2 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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