Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
0de3198
introducing trained models service to manage models download & deploy…
rbrtj Jan 2, 2025
d0078f9
rename action to Start Deployment
rbrtj Jan 2, 2025
1474865
add a queue for deployments started before the model is downloaded
rbrtj Jan 2, 2025
0d52bc0
rename State column to Model state
rbrtj Jan 2, 2025
1727e2c
model actions cleanup
rbrtj Jan 2, 2025
6f96af1
rename Delete action to Delete Model && update actions order
rbrtj Jan 2, 2025
cf1ca47
trained models service small refactor
rbrtj Jan 7, 2025
31c18e8
align error handling with previous implementation
rbrtj Jan 7, 2025
3b646de
fix trained models service flow to correctly keep track of active ope…
rbrtj Jan 7, 2025
0c0eadf
Merge remote-tracking branch 'upstream/main' into trained-models-repl…
rbrtj Jan 9, 2025
2646bef
fix loading state in trained models service
rbrtj Jan 9, 2025
b9d6c5f
ensure user can start one deployment at a time && isLoading based on …
rbrtj Jan 9, 2025
173321f
refactor trained models service and corresponding components to use m…
rbrtj Jan 10, 2025
c079ddf
cancel all request when user deletes a model after starting a download
rbrtj Jan 10, 2025
9856fe7
use withLatestFrom for polling logic
rbrtj Jan 10, 2025
27f8d9f
remove isInitialized
rbrtj Jan 10, 2025
5acf8dd
use trained models service hook - improve singletone behavior && useU…
rbrtj Jan 13, 2025
8847920
fix trained models list actions and expanding row icon buttons overla…
rbrtj Jan 13, 2025
11b951e
display deploying state
rbrtj Jan 14, 2025
a81df16
simplify startModelDeployment$
rbrtj Jan 14, 2025
7863d66
update breakpoint
rbrtj Jan 14, 2025
f73f9df
increase actions column width
rbrtj Jan 14, 2025
ac599eb
revert startModelDeployment changes
rbrtj Jan 14, 2025
ea1800a
fix requests cancelation
rbrtj Jan 14, 2025
edac0af
remove comment
rbrtj Jan 14, 2025
b3f47a5
use ModelStatusIndicator in models_list
rbrtj Jan 14, 2025
06debd4
Merge branch 'main' into trained-models-replace-download-button-by-ex…
rbrtj Jan 14, 2025
c23ad1d
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Jan 14, 2025
630e994
remove unused translations
rbrtj Jan 14, 2025
832418b
display success toast after deploying the model
rbrtj Jan 15, 2025
60129c2
Merge branch 'main' into trained-models-replace-download-button-by-ex…
rbrtj Jan 16, 2025
62b3a61
update start deployment toast messages
rbrtj Jan 21, 2025
a199de2
deployment modal: add divider, allow progress bar to take more space
rbrtj Jan 21, 2025
e651ce4
show only downloading and ready for deployment states in deployment m…
rbrtj Jan 21, 2025
0a6ff9f
update progress label inside deployment modal && update label color
rbrtj Jan 21, 2025
2399126
trained models service refactor
rbrtj Jan 30, 2025
64d3222
Merge remote-tracking branch 'upstream/main' into trained-models-repl…
rbrtj Jan 31, 2025
e88fd19
rename scheduled deployments local storage key
rbrtj Jan 31, 2025
1b14cf9
get rid of cancelDeployment$ && pipelines adjustments
rbrtj Feb 3, 2025
d0b1925
get rid of stopPolling$ subject
rbrtj Feb 3, 2025
bc3771a
trained models service basic jest tests
rbrtj Feb 3, 2025
7273c21
Merge branch 'main' into trained-models-replace-download-button-by-ex…
rbrtj Feb 3, 2025
7dd1dc9
remove unused translations && revert deployment updated success toast
rbrtj Feb 3, 2025
639e123
remove old translations
rbrtj Feb 3, 2025
08cb26f
reuse start allocation params
rbrtj Feb 4, 2025
460958e
make model status indicator unaware of its context
rbrtj Feb 4, 2025
fec55b2
rename initialScheduledDeployments to defaultScheduledDeployments var…
rbrtj Feb 4, 2025
0870ed4
remove shareReplay for modelItems$
rbrtj Feb 4, 2025
53884cb
getModels$ add isEqual to distinctUntilChanged
rbrtj Feb 4, 2025
9e0df27
rename trainedModelsService methods
rbrtj Feb 4, 2025
0ae7769
fix i18n
rbrtj Feb 4, 2025
a2f552d
refactor deployment pipelines
rbrtj Feb 4, 2025
86fde04
deployment pipelines further updates
rbrtj Feb 4, 2025
aa0601a
hasActiveOperations update
rbrtj Feb 4, 2025
5416a65
trained models service simplify destroy logic
rbrtj Feb 5, 2025
7a6d68b
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Feb 5, 2025
1adaf4b
improve naming, remove redundant check, fix comparision
rbrtj Feb 5, 2025
8ab2d3f
further trained models service improvements
rbrtj Feb 5, 2025
f6099f7
Merge branch 'main' into trained-models-replace-download-button-by-ex…
rbrtj Feb 5, 2025
12e4299
update jest tests
rbrtj Feb 6, 2025
0288a5b
disable stop deployment action while deployment hasnt started yet
rbrtj Feb 6, 2025
7131057
organize imports && remove unnecessary if check in destroy method
rbrtj Feb 7, 2025
d5a3f38
Merge branch 'main' into trained-models-replace-download-button-by-ex…
rbrtj Feb 10, 2025
dfc5a33
reduce trained models list api calls
rbrtj Feb 10, 2025
558bae7
adjust jest tests
rbrtj Feb 10, 2025
4fa439f
cleanup method include processedDeployments
rbrtj Feb 10, 2025
302723c
use merge instead of from in setupDeploymentSubscription
rbrtj Feb 10, 2025
fc1c523
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Feb 10, 2025
ba641fe
get rid of processedDeployments
rbrtj Feb 10, 2025
9d2932b
cleanup
rbrtj Feb 10, 2025
d6029a5
update jest tests
rbrtj Feb 10, 2025
dc626e9
Merge branch 'main' into trained-models-replace-download-button-by-ex…
rbrtj Feb 11, 2025
fcee9ca
add initialDataLoaded behavior subject to prevent functional tests fr…
rbrtj Feb 11, 2025
b0989f2
simplify isInitialized check
rbrtj Feb 11, 2025
File filter

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 @@ -27,15 +27,18 @@ const navigateToUrl = jest.fn().mockImplementation(async (url) => {
describe('useUnsavedChangesPrompt', () => {
let addSpy: jest.SpiedFunction<Window['addEventListener']>;
let removeSpy: jest.SpiedFunction<Window['removeEventListener']>;
let blockSpy: jest.SpiedFunction<CoreScopedHistory['block']>;

beforeEach(() => {
addSpy = jest.spyOn(window, 'addEventListener');
removeSpy = jest.spyOn(window, 'removeEventListener');
blockSpy = jest.spyOn(history, 'block');
});

afterEach(() => {
addSpy.mockRestore();
removeSpy.mockRestore();
blockSpy.mockRestore();
jest.resetAllMocks();
});

Expand Down Expand Up @@ -97,4 +100,23 @@ describe('useUnsavedChangesPrompt', () => {
expect(addSpy).toBeCalledWith('beforeunload', expect.anything());
expect(removeSpy).toBeCalledWith('beforeunload', expect.anything());
});

it('should not block SPA navigation if blockSpaNavigation is false', async () => {
renderHook(() =>
useUnsavedChangesPrompt({
hasUnsavedChanges: true,
blockSpaNavigation: false,
})
);

expect(addSpy).toBeCalledWith('beforeunload', expect.anything());

act(() => history.push('/test'));

expect(coreStart.overlays.openConfirm).not.toBeCalled();

expect(history.location.pathname).toBe('/test');

expect(blockSpy).not.toBeCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ const DEFAULT_CONFIRM_BUTTON = i18n.translate('unsavedChangesPrompt.defaultModal
defaultMessage: 'Leave page',
});

interface Props {
interface BaseProps {
hasUnsavedChanges: boolean;
}

interface SpaBlockingProps extends BaseProps {
http: HttpStart;
openConfirm: OverlayStart['openConfirm'];
history: ScopedHistory;
Expand All @@ -38,20 +41,21 @@ interface Props {
messageText?: string;
cancelButtonText?: string;
confirmButtonText?: string;
blockSpaNavigation?: true;
}

interface BrowserBlockingProps extends BaseProps {
blockSpaNavigation: false;
}

export const useUnsavedChangesPrompt = ({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This is just a proposal, so it is possible to use useUnsavedChangesPrompt without blocking SPA navigation. If you don't like the implementation, we can separate the relevant part of the hook into our package

hasUnsavedChanges,
openConfirm,
history,
http,
navigateToUrl,
// Provide overrides for confirm dialog
messageText = DEFAULT_BODY_TEXT,
titleText = DEFAULT_TITLE_TEXT,
confirmButtonText = DEFAULT_CONFIRM_BUTTON,
cancelButtonText = DEFAULT_CANCEL_BUTTON,
}: Props) => {
type Props = SpaBlockingProps | BrowserBlockingProps;

const isSpaBlocking = (props: Props): props is SpaBlockingProps =>
props.blockSpaNavigation !== false;

export const useUnsavedChangesPrompt = (props: Props) => {
const { hasUnsavedChanges, blockSpaNavigation = true } = props;

useEffect(() => {
if (hasUnsavedChanges) {
const handler = (event: BeforeUnloadEvent) => {
Expand All @@ -67,10 +71,22 @@ export const useUnsavedChangesPrompt = ({
}, [hasUnsavedChanges]);

useEffect(() => {
if (!hasUnsavedChanges) {
if (!hasUnsavedChanges || !isSpaBlocking(props)) {
return;
}

const {
openConfirm,
http,
history,
navigateToUrl,
// Provide overrides for confirm dialog
messageText = DEFAULT_BODY_TEXT,
titleText = DEFAULT_TITLE_TEXT,
confirmButtonText = DEFAULT_CONFIRM_BUTTON,
cancelButtonText = DEFAULT_CANCEL_BUTTON,
} = props;

const unblock = history.block((state) => {
async function confirmAsync() {
const confirmResponse = await openConfirm(messageText, {
Expand All @@ -97,15 +113,5 @@ export const useUnsavedChangesPrompt = ({
});

return unblock;
}, [
history,
hasUnsavedChanges,
openConfirm,
navigateToUrl,
http.basePath,
titleText,
cancelButtonText,
confirmButtonText,
messageText,
]);
}, [hasUnsavedChanges, blockSpaNavigation, props]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -27054,7 +27054,6 @@
"xpack.ml.indexDatavisualizer.actionsPanel.dataframeTitle": "Analyse du cadre de données",
"xpack.ml.inference.modelsList.analyticsMapActionLabel": "Mapping d'analyse",
"xpack.ml.inference.modelsList.analyzeDataDriftLabel": "Analyser la dérive de données",
"xpack.ml.inference.modelsList.downloadModelActionLabel": "Télécharger",
"xpack.ml.inference.modelsList.startModelDeploymentActionDescription": "Démarrer le déploiement",
"xpack.ml.inference.modelsList.startModelDeploymentActionLabel": "Déployer",
"xpack.ml.inference.modelsList.stopModelDeploymentActionLabel": "Arrêter le déploiement",
Expand Down Expand Up @@ -28840,14 +28839,9 @@
"xpack.ml.trainedModels.modelsList.startDeployment.vCULevel": "Sélecteur de niveau des VCU",
"xpack.ml.trainedModels.modelsList.startDeployment.vCUUsageLabel": "Niveau d'utilisation du VCU",
"xpack.ml.trainedModels.modelsList.startDeployment.viewElserDocLink": "Afficher la documentation",
"xpack.ml.trainedModels.modelsList.startFailed": "Impossible de démarrer \"{modelId}\"",
"xpack.ml.trainedModels.modelsList.stateHeader": "État",
"xpack.ml.trainedModels.modelsList.stopDeploymentWarning": "Impossible d'arrêter \"{deploymentId}\"",
"xpack.ml.trainedModels.modelsList.stopFailed": "Impossible d'arrêter \"{modelId}\"",
"xpack.ml.trainedModels.modelsList.totalAmountLabel": "Total de modèles entraînés",
"xpack.ml.trainedModels.modelsList.updateDeployment.modalTitle": "Mettre à jour le déploiement {modelId}",
"xpack.ml.trainedModels.modelsList.updateFailed": "Impossible de mettre à jour \"{modelId}\"",
"xpack.ml.trainedModels.modelsList.updateSuccess": "Le déploiement pour \"{modelId}\" a bien été mis à jour.",
"xpack.ml.trainedModels.modelsList.viewTrainingDataActionLabel": "Les données d'entraînement peuvent être consultées lorsque la tâche d'analyse du cadre de données existe.",
"xpack.ml.trainedModels.modelsList.viewTrainingDataNameActionLabel": "Afficher les données d'entraînement",
"xpack.ml.trainedModels.nodesList.adMemoryUsage": "Tâches de détection des anomalies",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26921,7 +26921,6 @@
"xpack.ml.indexDatavisualizer.actionsPanel.dataframeTitle": "データフレーム分析",
"xpack.ml.inference.modelsList.analyticsMapActionLabel": "分析マップ",
"xpack.ml.inference.modelsList.analyzeDataDriftLabel": "データドリフトを分析",
"xpack.ml.inference.modelsList.downloadModelActionLabel": "ダウンロード",
"xpack.ml.inference.modelsList.startModelDeploymentActionDescription": "デプロイを開始",
"xpack.ml.inference.modelsList.startModelDeploymentActionLabel": "デプロイ",
"xpack.ml.inference.modelsList.stopModelDeploymentActionLabel": "デプロイを停止",
Expand Down Expand Up @@ -28705,14 +28704,9 @@
"xpack.ml.trainedModels.modelsList.startDeployment.vCULevel": "VCUレベルセレクター",
"xpack.ml.trainedModels.modelsList.startDeployment.vCUUsageLabel": "VCU使用率レベル",
"xpack.ml.trainedModels.modelsList.startDeployment.viewElserDocLink": "ドキュメンテーションを表示",
"xpack.ml.trainedModels.modelsList.startFailed": "\"{modelId}\"の開始に失敗しました",
"xpack.ml.trainedModels.modelsList.stateHeader": "ステータス",
"xpack.ml.trainedModels.modelsList.stopDeploymentWarning": "\"{deploymentId}\"を停止できませんでした",
"xpack.ml.trainedModels.modelsList.stopFailed": "\"{modelId}\"の停止に失敗しました",
"xpack.ml.trainedModels.modelsList.totalAmountLabel": "学習済みモデルの合計数",
"xpack.ml.trainedModels.modelsList.updateDeployment.modalTitle": "{modelId}デプロイを更新",
"xpack.ml.trainedModels.modelsList.updateFailed": "\"{modelId}\"を更新できませんでした",
"xpack.ml.trainedModels.modelsList.updateSuccess": "\"{modelId}\"のデプロイが正常に更新されました。",
"xpack.ml.trainedModels.modelsList.viewTrainingDataActionLabel": "データフレーム分析ジョブが存在する場合、学習データを表示できます。",
"xpack.ml.trainedModels.modelsList.viewTrainingDataNameActionLabel": "学習データを表示",
"xpack.ml.trainedModels.nodesList.adMemoryUsage": "異常検知ジョブ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26480,7 +26480,6 @@
"xpack.ml.indexDatavisualizer.actionsPanel.dataframeTitle": "数据帧分析",
"xpack.ml.inference.modelsList.analyticsMapActionLabel": "分析地图",
"xpack.ml.inference.modelsList.analyzeDataDriftLabel": "分析数据偏移",
"xpack.ml.inference.modelsList.downloadModelActionLabel": "下载",
"xpack.ml.inference.modelsList.startModelDeploymentActionDescription": "开始部署",
"xpack.ml.inference.modelsList.startModelDeploymentActionLabel": "部署",
"xpack.ml.inference.modelsList.stopModelDeploymentActionLabel": "停止部署",
Expand Down
6 changes: 6 additions & 0 deletions x-pack/platform/plugins/shared/ml/common/types/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import type { MlEntityFieldType } from '@kbn/ml-anomaly-utils';
import type { FrozenTierPreference } from '@kbn/ml-date-picker';
import type { StartAllocationParams } from '../../public/application/services/ml_api_service/trained_models';

export const ML_ENTITY_FIELDS_CONFIG = 'ml.singleMetricViewer.partitionFields' as const;
export const ML_APPLY_TIME_RANGE_CONFIG = 'ml.jobSelectorFlyout.applyTimeRange';
Expand All @@ -16,6 +17,7 @@ export const ML_ANOMALY_EXPLORER_PANELS = 'ml.anomalyExplorerPanels';
export const ML_NOTIFICATIONS_LAST_CHECKED_AT = 'ml.notificationsLastCheckedAt';
export const ML_OVERVIEW_PANELS = 'ml.overviewPanels';
export const ML_ELSER_CALLOUT_DISMISSED = 'ml.elserUpdateCalloutDismissed';
export const ML_SCHEDULED_MODEL_DEPLOYMENTS = 'ml.trainedModels.scheduledModelDeployments';

export type PartitionFieldConfig =
| {
Expand Down Expand Up @@ -71,6 +73,7 @@ export interface MlStorageRecord {
[ML_NOTIFICATIONS_LAST_CHECKED_AT]: number | undefined;
[ML_OVERVIEW_PANELS]: OverviewPanelsState;
[ML_ELSER_CALLOUT_DISMISSED]: boolean | undefined;
[ML_SCHEDULED_MODEL_DEPLOYMENTS]: StartAllocationParams[];
}

export type MlStorage = Partial<MlStorageRecord> | null;
Expand All @@ -93,6 +96,8 @@ export type TMlStorageMapped<T extends MlStorageKey> = T extends typeof ML_ENTIT
? OverviewPanelsState | undefined
: T extends typeof ML_ELSER_CALLOUT_DISMISSED
? boolean | undefined
: T extends typeof ML_SCHEDULED_MODEL_DEPLOYMENTS
? string[] | undefined
: null;

export const ML_STORAGE_KEYS = [
Expand All @@ -104,4 +109,5 @@ export const ML_STORAGE_KEYS = [
ML_NOTIFICATIONS_LAST_CHECKED_AT,
ML_OVERVIEW_PANELS,
ML_ELSER_CALLOUT_DISMISSED,
ML_SCHEDULED_MODEL_DEPLOYMENTS,
] as const;
Loading