Skip to content

Commit

Permalink
Add omitempty tag to parallel_workers field (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangonz authored Nov 18, 2022
1 parent 40db5be commit d55b925
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scheduler/pkg/agent/repository/mlserver/mlserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type ModelSettings struct {
Outputs []ModelMetadataTensors `json:"outputs,omitempty"`
Platform string `json:"platform,omitempty"`
Versions []string `json:"versions,omitempty"`
ParallelWorkers int `json:"parallel_workers"`
ParallelWorkers int `json:"parallel_workers,omitempty"`
Implementation string `json:"implementation,omitempty"`
Parameters *ModelParameters `json:"parameters,omitempty"`
}
Expand Down
27 changes: 27 additions & 0 deletions scheduler/pkg/agent/repository/mlserver/mlserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,3 +730,30 @@ func TestFindHighestVersionInPath(t *testing.T) {
})
}
}

func TestDefaultModelSettings(t *testing.T) {
g := NewGomegaWithT(t)

tests := []struct {
name string
modelSettings *ModelSettings
expected []byte
}{
{name: "omits all empty fields",
modelSettings: &ModelSettings{Name: "foo"},
expected: []byte("{\"name\":\"foo\"}"),
},
{
name: "adds empty parameters dict",
modelSettings: &ModelSettings{Name: "foo", Parameters: &ModelParameters{}},
expected: []byte("{\"name\":\"foo\",\"parameters\":{}}"),
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
data, _ := json.Marshal(test.modelSettings)
g.Expect(data).To(Equal(test.expected))
})
}
}

0 comments on commit d55b925

Please sign in to comment.