• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tensorchord / openmodelz / 6146306117

11 Sep 2023 12:22PM UTC coverage: 26.069% (-3.9%) from 29.927%
6146306117

Pull #171

github

xieydd
chore: Make proxy endpoint port configurable

Signed-off-by: xieydd <xieydd@gmail.com>
Pull Request #171: feat: Support BYOC

443 of 443 new or added lines in 14 files covered. (100.0%)

939 of 3602 relevant lines covered (26.07%)

1.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.94
/agent/pkg/server/handler_inference_create.go
1
package server
2

3
import (
4
        "fmt"
5
        "net/http"
6

7
        "github.com/gin-gonic/gin"
8

9
        "github.com/tensorchord/openmodelz/agent/api/types"
10
        "github.com/tensorchord/openmodelz/agent/client"
11
)
12

13
// @Summary     Create the inferences.
14
// @Description Create the inferences.
15
// @Tags        inference
16
// @Accept      json
17
// @Produce     json
18
// @Param       request body     types.InferenceDeployment true "query params"
19
// @Success     201     {object} types.InferenceDeployment
20
// @Router      /system/inferences [post]
21
func (s *Server) handleInferenceCreate(c *gin.Context) error {
3✔
22
        event := types.DeploymentCreateEvent
3✔
23

3✔
24
        var req types.InferenceDeployment
3✔
25
        if err := c.ShouldBindJSON(&req); err != nil {
4✔
26
                return NewError(http.StatusBadRequest, err, event)
1✔
27
        }
1✔
28

29
        if s.config.ModelZCloud.Enabled {
2✔
30
                ns := req.Spec.Namespace
×
31
                user, err := client.GetUserIDFromNamespace(ns)
×
32
                if err != nil {
×
33
                        return err
×
34
                } else if user == "" {
×
35
                        return fmt.Errorf("user id is empty")
×
36
                }
×
37
                s.cache.SetWithTTL(req.Spec.Name, user, 1, 0)
×
38

×
39
                exist := s.runtime.NamespaceGet(c.Request.Context(), ns)
×
40
                if !exist {
×
41
                        if err := s.runtime.NamespaceCreate(c.Request.Context(), ns); err != nil {
×
42
                                return err
×
43
                        }
×
44
                }
45
        }
46

47
        // Set the default values.
48
        s.validator.DefaultDeployRequest(&req)
2✔
49

2✔
50
        // Validate the request.
2✔
51
        if err := s.validator.ValidateDeployRequest(&req); err != nil {
3✔
52
                return NewError(http.StatusBadRequest, err, event)
1✔
53
        }
1✔
54

55
        // Create the inference.
56
        if err := s.runtime.InferenceCreate(c.Request.Context(), req,
1✔
57
                s.config.Ingress, event, s.config.Server.ServerPort); err != nil {
1✔
58
                return errFromErrDefs(err, event)
×
59
        }
×
60
        c.JSON(http.StatusCreated, req)
1✔
61
        return nil
1✔
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc