generated from pulumi/pulumi-tf-provider-boilerplate
/
modelServing.go
359 lines (308 loc) · 15.4 KB
/
modelServing.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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package databricks
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-databricks/sdk/go/databricks/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// This resource allows you to manage [Model Serving](https://docs.databricks.com/machine-learning/model-serving/index.html) endpoints in Databricks.
//
// **Note** If you replace `servedModels` with `servedEntities` in an existing serving endpoint, the serving endpoint will briefly go into an update state (~30 seconds) and increment the config version.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-databricks/sdk/go/databricks"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := databricks.NewModelServing(ctx, "this", &databricks.ModelServingArgs{
// Name: pulumi.String("ads-serving-endpoint"),
// Config: &databricks.ModelServingConfigArgs{
// ServedEntities: databricks.ModelServingConfigServedEntityArray{
// &databricks.ModelServingConfigServedEntityArgs{
// Name: pulumi.String("prod_model"),
// EntityName: pulumi.String("ads-model"),
// EntityVersion: pulumi.String("2"),
// WorkloadSize: pulumi.String("Small"),
// ScaleToZeroEnabled: pulumi.Bool(true),
// },
// &databricks.ModelServingConfigServedEntityArgs{
// Name: pulumi.String("candidate_model"),
// EntityName: pulumi.String("ads-model"),
// EntityVersion: pulumi.String("4"),
// WorkloadSize: pulumi.String("Small"),
// ScaleToZeroEnabled: pulumi.Bool(false),
// },
// },
// TrafficConfig: &databricks.ModelServingConfigTrafficConfigArgs{
// Routes: databricks.ModelServingConfigTrafficConfigRouteArray{
// &databricks.ModelServingConfigTrafficConfigRouteArgs{
// ServedModelName: pulumi.String("prod_model"),
// TrafficPercentage: pulumi.Int(90),
// },
// &databricks.ModelServingConfigTrafficConfigRouteArgs{
// ServedModelName: pulumi.String("candidate_model"),
// TrafficPercentage: pulumi.Int(10),
// },
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Access Control
//
// * Permissions can control which groups or individual users can *Manage*, *Query* or *View* individual serving endpoints.
//
// ## Related Resources
//
// The following resources are often used in the same context:
//
// * RegisteredModel to create [Models in Unity Catalog](https://docs.databricks.com/en/mlflow/models-in-uc.html) in Databricks.
// * End to end workspace management guide.
// * Directory to manage directories in [Databricks Workspace](https://docs.databricks.com/workspace/workspace-objects.html).
// * MlflowModel to create models in the [workspace model registry](https://docs.databricks.com/en/mlflow/model-registry.html) in Databricks.
// * Notebook to manage [Databricks Notebooks](https://docs.databricks.com/notebooks/index.html).
// * Notebook data to export a notebook from Databricks Workspace.
// * Repo to manage [Databricks Repos](https://docs.databricks.com/repos.html).
//
// ## Import
//
// The model serving resource can be imported using the name of the endpoint.
//
// bash
//
// ```sh
// $ pulumi import databricks:index/modelServing:ModelServing this <model-serving-endpoint-name>
// ```
type ModelServing struct {
pulumi.CustomResourceState
// The model serving endpoint configuration.
Config ModelServingConfigOutput `pulumi:"config"`
// The name of the model serving endpoint. This field is required and must be unique across a workspace. An endpoint name can consist of alphanumeric characters, dashes, and underscores. NOTE: Changing this name will delete the existing endpoint and create a new endpoint with the update name.
Name pulumi.StringOutput `pulumi:"name"`
// A list of rate limits to be applied to the serving endpoint. NOTE: only external and foundation model endpoints are supported as of now.
RateLimits ModelServingRateLimitArrayOutput `pulumi:"rateLimits"`
// Unique identifier of the serving endpoint primarily used to set permissions and refer to this instance for other operations.
ServingEndpointId pulumi.StringOutput `pulumi:"servingEndpointId"`
// Tags to be attached to the serving endpoint and automatically propagated to billing logs.
Tags ModelServingTagArrayOutput `pulumi:"tags"`
}
// NewModelServing registers a new resource with the given unique name, arguments, and options.
func NewModelServing(ctx *pulumi.Context,
name string, args *ModelServingArgs, opts ...pulumi.ResourceOption) (*ModelServing, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Config == nil {
return nil, errors.New("invalid value for required argument 'Config'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource ModelServing
err := ctx.RegisterResource("databricks:index/modelServing:ModelServing", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetModelServing gets an existing ModelServing resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetModelServing(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ModelServingState, opts ...pulumi.ResourceOption) (*ModelServing, error) {
var resource ModelServing
err := ctx.ReadResource("databricks:index/modelServing:ModelServing", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ModelServing resources.
type modelServingState struct {
// The model serving endpoint configuration.
Config *ModelServingConfig `pulumi:"config"`
// The name of the model serving endpoint. This field is required and must be unique across a workspace. An endpoint name can consist of alphanumeric characters, dashes, and underscores. NOTE: Changing this name will delete the existing endpoint and create a new endpoint with the update name.
Name *string `pulumi:"name"`
// A list of rate limits to be applied to the serving endpoint. NOTE: only external and foundation model endpoints are supported as of now.
RateLimits []ModelServingRateLimit `pulumi:"rateLimits"`
// Unique identifier of the serving endpoint primarily used to set permissions and refer to this instance for other operations.
ServingEndpointId *string `pulumi:"servingEndpointId"`
// Tags to be attached to the serving endpoint and automatically propagated to billing logs.
Tags []ModelServingTag `pulumi:"tags"`
}
type ModelServingState struct {
// The model serving endpoint configuration.
Config ModelServingConfigPtrInput
// The name of the model serving endpoint. This field is required and must be unique across a workspace. An endpoint name can consist of alphanumeric characters, dashes, and underscores. NOTE: Changing this name will delete the existing endpoint and create a new endpoint with the update name.
Name pulumi.StringPtrInput
// A list of rate limits to be applied to the serving endpoint. NOTE: only external and foundation model endpoints are supported as of now.
RateLimits ModelServingRateLimitArrayInput
// Unique identifier of the serving endpoint primarily used to set permissions and refer to this instance for other operations.
ServingEndpointId pulumi.StringPtrInput
// Tags to be attached to the serving endpoint and automatically propagated to billing logs.
Tags ModelServingTagArrayInput
}
func (ModelServingState) ElementType() reflect.Type {
return reflect.TypeOf((*modelServingState)(nil)).Elem()
}
type modelServingArgs struct {
// The model serving endpoint configuration.
Config ModelServingConfig `pulumi:"config"`
// The name of the model serving endpoint. This field is required and must be unique across a workspace. An endpoint name can consist of alphanumeric characters, dashes, and underscores. NOTE: Changing this name will delete the existing endpoint and create a new endpoint with the update name.
Name *string `pulumi:"name"`
// A list of rate limits to be applied to the serving endpoint. NOTE: only external and foundation model endpoints are supported as of now.
RateLimits []ModelServingRateLimit `pulumi:"rateLimits"`
// Tags to be attached to the serving endpoint and automatically propagated to billing logs.
Tags []ModelServingTag `pulumi:"tags"`
}
// The set of arguments for constructing a ModelServing resource.
type ModelServingArgs struct {
// The model serving endpoint configuration.
Config ModelServingConfigInput
// The name of the model serving endpoint. This field is required and must be unique across a workspace. An endpoint name can consist of alphanumeric characters, dashes, and underscores. NOTE: Changing this name will delete the existing endpoint and create a new endpoint with the update name.
Name pulumi.StringPtrInput
// A list of rate limits to be applied to the serving endpoint. NOTE: only external and foundation model endpoints are supported as of now.
RateLimits ModelServingRateLimitArrayInput
// Tags to be attached to the serving endpoint and automatically propagated to billing logs.
Tags ModelServingTagArrayInput
}
func (ModelServingArgs) ElementType() reflect.Type {
return reflect.TypeOf((*modelServingArgs)(nil)).Elem()
}
type ModelServingInput interface {
pulumi.Input
ToModelServingOutput() ModelServingOutput
ToModelServingOutputWithContext(ctx context.Context) ModelServingOutput
}
func (*ModelServing) ElementType() reflect.Type {
return reflect.TypeOf((**ModelServing)(nil)).Elem()
}
func (i *ModelServing) ToModelServingOutput() ModelServingOutput {
return i.ToModelServingOutputWithContext(context.Background())
}
func (i *ModelServing) ToModelServingOutputWithContext(ctx context.Context) ModelServingOutput {
return pulumi.ToOutputWithContext(ctx, i).(ModelServingOutput)
}
// ModelServingArrayInput is an input type that accepts ModelServingArray and ModelServingArrayOutput values.
// You can construct a concrete instance of `ModelServingArrayInput` via:
//
// ModelServingArray{ ModelServingArgs{...} }
type ModelServingArrayInput interface {
pulumi.Input
ToModelServingArrayOutput() ModelServingArrayOutput
ToModelServingArrayOutputWithContext(context.Context) ModelServingArrayOutput
}
type ModelServingArray []ModelServingInput
func (ModelServingArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ModelServing)(nil)).Elem()
}
func (i ModelServingArray) ToModelServingArrayOutput() ModelServingArrayOutput {
return i.ToModelServingArrayOutputWithContext(context.Background())
}
func (i ModelServingArray) ToModelServingArrayOutputWithContext(ctx context.Context) ModelServingArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ModelServingArrayOutput)
}
// ModelServingMapInput is an input type that accepts ModelServingMap and ModelServingMapOutput values.
// You can construct a concrete instance of `ModelServingMapInput` via:
//
// ModelServingMap{ "key": ModelServingArgs{...} }
type ModelServingMapInput interface {
pulumi.Input
ToModelServingMapOutput() ModelServingMapOutput
ToModelServingMapOutputWithContext(context.Context) ModelServingMapOutput
}
type ModelServingMap map[string]ModelServingInput
func (ModelServingMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ModelServing)(nil)).Elem()
}
func (i ModelServingMap) ToModelServingMapOutput() ModelServingMapOutput {
return i.ToModelServingMapOutputWithContext(context.Background())
}
func (i ModelServingMap) ToModelServingMapOutputWithContext(ctx context.Context) ModelServingMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ModelServingMapOutput)
}
type ModelServingOutput struct{ *pulumi.OutputState }
func (ModelServingOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ModelServing)(nil)).Elem()
}
func (o ModelServingOutput) ToModelServingOutput() ModelServingOutput {
return o
}
func (o ModelServingOutput) ToModelServingOutputWithContext(ctx context.Context) ModelServingOutput {
return o
}
// The model serving endpoint configuration.
func (o ModelServingOutput) Config() ModelServingConfigOutput {
return o.ApplyT(func(v *ModelServing) ModelServingConfigOutput { return v.Config }).(ModelServingConfigOutput)
}
// The name of the model serving endpoint. This field is required and must be unique across a workspace. An endpoint name can consist of alphanumeric characters, dashes, and underscores. NOTE: Changing this name will delete the existing endpoint and create a new endpoint with the update name.
func (o ModelServingOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *ModelServing) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// A list of rate limits to be applied to the serving endpoint. NOTE: only external and foundation model endpoints are supported as of now.
func (o ModelServingOutput) RateLimits() ModelServingRateLimitArrayOutput {
return o.ApplyT(func(v *ModelServing) ModelServingRateLimitArrayOutput { return v.RateLimits }).(ModelServingRateLimitArrayOutput)
}
// Unique identifier of the serving endpoint primarily used to set permissions and refer to this instance for other operations.
func (o ModelServingOutput) ServingEndpointId() pulumi.StringOutput {
return o.ApplyT(func(v *ModelServing) pulumi.StringOutput { return v.ServingEndpointId }).(pulumi.StringOutput)
}
// Tags to be attached to the serving endpoint and automatically propagated to billing logs.
func (o ModelServingOutput) Tags() ModelServingTagArrayOutput {
return o.ApplyT(func(v *ModelServing) ModelServingTagArrayOutput { return v.Tags }).(ModelServingTagArrayOutput)
}
type ModelServingArrayOutput struct{ *pulumi.OutputState }
func (ModelServingArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ModelServing)(nil)).Elem()
}
func (o ModelServingArrayOutput) ToModelServingArrayOutput() ModelServingArrayOutput {
return o
}
func (o ModelServingArrayOutput) ToModelServingArrayOutputWithContext(ctx context.Context) ModelServingArrayOutput {
return o
}
func (o ModelServingArrayOutput) Index(i pulumi.IntInput) ModelServingOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ModelServing {
return vs[0].([]*ModelServing)[vs[1].(int)]
}).(ModelServingOutput)
}
type ModelServingMapOutput struct{ *pulumi.OutputState }
func (ModelServingMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ModelServing)(nil)).Elem()
}
func (o ModelServingMapOutput) ToModelServingMapOutput() ModelServingMapOutput {
return o
}
func (o ModelServingMapOutput) ToModelServingMapOutputWithContext(ctx context.Context) ModelServingMapOutput {
return o
}
func (o ModelServingMapOutput) MapIndex(k pulumi.StringInput) ModelServingOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ModelServing {
return vs[0].(map[string]*ModelServing)[vs[1].(string)]
}).(ModelServingOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ModelServingInput)(nil)).Elem(), &ModelServing{})
pulumi.RegisterInputType(reflect.TypeOf((*ModelServingArrayInput)(nil)).Elem(), ModelServingArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ModelServingMapInput)(nil)).Elem(), ModelServingMap{})
pulumi.RegisterOutputType(ModelServingOutput{})
pulumi.RegisterOutputType(ModelServingArrayOutput{})
pulumi.RegisterOutputType(ModelServingMapOutput{})
}