Skip to content

Commit

Permalink
[8.8] [ML] Rename curated model type to elastic (#156684) (#156786)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.8`:
- [[ML] Rename `curated` model type to `elastic`
(#156684)](#156684)

<!--- Backport version: 8.9.7 -->

### 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":"2023-05-05T06:57:50Z","message":"[ML]
Rename `curated` model type to `elastic` (#156684)\n\n##
Summary\r\n\r\nRename the `curated` model type and tag to
`elastic`","sha":"3f42de3f5f571a79b8a5d464230b02be03eb4763","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":[":ml","release_note:skip","Team:ML","v8.8.0","v8.9.0"],"number":156684,"url":"https://github.com/elastic/kibana/pull/156684","mergeCommit":{"message":"[ML]
Rename `curated` model type to `elastic` (#156684)\n\n##
Summary\r\n\r\nRename the `curated` model type and tag to
`elastic`","sha":"3f42de3f5f571a79b8a5d464230b02be03eb4763"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/156684","number":156684,"mergeCommit":{"message":"[ML]
Rename `curated` model type to `elastic` (#156684)\n\n##
Summary\r\n\r\nRename the `curated` model type and tag to
`elastic`","sha":"3f42de3f5f571a79b8a5d464230b02be03eb4763"}}]}]
BACKPORT-->

Co-authored-by: Dima Arnautov <dmitrii.arnautov@elastic.co>
  • Loading branch information
kibanamachine and darnautov authored May 5, 2023
1 parent ef2f448 commit 0d6161a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
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 0d6161a

Please sign in to comment.