-
Notifications
You must be signed in to change notification settings - Fork 21
/
handler_inference_instance_exec.go
58 lines (50 loc) · 1.64 KB
/
handler_inference_instance_exec.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package server
import (
"errors"
"net/http"
"strconv"
"strings"
"github.com/gin-gonic/gin"
_ "github.com/tensorchord/openmodelz/agent/api/types"
)
// @Summary Attach to the inference instance.
// @Description Attach to the inference instance.
// @Tags inference
// @Accept json
// @Produce json
// @Param namespace query string true "Namespace" example("modelz-d3524a71-c17c-4c92-8faf-8603f02f4713")
// @Param name path string true "Name"
// @Param instance path string true "Instance name"
// @Success 200 {object} []types.InferenceDeployment
// @Router /system/inference/{name}/instance/{instance} [post]
func (s *Server) handleInferenceInstanceExec(c *gin.Context) error {
namespace := c.Query("namespace")
if namespace == "" {
return NewError(http.StatusBadRequest, errors.New("namespace is required"), "inference-instance-list")
}
name := c.Param("name")
if name == "" {
return NewError(http.StatusBadRequest, errors.New("name is required"),
"inference-instance-list")
}
instance := c.Param("instance")
if name == "" {
return NewError(http.StatusBadRequest, errors.New("instance is required"),
"inference-instance-list")
}
tty := c.Query("tty")
if tty == "" {
tty = "false"
}
ttyBoolean, err := strconv.ParseBool(tty)
if err != nil {
return NewError(http.StatusBadRequest, err, "inference-instance-exec")
}
command := c.Query("command")
commandSlice := strings.Split(command, ",")
if err := s.runtime.InferenceExec(
c, namespace, instance, commandSlice, ttyBoolean); err != nil {
return errFromErrDefs(err, "inference-instance-exec")
}
return nil
}