Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9cf4ca1
hide pagination when total number of items is lower than min page siz…
darnautov Sep 30, 2024
2f31439
update layout
darnautov Sep 30, 2024
8586784
remove "Not downloaded"
darnautov Sep 30, 2024
7b463bc
remove unused translation
darnautov Sep 30, 2024
c158893
e5 disclaimer
darnautov Sep 30, 2024
d936f39
auto table layout
darnautov Oct 1, 2024
6ac5ac4
update states
darnautov Oct 1, 2024
cbaf1a9
remove unused import
darnautov Oct 1, 2024
76af7cf
fix tags responsive layout
darnautov Oct 1, 2024
c25a6d2
change type based on layout
darnautov Oct 1, 2024
d838115
change deploy action visibility
darnautov Oct 4, 2024
fe46884
update model actions
darnautov Oct 7, 2024
1bb8f5d
improve state update
darnautov Oct 7, 2024
ee36bad
working state update
darnautov Oct 7, 2024
8690276
cleanup
darnautov Oct 7, 2024
7c8f271
remove success toasts
darnautov Oct 7, 2024
9d6d7d5
remove unused translation strings
darnautov Oct 7, 2024
48a60ba
remove redundant stats call
darnautov Oct 7, 2024
ce3ca94
spinner for the stopping state
darnautov Oct 7, 2024
6b2ade8
update states based on the latest prototype
darnautov Oct 7, 2024
bd5bb08
Merge remote-tracking branch 'origin/main' into ml-trained-models-ui-…
darnautov Oct 7, 2024
74adf16
remove success deletion toast
darnautov Oct 7, 2024
6a0628b
fix check for pytorch
darnautov Oct 7, 2024
eb9f76f
update jest tests
darnautov Oct 7, 2024
82cb2b1
update api tests
darnautov Oct 7, 2024
a8050da
update functional tests
darnautov Oct 7, 2024
aa9db4a
fix tooltip, update useTableSettings signature
darnautov Oct 8, 2024
34c6516
remove createdAt assertion
darnautov Oct 8, 2024
6fb1c5e
test action as primary
darnautov Oct 8, 2024
439c6ba
move space
darnautov Oct 8, 2024
0812fc8
fix ts issue with function overload
darnautov Oct 8, 2024
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 @@ -120,6 +120,10 @@ export const ELASTIC_MODEL_DEFINITIONS: Record<
license: 'MIT',
licenseUrl: 'https://huggingface.co/elastic/multilingual-e5-small',
type: ['pytorch', 'text_embedding'],
disclaimer: i18n.translate('xpack.ml.trainedModels.modelsList.e5v1Disclaimer', {
defaultMessage:
'This E5 model, as defined, hosted, integrated and used in conjunction with our other Elastic Software is covered by our standard warranty.',
}),
},
[E5_LINUX_OPTIMIZED_MODEL_ID]: {
modelName: 'e5',
Expand All @@ -138,6 +142,10 @@ export const ELASTIC_MODEL_DEFINITIONS: Record<
license: 'MIT',
licenseUrl: 'https://huggingface.co/elastic/multilingual-e5-small_linux-x86_64',
type: ['pytorch', 'text_embedding'],
disclaimer: i18n.translate('xpack.ml.trainedModels.modelsList.e5v1Disclaimer', {
defaultMessage:
'This E5 model, as defined, hosted, integrated and used in conjunction with our other Elastic Software is covered by our standard warranty.',
}),
},
} as const);

Expand Down Expand Up @@ -167,6 +175,7 @@ export interface ModelDefinition {
/** Link to the external license/documentation page */
licenseUrl?: string;
type?: readonly string[];
disclaimer?: string;
}

export type ModelDefinitionResponse = ModelDefinition & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ export interface CriteriaWithPagination<T extends object> extends Criteria<T> {
};
}

interface UseTableSettingsReturnValue<T extends object> {
interface UseTableSettingsReturnValue<T extends object, HidePagination extends boolean = false> {
onTableChange: EuiBasicTableProps<T>['onChange'];
pagination: Required<Omit<Pagination, 'showPerPageOptions'>>;
pagination: HidePagination extends true
? Required<Omit<Pagination, 'showPerPageOptions'>> | boolean
: Required<Omit<Pagination, 'showPerPageOptions'>>;
sorting: {
sort: {
field: keyof T;
Expand All @@ -44,8 +46,31 @@ interface UseTableSettingsReturnValue<T extends object> {
export function useTableSettings<TypeOfItem extends object>(
totalItemCount: number,
pageState: ListingPageUrlState,
updatePageState: (update: Partial<ListingPageUrlState>) => void
): UseTableSettingsReturnValue<TypeOfItem> {
updatePageState: (update: Partial<ListingPageUrlState>) => void,
hide: true
): UseTableSettingsReturnValue<TypeOfItem, true>;

export function useTableSettings<TypeOfItem extends object>(
totalItemCount: number,
pageState: ListingPageUrlState,
updatePageState: (update: Partial<ListingPageUrlState>) => void,
hide?: false
): UseTableSettingsReturnValue<TypeOfItem, false>;

/**
*
* @param totalItemCount
* @param pageState
* @param updatePageState
* @param hide If true, hides pagination when total number of items is lower that the smallest per page option
* @returns
*/
export function useTableSettings<TypeOfItem extends object>(
totalItemCount: number,
pageState: ListingPageUrlState,
updatePageState: (update: Partial<ListingPageUrlState>) => void,
hide: boolean = false
): UseTableSettingsReturnValue<TypeOfItem, boolean> {
const { pageIndex, pageSize, sortField, sortDirection } = pageState;

const onTableChange: EuiBasicTableProps<TypeOfItem>['onChange'] = useCallback(
Expand All @@ -66,15 +91,19 @@ export function useTableSettings<TypeOfItem extends object>(
[pageState, updatePageState]
);

const pagination = useMemo(
() => ({
const pagination = useMemo(() => {
if (hide && totalItemCount <= Math.min(...PAGE_SIZE_OPTIONS)) {
// Hide pagination if total number of items is lower that the smallest per page option
return false;
}

return {
pageIndex,
pageSize,
totalItemCount,
pageSizeOptions: PAGE_SIZE_OPTIONS,
}),
[totalItemCount, pageIndex, pageSize]
);
};
}, [totalItemCount, pageIndex, pageSize, hide]);

const sorting = useMemo(
() => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ export function DataViewEditor({
const { onTableChange, pagination } = useTableSettings<MatchedItem>(
matchedReferenceIndices.length,
pageState,
// @ts-expect-error callback will have all the 4 necessary params
updatePageState
updatePageState as Parameters<typeof useTableSettings>['2']
);

const pageOfItems = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface DeleteModelsModalProps {

export const DeleteModelsModal: FC<DeleteModelsModalProps> = ({ models, onClose }) => {
const trainedModelsApiService = useTrainedModelsApiService();
const { displayErrorToast, displaySuccessToast } = useToastNotificationService();
const { displayErrorToast } = useToastNotificationService();

const [canDeleteModel, setCanDeleteModel] = useState(false);
const [deletePipelines, setDeletePipelines] = useState<boolean>(false);
Expand Down Expand Up @@ -66,16 +66,6 @@ export const DeleteModelsModal: FC<DeleteModelsModalProps> = ({ models, onClose
})
)
);
displaySuccessToast(
i18n.translate('xpack.ml.trainedModels.modelsList.successfullyDeletedMessage', {
defaultMessage:
'{modelsCount, plural, one {Model {modelIds}} other {# models}} {modelsCount, plural, one {has} other {have}} been successfully deleted',
values: {
modelsCount: modelIds.length,
modelIds: modelIds.join(', '),
},
})
);
} catch (error) {
displayErrorToast(
error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@
* 2.0.
*/

import React from 'react';
import { DEPLOYMENT_STATE, MODEL_STATE, type ModelState } from '@kbn/ml-trained-models-utils';
import type { EuiHealthProps } from '@elastic/eui';
import {
EuiBadge,
EuiHealth,
EuiLoadingSpinner,
type EuiHealthProps,
EuiFlexGroup,
EuiFlexItem,
EuiText,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import type { ModelItem } from './models_list';

Expand All @@ -33,11 +42,11 @@ export const getModelDeploymentState = (model: ModelItem): ModelState | undefine

export const getModelStateColor = (
state: ModelState | undefined
): { color: EuiHealthProps['color']; name: string } | null => {
): { color: EuiHealthProps['color']; name: string; component?: React.ReactNode } | null => {
switch (state) {
case MODEL_STATE.DOWNLOADED:
return {
color: 'subdued',
color: 'success',
name: i18n.translate('xpack.ml.trainedModels.modelsList.modelState.downloadedName', {
defaultMessage: 'Ready to deploy',
}),
Expand All @@ -46,37 +55,64 @@ export const getModelStateColor = (
return {
color: 'primary',
name: i18n.translate('xpack.ml.trainedModels.modelsList.modelState.downloadingName', {
defaultMessage: 'Downloading...',
defaultMessage: 'Downloading',
}),
};
case MODEL_STATE.STARTED:
return {
color: 'success',
color: '#E6F9F7',
name: i18n.translate('xpack.ml.trainedModels.modelsList.modelState.startedName', {
defaultMessage: 'Deployed',
}),
get component() {
return (
<EuiBadge color={this.color}>
<EuiHealth color={'success'} textSize="xs" css={{ display: 'inline' }}>
{this.name}
</EuiHealth>
</EuiBadge>
);
},
};
case MODEL_STATE.STARTING:
return {
color: 'success',
name: i18n.translate('xpack.ml.trainedModels.modelsList.modelState.startingName', {
defaultMessage: 'Starting deployment...',
defaultMessage: 'Deploying',
}),
get component() {
return (
<EuiFlexGroup gutterSize="xs" alignItems="center">
<EuiFlexItem grow={false}>
<EuiLoadingSpinner size="s" />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText size="xs">{this.name}</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
);
},
};
case MODEL_STATE.STOPPING:
return {
color: 'accent',
name: i18n.translate('xpack.ml.trainedModels.modelsList.modelState.stoppingName', {
defaultMessage: 'Stopping deployment...',
defaultMessage: 'Stopping',
}),
get component() {
return (
<EuiFlexGroup gutterSize="xs" alignItems="center">
<EuiFlexItem grow={false}>
<EuiLoadingSpinner size="s" />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText size="xs">{this.name}</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
);
},
};
case MODEL_STATE.NOT_DOWNLOADED:
return {
color: '#d4dae5',
name: i18n.translate('xpack.ml.trainedModels.modelsList.modelState.notDownloadedName', {
defaultMessage: 'Not downloaded',
}),
};
default:
return null;
}
Expand Down
Loading