Skip to content

Commit

Permalink
chore: Update auth gql & related pkg
Browse files Browse the repository at this point in the history
Signed-off-by: Lanture1064 <[email protected]>
  • Loading branch information
Lanture1064 committed Dec 22, 2023
1 parent 09de386 commit bc4fde5
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 78 deletions.
56 changes: 2 additions & 54 deletions apiserver/graph/generated/generated.go

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

7 changes: 1 addition & 6 deletions apiserver/graph/generated/models_gen.go

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

7 changes: 1 addition & 6 deletions apiserver/graph/schema/entrypoint.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ input EndpointInput {
"""地址(必填)"""
url: String!
"""secret验证密码"""
auth: AuthInput
auth: Map
"""默认true"""
insecure: Boolean
}

input AuthInput {
username: String!
password: String!
}

input ListCommonInput {
namespace: String!

Expand Down
60 changes: 60 additions & 0 deletions apiserver/graph/schema/modelservice.gql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,36 @@ mutation createModelService($input: CreateModelServiceInput!) {
apiType
creationTimestamp
updateTimestamp
llmResource {
name
namespace
labels
annotations
displayName
description
baseUrl
models
provider
type
updateTimestamp
status
message
}
embedderResource {
name
namespace
labels
annotations
displayName
description
type
baseUrl
models
provider
updateTimestamp
status
message
}
}
}
}
Expand All @@ -32,6 +62,36 @@ mutation updateModelService($input: UpdateModelServiceInput) {
apiType
creationTimestamp
updateTimestamp
llmResource {
name
namespace
labels
annotations
displayName
description
baseUrl
models
provider
type
updateTimestamp
status
message
}
embedderResource {
name
namespace
labels
annotations
displayName
description
type
baseUrl
models
provider
updateTimestamp
status
message
}
}
}
}
Expand Down
15 changes: 9 additions & 6 deletions apiserver/pkg/common/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func MakeEndpoint(ctx context.Context, c dynamic.Interface, owner generated.Type
Kind: "Secret",
Name: secret,
Namespace: owner.Namespace,
}, *input.Auth, ownerObject)
}, input.Auth, ownerObject)
if err != nil {
return endpoint, err
}
Expand All @@ -84,7 +84,13 @@ func MakeAuthSecretName(base string, ownerKind string) string {

// MakeAuthSecret will create or update a secret based on auth input
// When owner is not nil, owner reference will be set
func MakeAuthSecret(ctx context.Context, c dynamic.Interface, secret generated.TypedObjectReferenceInput, input generated.AuthInput, owner metav1.Object) error {
func MakeAuthSecret(ctx context.Context, c dynamic.Interface, secret generated.TypedObjectReferenceInput, input map[string]interface{}, owner metav1.Object) error {
// copy input map into data
data := map[string][]byte{}
for k, v := range input {
data[k] = []byte(fmt.Sprintf("%v", v))
}

// initialize a auth secret
authSecret := &corev1.Secret{
TypeMeta: metav1.TypeMeta{
Expand All @@ -95,10 +101,7 @@ func MakeAuthSecret(ctx context.Context, c dynamic.Interface, secret generated.T
Name: secret.Name,
Namespace: *secret.Namespace,
},
Data: map[string][]byte{
"rootUser": []byte(input.Username),
"rootPassword": []byte(input.Password),
},
Data: data,
}

// set owner reference
Expand Down
4 changes: 2 additions & 2 deletions apiserver/pkg/datasource/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func CreateDatasource(ctx context.Context, c dynamic.Interface, input generated.
Kind: "Secret",
Name: common.MakeAuthSecretName(datasource.Name, "datasource"),
Namespace: &input.Namespace,
}, *input.Endpointinput.Auth, obj)
}, input.Endpointinput.Auth, obj)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -351,7 +351,7 @@ func CheckDatasource(ctx context.Context, c dynamic.Interface, input generated.C
insecure = !*input.Endpointinput.Insecure
}
mc, err := minio.New(input.Endpointinput.URL, &minio.Options{
Creds: credentials.NewStaticV4(input.Endpointinput.Auth.Username, input.Endpointinput.Auth.Password, ""),
Creds: credentials.NewStaticV4(input.Endpointinput.Auth["rootUser"].(string), input.Endpointinput.Auth["rootPassword"].(string), ""),
Secure: insecure,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
Expand Down
4 changes: 2 additions & 2 deletions apiserver/pkg/embedder/embedder.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func CreateEmbedder(ctx context.Context, c dynamic.Interface, input generated.Cr
err := common.MakeAuthSecret(ctx, c, generated.TypedObjectReferenceInput{
Name: secret,
Namespace: &input.Namespace,
}, *input.Endpointinput.Auth, nil)
}, input.Endpointinput.Auth, nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -155,7 +155,7 @@ func CreateEmbedder(ctx context.Context, c dynamic.Interface, input generated.Cr
err := common.MakeAuthSecret(ctx, c, generated.TypedObjectReferenceInput{
Name: secret,
Namespace: &input.Namespace,
}, *input.Endpointinput.Auth, obj)
}, input.Endpointinput.Auth, obj)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions apiserver/pkg/llm/llm.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func CreateLLM(ctx context.Context, c dynamic.Interface, input generated.CreateL
err := common.MakeAuthSecret(ctx, c, generated.TypedObjectReferenceInput{
Name: secret,
Namespace: &input.Namespace,
}, *input.Endpointinput.Auth, nil)
}, input.Endpointinput.Auth, nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -231,7 +231,7 @@ func CreateLLM(ctx context.Context, c dynamic.Interface, input generated.CreateL
err := common.MakeAuthSecret(ctx, c, generated.TypedObjectReferenceInput{
Name: secret,
Namespace: &input.Namespace,
}, *input.Endpointinput.Auth, obj)
}, input.Endpointinput.Auth, obj)
if err != nil {
return nil, err
}
Expand Down
7 changes: 7 additions & 0 deletions deploy/llms/Dockerfile.fastchat-worker
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@ RUN python3.9 -m pip install wavedrom -i https://pypi.mirrors.ustc.edu.cn/simple
RUN python3.9 -m pip install fschat -i https://pypi.mirrors.ustc.edu.cn/simple/
RUN python3.9 -m pip install fschat[model_worker,webui] pydantic==1.10.13 -i https://pypi.mirrors.ustc.edu.cn/simple/

# required by vllm
# RUN python3.9 -m pip install vllm -i https://pypi.mirrors.ustc.edu.cn/simple/

# required by qwen
# might also install flash-attention to improve performance
RUN python3.9 -m pip install transformers==4.32.0 accelerate tiktoken einops scipy transformers_stream_generator==0.0.4 -i https://pypi.mirrors.ustc.edu.cn/simple/

# required by qwen quantize
RUN python3.9 -m pip install auto-gptq optimum -i https://pypi.mirrors.ustc.edu.cn/simple/qwn

0 comments on commit bc4fde5

Please sign in to comment.