Skip to content

Commit 33a018a

Browse files
committed
more
1 parent 145abf8 commit 33a018a

File tree

9 files changed

+84
-11
lines changed

9 files changed

+84
-11
lines changed

packages/maas/bff/internal/models/maasmodelref.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ type CreateMaaSModelRefRequest struct {
77
ModelRef ModelReference `json:"modelRef"`
88
EndpointOverride string `json:"endpointOverride,omitempty"`
99
Uid string `json:"uid,omitempty"`
10+
DisplayName string `json:"displayName,omitempty"`
11+
Description string `json:"description,omitempty"`
1012
}
1113

1214
// UpdateMaaSModelRefRequest is the request body for updating an existing MaaSModelRef.
1315
type UpdateMaaSModelRefRequest struct {
1416
ModelRef ModelReference `json:"modelRef"`
1517
EndpointOverride string `json:"endpointOverride,omitempty"`
18+
DisplayName string `json:"displayName,omitempty"`
19+
Description string `json:"description,omitempty"`
1620
}

packages/maas/bff/internal/models/subscription.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ type ModelReference struct {
8080

8181
// MaaSModelRefSummary is the BFF representation of a MaaSModelRef CR.
8282
type MaaSModelRefSummary struct {
83-
Name string `json:"name"`
84-
Namespace string `json:"namespace"`
85-
ModelRef ModelReference `json:"modelRef"`
86-
Phase string `json:"phase,omitempty"`
87-
Endpoint string `json:"endpoint,omitempty"`
83+
Name string `json:"name"`
84+
Namespace string `json:"namespace"`
85+
ModelRef ModelReference `json:"modelRef"`
86+
Phase string `json:"phase,omitempty"`
87+
Endpoint string `json:"endpoint,omitempty"`
88+
DisplayName string `json:"displayName,omitempty"`
89+
Description string `json:"description,omitempty"`
8890
}
8991

9092
// CreateSubscriptionRequest is the request body for creating a new subscription.

packages/maas/bff/internal/repositories/maasmodelrefs.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (r *MaaSModelRefsRepository) CreateMaaSModelRef(ctx context.Context, reques
4040

4141
kubeClient := client.GetDynamicClient()
4242

43-
obj := buildModelRefUnstructured(request.Name, request.Namespace, request.ModelRef, request.EndpointOverride, request.Uid)
43+
obj := buildModelRefUnstructured(request.Name, request.Namespace, request.ModelRef, request.EndpointOverride, request.Uid, request.DisplayName, request.Description)
4444
created, err := kubeClient.Resource(constants.MaaSModelRefGvr).Namespace(request.Namespace).Create(ctx, obj, metav1.CreateOptions{})
4545
if err != nil {
4646
if k8sErrors.IsAlreadyExists(err) {
@@ -82,6 +82,22 @@ func (r *MaaSModelRefsRepository) UpdateMaaSModelRef(ctx context.Context, namesp
8282
if request.EndpointOverride != "" {
8383
existingSpec["endpointOverride"] = request.EndpointOverride
8484
}
85+
86+
annotations := existing.GetAnnotations()
87+
if annotations == nil {
88+
annotations = map[string]string{}
89+
}
90+
if request.DisplayName != "" {
91+
annotations[displayNameAnnotation] = request.DisplayName
92+
} else {
93+
delete(annotations, displayNameAnnotation)
94+
}
95+
if request.Description != "" {
96+
annotations[descriptionAnnotation] = request.Description
97+
} else {
98+
delete(annotations, descriptionAnnotation)
99+
}
100+
existing.SetAnnotations(annotations)
85101
existing.Object["spec"] = existingSpec
86102

87103
updated, err := kubeClient.Resource(constants.MaaSModelRefGvr).Namespace(namespace).Update(ctx, existing, metav1.UpdateOptions{})
@@ -113,7 +129,7 @@ func (r *MaaSModelRefsRepository) DeleteMaaSModelRef(ctx context.Context, namesp
113129
return nil
114130
}
115131

116-
func buildModelRefUnstructured(name, namespace string, modelRef models.ModelReference, endpointOverride string, uid string) *unstructured.Unstructured {
132+
func buildModelRefUnstructured(name, namespace string, modelRef models.ModelReference, endpointOverride string, uid string, displayName string, description string) *unstructured.Unstructured {
117133
obj := &unstructured.Unstructured{}
118134
obj.SetAPIVersion("maas.opendatahub.io/v1alpha1")
119135
obj.SetKind("MaaSModelRef")
@@ -128,6 +144,10 @@ func buildModelRefUnstructured(name, namespace string, modelRef models.ModelRefe
128144
BlockOwnerDeletion: &[]bool{false}[0],
129145
},
130146
})
147+
obj.SetAnnotations(map[string]string{
148+
"openshift.io/display-name": displayName,
149+
"openshift.io/description": description,
150+
})
131151

132152
spec := map[string]interface{}{
133153
"modelRef": map[string]interface{}{

packages/maas/bff/internal/repositories/subscriptions.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ import (
1515
"github.com/opendatahub-io/maas-library/bff/internal/models"
1616
)
1717

18+
const (
19+
displayNameAnnotation = "openshift.io/display-name"
20+
descriptionAnnotation = "openshift.io/description"
21+
)
22+
1823
// SubscriptionsRepository handles subscription operations via the Kubernetes API.
1924
type SubscriptionsRepository struct {
2025
logger *slog.Logger
@@ -489,6 +494,9 @@ func convertUnstructuredToModelRefSummary(obj *unstructured.Unstructured) (*mode
489494
Name: obj.GetName(),
490495
Namespace: obj.GetNamespace(),
491496
}
497+
annotations := obj.GetAnnotations()
498+
summary.DisplayName = annotations[displayNameAnnotation]
499+
summary.Description = annotations[descriptionAnnotation]
492500

493501
kind, _, _ := unstructured.NestedString(content, "spec", "modelRef", "kind")
494502
name, _, _ := unstructured.NestedString(content, "spec", "modelRef", "name")

packages/maas/bff/openapi.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,14 @@ components:
14871487
type: string
14881488
description: Endpoint URL for the model (from status)
14891489
example: https://llama-2-7b-chat.example.com
1490+
displayName:
1491+
type: string
1492+
description: Human-readable display name (from openshift.io/display-name annotation)
1493+
example: Llama 2 7B Chat
1494+
description:
1495+
type: string
1496+
description: Human-readable description (from openshift.io/description annotation)
1497+
example: A conversational language model fine-tuned for chat use cases
14901498
required:
14911499
- name
14921500
- namespace
@@ -1626,6 +1634,14 @@ components:
16261634
type: string
16271635
description: UID of the OwnerReference Resource
16281636
example: ""
1637+
displayName:
1638+
type: string
1639+
description: Human-readable display name stored as openshift.io/display-name annotation
1640+
example: Granite 3 8B Instruct
1641+
description:
1642+
type: string
1643+
description: Human-readable description stored as openshift.io/description annotation
1644+
example: A high-performance instruction-tuned language model
16291645
required:
16301646
- name
16311647
- namespace
@@ -1641,5 +1657,13 @@ components:
16411657
type: string
16421658
description: Optional endpoint URL override
16431659
example: ""
1660+
displayName:
1661+
type: string
1662+
description: Human-readable display name stored as openshift.io/display-name annotation
1663+
example: Granite 3 8B Instruct
1664+
description:
1665+
type: string
1666+
description: Human-readable description stored as openshift.io/description annotation
1667+
example: A high-performance instruction-tuned language model
16441668
required:
16451669
- modelRef

packages/maas/frontend/src/app/api/maas-models.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export const createMaaSModelRef =
5353
namespace: '',
5454
modelRef: { kind: '', name: '' },
5555
uid: '',
56+
displayName: '',
57+
description: '',
5658
},
5759
) =>
5860
(opts: APIOptions): Promise<MaaSModelRef> =>
@@ -70,7 +72,9 @@ export const updateMaaSModelRef =
7072
(
7173
namespace: string,
7274
name: string,
73-
requestBody: UpdateMaaSModelRefRequest = { modelRef: { kind: '', name: '' } },
75+
requestBody: UpdateMaaSModelRefRequest = {
76+
modelRef: { kind: '', name: '' },
77+
},
7478
hostPath = '',
7579
) =>
7680
(opts: APIOptions): Promise<MaaSModelRef> =>

packages/maas/frontend/src/app/types/maas-model.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export type MaaSModelRef = {
1414
modelRef: ModelReference;
1515
phase?: string;
1616
endpoint?: string;
17+
displayName?: string;
18+
description?: string;
1719
};
1820

1921
export type ModelReference = {
@@ -27,11 +29,15 @@ export type CreateMaaSModelRefRequest = {
2729
modelRef: ModelReference;
2830
endpointOverride?: string;
2931
uid?: string;
32+
displayName?: string;
33+
description?: string;
3034
};
3135

3236
export type UpdateMaaSModelRefRequest = {
3337
modelRef: ModelReference;
3438
endpointOverride?: string;
39+
displayName?: string;
40+
description?: string;
3541
};
3642

3743
export type DeleteMaaSModelRefResponse = {

packages/maas/frontend/src/odh/modelServingExtensions/modelDeploymentWizard/MaaSModelRef.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { LLMdDeployment } from '@odh-dashboard/llmd-serving/types';
22
import { createMaaSModelRef, deleteMaaSModelRef, updateMaaSModelRef } from '~/app/api/maas-models';
33
import type { MaaSFieldValue } from './MaaSEndpointCheckbox';
44

5-
const LLMINFERENCESERVICE_KIND = 'llmisvc';
5+
const LLMINFERENCESERVICE_KIND = 'LLMInferenceService';
66

77
/**
88
* Post-deploy extension for the MaaS checkbox field.
@@ -25,6 +25,8 @@ export const applyMaaSModelRef = async (
2525
const { name, namespace, uid } = deployedModel.metadata;
2626
const { isChecked } = fieldData;
2727
const modelRef = { kind: LLMINFERENCESERVICE_KIND, name };
28+
const displayName = deployedModel.metadata.annotations?.['openshift.io/display-name'] ?? name;
29+
const description = deployedModel.metadata.annotations?.['openshift.io/description'] ?? '';
2830

2931
if (existingDeployment) {
3032
if (!isChecked) {
@@ -39,7 +41,7 @@ export const applyMaaSModelRef = async (
3941
}
4042
} else {
4143
try {
42-
await updateMaaSModelRef(namespace, name, { modelRef })({});
44+
await updateMaaSModelRef(namespace, name, { modelRef, displayName, description })({});
4345
} catch (err) {
4446
// If the MaaSModelRef was somehow removed externally, create it fresh
4547
const message = err instanceof Error ? err.message : String(err);
@@ -49,6 +51,8 @@ export const applyMaaSModelRef = async (
4951
namespace,
5052
modelRef,
5153
uid,
54+
displayName,
55+
description,
5256
})({});
5357
} else {
5458
throw err;
@@ -61,6 +65,8 @@ export const applyMaaSModelRef = async (
6165
namespace,
6266
modelRef,
6367
uid,
68+
displayName,
69+
description,
6470
})({});
6571
}
6672
};

packages/model-serving/src/components/deploymentWizard/ModelDeploymentWizard.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ const ModelDeploymentWizard: React.FC<ModelDeploymentWizardProps> = ({
6565
project?.metadata.name,
6666
externalData,
6767
);
68-
console.log('wizardFormData', wizardFormData);
6968
const validation = useModelDeploymentWizardValidation(
7069
wizardFormData.state,
7170
wizardFormData.fields,

0 commit comments

Comments
 (0)