Skip to content

Commit

Permalink
feat(handler): add title for region hardware (#718)
Browse files Browse the repository at this point in the history
Because

- provide display name for hardware types

This commit

- add title for region hardware
  • Loading branch information
heiruwu authored Dec 11, 2024
1 parent 2b0ce43 commit c71bb75
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions config/model/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@
"const": "NVIDIA_TESLA_T4",
"instillShortDescription": "Deploy model that runs on Nvidia T4 GPU",
"description": "Deploy model that runs on Nvidia T4 GPU",
"title": "Nvidia Tesla T4"
"title": "NVIDIA Tesla T4"
},
{
"const": "NVIDIA_L4",
"instillShortDescription": "Deploy model that runs on Nvidia L4 GPU",
"description": "Deploy model that runs on Nvidia L4 GPU",
"title": "Nvidia L4"
"title": "NVIDIA L4"
},
{
"const": "NVIDIA_A100",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0
github.com/iancoleman/strcase v0.3.0
github.com/influxdata/influxdb-client-go/v2 v2.14.0
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20241129105617-c2c298e76498
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20241211175103-4f1558f81c9c
github.com/instill-ai/usage-client v0.3.0-alpha
github.com/instill-ai/x v0.5.0-alpha.0.20241203111314-11f1aa4a3d91
github.com/jackc/pgx/v5 v5.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ github.com/influxdata/influxdb-client-go/v2 v2.14.0 h1:AjbBfJuq+QoaXNcrova8smSjw
github.com/influxdata/influxdb-client-go/v2 v2.14.0/go.mod h1:Ahpm3QXKMJslpXl3IftVLVezreAUtBOTZssDrjZEFHI=
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 h1:W9WBk7wlPfJLvMCdtV4zPulc4uCPrlywQOmbFOhgQNU=
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20241129105617-c2c298e76498 h1:JYRfk/m+960jEScE1NPQM+xh+ScR4cHNMg/tCFwQbpI=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20241129105617-c2c298e76498/go.mod h1:rf0UY7VpEgpaLudYEcjx5rnbuwlBaaLyD4FQmWLtgAY=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20241211175103-4f1558f81c9c h1:Ms49DzMSgT/g9k6xFeaY274O9S53sLMhdYZn/ld2UtU=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20241211175103-4f1558f81c9c/go.mod h1:rf0UY7VpEgpaLudYEcjx5rnbuwlBaaLyD4FQmWLtgAY=
github.com/instill-ai/usage-client v0.3.0-alpha h1:yY5eNn5zINqy8wpOogiNmrVYzJKnd1KMnMxlYBpr7Tk=
github.com/instill-ai/usage-client v0.3.0-alpha/go.mod h1:8lvtZulkhQ7t8alttb2KkLKYoCp5u4oatzDbfFlEld0=
github.com/instill-ai/x v0.5.0-alpha.0.20241203111314-11f1aa4a3d91 h1:baD7UhjwpmbBkaykoxi+6qd9A97qb/fkvvkocmwSrFA=
Expand Down
17 changes: 13 additions & 4 deletions pkg/handler/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -1065,18 +1065,27 @@ func (h *PublicHandler) ListAvailableRegions(ctx context.Context, req *modelpb.L
for _, r := range regionsStruct {
subRegion := &modelpb.Region{
RegionName: r.Const,
Hardware: []string{},
Hardware: []*modelpb.Hardware{},
}
for _, h := range hardwaresStruct {
if h.If.Properties.Region.Const == r.Const {
for _, hardware := range h.Then.Properties.Hardware.OneOf {
subRegion.Hardware = append(subRegion.Hardware, hardware.Const)
subRegion.Hardware = append(subRegion.Hardware, &modelpb.Hardware{
Title: hardware.Title,
Value: hardware.Const,
})
}
for _, hardware := range h.Then.Properties.Hardware.AnyOf {
if hardware.Const != "" {
subRegion.Hardware = append(subRegion.Hardware, hardware.Const)
subRegion.Hardware = append(subRegion.Hardware, &modelpb.Hardware{
Title: hardware.Title,
Value: hardware.Const,
})
} else if hardware.Title != "" {
subRegion.Hardware = append(subRegion.Hardware, hardware.Title)
subRegion.Hardware = append(subRegion.Hardware, &modelpb.Hardware{
Title: hardware.Title,
Value: "",
})
}
}
}
Expand Down

0 comments on commit c71bb75

Please sign in to comment.