Skip to content

Commit

Permalink
[ML] Fix model size stats. (#121958)
Browse files Browse the repository at this point in the history
The API for model size stats changed attributes and structure. This picks up the changes to fix the display of model sizes on the ML overview page and model management page.
  • Loading branch information
walterra authored Dec 23, 2021
1 parent ee13980 commit 058caf8
Show file tree
Hide file tree
Showing 6 changed files with 420 additions and 356 deletions.
8 changes: 7 additions & 1 deletion x-pack/plugins/ml/common/types/trained_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export interface IngestStats {
failed: number;
}

export interface TrainedModelModelSizeStats {
model_size_bytes: number;
required_native_memory_bytes: number;
}

export interface TrainedModelStat {
model_id?: string;
pipeline_count?: number;
Expand Down Expand Up @@ -46,6 +51,7 @@ export interface TrainedModelStat {
>;
};
deployment_stats?: Omit<TrainedModelDeploymentStatsResponse, 'model_id'>;
model_size_stats?: TrainedModelModelSizeStats;
}

type TreeNode = object;
Expand Down Expand Up @@ -126,7 +132,6 @@ export interface InferenceConfigResponse {

export interface TrainedModelDeploymentStatsResponse {
model_id: string;
model_size_bytes: number;
inference_threads: number;
model_threads: number;
state: DeploymentState;
Expand Down Expand Up @@ -170,6 +175,7 @@ export interface AllocatedModel {
state: string;
model_threads: number;
model_size_bytes: number;
required_native_memory_bytes: number;
node: {
/**
* Not required for rendering in the Nodes overview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,15 @@ export const ExpandedRow: FC<ExpandedRowProps> = ({ item }) => {
function updateModelItems() {
(async function () {
const deploymentStats = stats.deployment_stats;
const modelSizeStats = stats.model_size_stats;

if (!deploymentStats) return;
if (!deploymentStats || !modelSizeStats) return;

const items: AllocatedModel[] = deploymentStats.nodes.map((n) => {
const nodeName = Object.values(n.node)[0].name;
return {
...deploymentStats,
...modelSizeStats,
node: {
...pick(n, [
'average_inference_time_ms',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const AllocatedModels: FC<AllocatedModelsProps> = ({
truncateText: true,
'data-test-subj': 'mlAllocatedModelsTableSize',
render: (v: AllocatedModel) => {
return bytesFormatter(v.model_size_bytes);
return bytesFormatter(v.required_native_memory_bytes);
},
},
{
Expand Down
Loading

0 comments on commit 058caf8

Please sign in to comment.