Skip to content

Commit

Permalink
feat: add checkModelService API & fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Lanture1064 committed Dec 26, 2023
1 parent 249850e commit 248d4f2
Show file tree
Hide file tree
Showing 11 changed files with 279 additions and 12 deletions.
155 changes: 155 additions & 0 deletions apiserver/graph/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apiserver/graph/generated/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions apiserver/graph/impl/modelservice.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions apiserver/graph/schema/modelservice.gql
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ mutation createModelService($input: CreateModelServiceInput!) {
status
message
}
resource {
cpu
nvidiaGPU
memory
}
}
}
}
Expand Down Expand Up @@ -92,6 +97,11 @@ mutation updateModelService($input: UpdateModelServiceInput) {
status
message
}
resource {
cpu
nvidiaGPU
memory
}
}
}
}
Expand Down Expand Up @@ -215,4 +225,15 @@ query listModelServices($input: ListModelService) {
}
}
}
}

query checkModelService($input: CreateModelServiceInput!) {
ModelService {
checkModelService(input: $input) {
name
namespace
apiType
description
}
}
}
1 change: 1 addition & 0 deletions apiserver/graph/schema/modelservice.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ extend type Mutation {
type ModelServiceQuery {
getModelService(name: String!, namespace: String!, apiType: String!): ModelService
listModelServices(input: ListModelService): PaginatedResult!
checkModelService(input: CreateModelServiceInput!): ModelService!
}

extend type Query {
Expand Down
2 changes: 2 additions & 0 deletions apiserver/pkg/embedder/embedder.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func CreateEmbedder(ctx context.Context, c dynamic.Interface, input generated.Cr
// create auth secret
secret := common.MakeAuthSecretName(embedder.Name, "embedder")
err := common.MakeAuthSecret(ctx, c, generated.TypedObjectReferenceInput{
Kind: "Secret",
Name: secret,
Namespace: &input.Namespace,
}, input.Endpointinput.Auth, nil)
Expand Down Expand Up @@ -153,6 +154,7 @@ func CreateEmbedder(ctx context.Context, c dynamic.Interface, input generated.Cr
// user obj as the owner
secret := common.MakeAuthSecretName(embedder.Name, "embedder")
err := common.MakeAuthSecret(ctx, c, generated.TypedObjectReferenceInput{
Kind: "Secret",
Name: secret,
Namespace: &input.Namespace,
}, input.Endpointinput.Auth, obj)
Expand Down
6 changes: 4 additions & 2 deletions apiserver/pkg/llm/llm.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func CreateLLM(ctx context.Context, c dynamic.Interface, input generated.CreateL
if input.Endpointinput.Auth != nil {
secret := common.MakeAuthSecretName(llm.Name, "llm")
err := common.MakeAuthSecret(ctx, c, generated.TypedObjectReferenceInput{
Kind: "Secret",
Name: secret,
Namespace: &input.Namespace,
}, input.Endpointinput.Auth, nil)
Expand All @@ -218,7 +219,7 @@ func CreateLLM(ctx context.Context, c dynamic.Interface, input generated.CreateL
return nil, err
}

obj, err := c.Resource(schema.GroupVersionResource{Group: v1alpha1.GroupVersion.Group, Version: v1alpha1.GroupVersion.Version, Resource: "LLM"}).
obj, err := c.Resource(schema.GroupVersionResource{Group: v1alpha1.GroupVersion.Group, Version: v1alpha1.GroupVersion.Version, Resource: "llms"}).
Namespace(input.Namespace).Create(ctx, &unstructured.Unstructured{Object: unstructuredLLM}, metav1.CreateOptions{})
if err != nil {
return nil, err
Expand All @@ -229,6 +230,7 @@ func CreateLLM(ctx context.Context, c dynamic.Interface, input generated.CreateL
// user obj as the owner
secret := common.MakeAuthSecretName(llm.Name, "LLM")
err := common.MakeAuthSecret(ctx, c, generated.TypedObjectReferenceInput{
Kind: "Secret",
Name: secret,
Namespace: &input.Namespace,
}, input.Endpointinput.Auth, obj)
Expand Down Expand Up @@ -271,7 +273,7 @@ func DeleteLLMs(ctx context.Context, c dynamic.Interface, input *generated.Delet
labelSelector = *input.LabelSelector
}

resource := c.Resource(schema.GroupVersionResource{Group: v1alpha1.GroupVersion.Group, Version: v1alpha1.GroupVersion.Version, Resource: "LLMs"})
resource := c.Resource(schema.GroupVersionResource{Group: v1alpha1.GroupVersion.Group, Version: v1alpha1.GroupVersion.Version, Resource: "llms"})
if name != "" {
err := resource.Namespace(input.Namespace).Delete(ctx, name, metav1.DeleteOptions{})
if err != nil {
Expand Down
Loading

0 comments on commit 248d4f2

Please sign in to comment.