forked from rai-project/dlframework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dlframework_model_manifest.go
224 lines (167 loc) · 4.66 KB
/
dlframework_model_manifest.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"strconv"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// DlframeworkModelManifest dlframework model manifest
// swagger:model dlframeworkModelManifest
type DlframeworkModelManifest struct {
// after postprocess
AfterPostprocess string `json:"after_postprocess,omitempty"`
// after preprocess
AfterPreprocess string `json:"after_preprocess,omitempty"`
// attributes
Attributes map[string]string `json:"attributes,omitempty"`
// before postprocess
BeforePostprocess string `json:"before_postprocess,omitempty"`
// before preprocess
BeforePreprocess string `json:"before_preprocess,omitempty"`
// container
Container map[string]DlframeworkContainerHardware `json:"container,omitempty"`
// description
Description string `json:"description,omitempty"`
// framework
Framework *DlframeworkFrameworkManifest `json:"framework,omitempty"`
// hidden
Hidden bool `json:"hidden,omitempty"`
// inputs
Inputs []*DlframeworkModelManifestType `json:"inputs"`
// license
License string `json:"license,omitempty"`
// model
Model *ModelManifestModel `json:"model,omitempty"`
// name
Name string `json:"name,omitempty"`
// output
Output *DlframeworkModelManifestType `json:"output,omitempty"`
// postprocess
Postprocess string `json:"postprocess,omitempty"`
// preprocess
Preprocess string `json:"preprocess,omitempty"`
// reference
Reference []string `json:"reference"`
// version
Version string `json:"version,omitempty"`
}
// Validate validates this dlframework model manifest
func (m *DlframeworkModelManifest) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateContainer(formats); err != nil {
res = append(res, err)
}
if err := m.validateFramework(formats); err != nil {
res = append(res, err)
}
if err := m.validateInputs(formats); err != nil {
res = append(res, err)
}
if err := m.validateModel(formats); err != nil {
res = append(res, err)
}
if err := m.validateOutput(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *DlframeworkModelManifest) validateContainer(formats strfmt.Registry) error {
if swag.IsZero(m.Container) { // not required
return nil
}
for k := range m.Container {
if err := validate.Required("container"+"."+k, "body", m.Container[k]); err != nil {
return err
}
if val, ok := m.Container[k]; ok {
if err := val.Validate(formats); err != nil {
return err
}
}
}
return nil
}
func (m *DlframeworkModelManifest) validateFramework(formats strfmt.Registry) error {
if swag.IsZero(m.Framework) { // not required
return nil
}
if m.Framework != nil {
if err := m.Framework.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("framework")
}
return err
}
}
return nil
}
func (m *DlframeworkModelManifest) validateInputs(formats strfmt.Registry) error {
if swag.IsZero(m.Inputs) { // not required
return nil
}
for i := 0; i < len(m.Inputs); i++ {
if swag.IsZero(m.Inputs[i]) { // not required
continue
}
if m.Inputs[i] != nil {
if err := m.Inputs[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("inputs" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
func (m *DlframeworkModelManifest) validateModel(formats strfmt.Registry) error {
if swag.IsZero(m.Model) { // not required
return nil
}
if m.Model != nil {
if err := m.Model.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("model")
}
return err
}
}
return nil
}
func (m *DlframeworkModelManifest) validateOutput(formats strfmt.Registry) error {
if swag.IsZero(m.Output) { // not required
return nil
}
if m.Output != nil {
if err := m.Output.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("output")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *DlframeworkModelManifest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *DlframeworkModelManifest) UnmarshalBinary(b []byte) error {
var res DlframeworkModelManifest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}