mirror of
https://github.com/hanzo-ml/kserve.git
synced 2026-10-30 20:53:49 +00:00
* Bump go 1.22 Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Update generate scripts Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Fix breaking changes Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Fix deepcopy, client generation and bump controller-gen to 0.16.2 Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * generate files Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Bump go version for CI and dockerfiles Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Bump go version for qpext Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Use slices.Contains Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Remove clientv1alpha1 dir Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * Fix lint Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * go mod tidy Signed-off-by: Sivanantham Chinnaiyan <[email protected]> * set min go version to 1.22.7 Signed-off-by: Sivanantham Chinnaiyan <[email protected]> --------- Signed-off-by: Sivanantham Chinnaiyan <[email protected]>
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
package generator
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
"github.com/getkin/kin-openapi/openapi3"
|
|
"github.com/kserve/kserve/tools/tf2openapi/types"
|
|
)
|
|
|
|
const (
|
|
requestName = "modelInput"
|
|
responseName = "modelOutput"
|
|
requestRefTemplate = "#/components/requestBodies/%s"
|
|
responseRefTemplate = "#/components/responses/%s"
|
|
pathTemplate = "/v1/models/%s/versions/%s:predict"
|
|
)
|
|
|
|
func (g *Generator) tfServingOpenAPI(model types.TFSavedModel) (*openapi3.T, error) {
|
|
requestSchema, responseSchema, err := model.Schema(g.metaGraphTags, g.sigDefKey)
|
|
if err != nil {
|
|
return &openapi3.T{}, err
|
|
}
|
|
api := &openapi3.T{
|
|
OpenAPI: "3.0.0",
|
|
Components: &openapi3.Components{
|
|
Responses: map[string]*openapi3.ResponseRef{
|
|
responseName: {
|
|
Value: &openapi3.Response{
|
|
Description: proto.String("Model output"),
|
|
Content: openapi3.NewContentWithJSONSchema(responseSchema),
|
|
},
|
|
},
|
|
},
|
|
RequestBodies: map[string]*openapi3.RequestBodyRef{
|
|
requestName: {
|
|
Value: &openapi3.RequestBody{
|
|
Content: openapi3.NewContentWithJSONSchema(requestSchema),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
Paths: &openapi3.Paths{},
|
|
Info: &openapi3.Info{
|
|
Title: "TFServing Predict Request API",
|
|
Version: "1.0",
|
|
},
|
|
}
|
|
responses := openapi3.Responses{}
|
|
responses.Set("200", &openapi3.ResponseRef{
|
|
Ref: fmt.Sprintf(responseRefTemplate, responseName),
|
|
})
|
|
api.Paths.Set(fmt.Sprintf(pathTemplate, g.name, g.version), &openapi3.PathItem{
|
|
Post: &openapi3.Operation{
|
|
RequestBody: &openapi3.RequestBodyRef{
|
|
Ref: fmt.Sprintf(requestRefTemplate, requestName),
|
|
},
|
|
Responses: &responses,
|
|
},
|
|
})
|
|
return api, nil
|
|
}
|