Skip to content

Commit

Permalink
mwa(front): Fix predictor's runtime property in all instances (#64)
Browse files Browse the repository at this point in the history
* mwa(front): Fix a typo in PredictorType

Fix a typo in PredictorType enumeration.

Signed-off-by: Elena Zioga <elena@arrikto.com>

* mwa(front): Introduce functions to get the right runtime

In this commit, we introduce two new functions so that to get the right
runtime based on the following:

- If the spec.predictor is model then the runtime is under
  spec.predictor.model.runtime
- Else we hardcode the runtime values by taking into account the
  predictor type and the protocol version

Signed-off-by: Elena Zioga <elena@arrikto.com>

* mwa(front): Fix Runtime property in Overview tab

Fix predictor's runtime property in Overview tab. Now both runtime and
runtime version values are displayed.

Signed-off-by: Elena Zioga <elena@arrikto.com>

* mwa(front): Fix Runtime property in Details tab

Fix predictor's runtime property in Details tab. Now both runtime and
runtime version values are displayed.

Signed-off-by: Elena Zioga <elena@arrikto.com>

---------

Signed-off-by: Elena Zioga <elena@arrikto.com>
  • Loading branch information
elenzio9 committed Mar 2, 2023
1 parent 87cea4f commit 4dc5b12
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 26 deletions.
4 changes: 3 additions & 1 deletion frontend/src/app/pages/index/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from 'kubeflow';
import { StorageUriColumnComponent } from 'src/app/shared/storage-uri-column/storage-uri-column.component';
import { getPredictorExtensionSpec } from 'src/app/shared/utils';
import { parseRuntime } from 'src/app/shared/utils';
import { InferenceServiceK8s } from 'src/app/types/kfserving/v1beta1';

export function generateDeleteConfig(svc: InferenceServiceK8s): DialogConfig {
Expand Down Expand Up @@ -65,7 +66,8 @@ export const defaultConfig: TableConfig = {
matHeaderCellDef: $localize`Runtime`,
matColumnDef: 'runtimeVersion',
value: new PropertyValue({
field: 'ui.runtimeVersion',
valueFn: parseRuntime,
popoverField: 'ui.runtimeVersion',
}),
sort: true,
},
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/pages/index/index.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,10 @@ export class IndexComponent implements OnInit, OnDestroy {

const predictorType = getPredictorType(svc.spec.predictor);
const predictor = getPredictorExtensionSpec(svc.spec.predictor);

svc.ui.predictorType = predictorType;
svc.ui.runtimeVersion = predictor.runtimeVersion;
svc.ui.storageUri = predictor.storageUri;
svc.ui.protocolVersion = predictor.protocolVersion;
svc.ui.protocolVersion = predictor.protocolVersion || 'v1';
svc.ui.link = {
text: svc.metadata.name,
url: `/details/${this.currNamespace}/${svc.metadata.name}`,
Expand Down
12 changes: 0 additions & 12 deletions frontend/src/app/pages/index/utils.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
{{ predictorType }}
</lib-details-list-item>

<lib-details-list-item key="Runtime" *ngIf="basePredictor?.runtimeVersion">
<lib-details-list-item key="Runtime">
{{ predictorRuntime }}
</lib-details-list-item>

<lib-details-list-item
key="Runtime Version"
*ngIf="basePredictor?.runtimeVersion"
>
{{ basePredictor.runtimeVersion }}
</lib-details-list-item>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from 'src/app/types/kfserving/v1beta1';
import {
getPredictorExtensionSpec,
getPredictorRuntime,
getPredictorType,
} from 'src/app/shared/utils';

Expand All @@ -23,4 +24,8 @@ export class PredictorDetailsComponent {
get predictorType(): string {
return getPredictorType(this.predictorSpec);
}

get predictorRuntime(): string {
return getPredictorRuntime(this.predictorSpec);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@
{{ predictorType }}
</lib-details-list-item>

<lib-details-list-item key="Runtime" *ngIf="basePredictor?.runtimeVersion">
<lib-details-list-item key="Runtime">
{{ predictorRuntime }}
</lib-details-list-item>

<lib-details-list-item
key="Runtime Version"
*ngIf="basePredictor?.runtimeVersion"
>
{{ basePredictor.runtimeVersion }}
</lib-details-list-item>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { Component, Input } from '@angular/core';
import { ListEntry, ChipDescriptor } from 'kubeflow';
import {
NamespaceService,
ListEntry,
ChipDescriptor,
K8sObject,
} from 'kubeflow';
import {
getReadyCondition,
getPredictorType,
getK8sObjectStatus,
getPredictorExtensionSpec,
getPredictorRuntime,
} from 'src/app/shared/utils';
import {
InferenceServiceK8s,
Expand Down Expand Up @@ -84,6 +79,10 @@ export class OverviewComponent {
return getPredictorType(this.svc.spec.predictor);
}

get predictorRuntime(): string {
return getPredictorRuntime(this.svc.spec.predictor);
}

private generateDefaultComponents(
svc: InferenceServiceK8s,
): ChipDescriptor[] {
Expand Down
52 changes: 51 additions & 1 deletion frontend/src/app/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export function getPredictorExtensionSpec(
spec.runtimeVersion = '';
spec.protocolVersion = '';

if (predictor.containers[0].env) {
if (predictor.containers[0]?.env) {
const storageUri = predictor.containers[0].env.find(
envVar => envVar.name.toLowerCase() === 'storage_uri',
);
Expand All @@ -171,3 +171,53 @@ export function getExplainerContainer(explainer: ExplainerSpec): V1Container {

return null;
}

export function parseRuntime(svc: InferenceServiceK8s): string {
return getPredictorRuntime(svc.spec.predictor);
}

export function getPredictorRuntime(predictor: PredictorSpec): string {
if (predictor === null) {
return '';
}

if (predictor?.model?.runtime) {
return predictor.model.runtime;
}

const predictorType = getPredictorType(predictor);

if (
predictorType === PredictorType.Triton ||
predictorType === PredictorType.Onnx
) {
return 'Triton Inference Server';
}
if (predictorType === PredictorType.Tensorflow) {
return 'TFServing';
}
if (predictorType === PredictorType.Pytorch) {
return 'TorchServe';
}
if (predictorType === PredictorType.Sklearn) {
if (predictor.sklearn?.protocolVersion === 'v2') {
return 'SKLearn MLServer';
}
return 'SKLearn ModelServer';
}
if (predictorType === PredictorType.Xgboost) {
if (predictor.xgboost?.protocolVersion === 'v2') {
return 'XGBoost MLServer';
}
return 'XGBoost ModelServer';
}
if (predictorType === PredictorType.Pmml) {
return 'PMML ModelServer';
}
if (predictorType === PredictorType.Lightgbm) {
return 'LightGBM ModelServer';
}
if (predictorType === PredictorType.Custom) {
return 'Custom ModelServer';
}
}
2 changes: 1 addition & 1 deletion frontend/src/app/types/kfserving/v1beta1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface InferenceServiceSpec {
export enum PredictorType {
Tensorflow = 'tensorflow',
Triton = 'triton',
Sklean = 'sklearn',
Sklearn = 'sklearn',
Onnx = 'onnx',
Pytorch = 'pytorch',
Xgboost = 'xgboost',
Expand Down

0 comments on commit 4dc5b12

Please sign in to comment.