aboutsummaryrefslogtreecommitdiff
path: root/google/cloud/ml/v1/model_service.proto
blob: c57b16b506d853afad5e003e51f5b22edf472ad1 (plain)
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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
// Copyright 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.cloud.ml.v1;

import "google/api/annotations.proto";
import "google/api/auth.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/timestamp.proto";

option go_package = "google.golang.org/genproto/googleapis/cloud/ml/v1;ml";
option java_multiple_files = true;
option java_outer_classname = "ModelServiceProto";
option java_package = "com.google.cloud.ml.api.v1";

// Copyright 2017 Google Inc. All Rights Reserved.
//
// Proto file for the Google Cloud Machine Learning Engine.
// Describes the 'models service' to work with the 'model' and 'version'
// resources.

// Provides methods that create and manage machine learning models and their
// versions.
//
// A model in this context is a container for versions. The model can't provide
// predictions without first having a version created for it.
//
// Each version is a trained machine learning model, and each is assumed to be
// an iteration of the same machine learning problem as the other versions of
// the same model.
//
// Your project can define multiple models, each with multiple versions.
//
// The basic life cycle of a model is:
//
// *   Create and train the machine learning model and save it to a
//     Google Cloud Storage location.
// *   Use
//     [projects.models.create](/ml/reference/rest/v1/projects.models/create)
//     to make a new model in your project.
// *   Use
//     [projects.models.versions.create](/ml/reference/rest/v1/projects.models.versions/create)
//     to deploy your saved model.
// *   Use [projects.predict](/ml/reference/rest/v1/projects/predict to
//     request predictions of a version of your model, or use
//     [projects.jobs.create](/ml/reference/rest/v1/projects.jobs/create)
//     to start a batch prediction job.
service ModelService {
  // Creates a model which will later contain one or more versions.
  //
  // You must add at least one version before you can request predictions from
  // the model. Add versions by calling
  // [projects.models.versions.create](/ml/reference/rest/v1/projects.models.versions/create).
  rpc CreateModel(CreateModelRequest) returns (Model) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*}/models"
      body: "model"
    };
  }

  // Lists the models in a project.
  //
  // Each project can contain multiple models, and each model can have multiple
  // versions.
  rpc ListModels(ListModelsRequest) returns (ListModelsResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*}/models"
    };
  }

  // Gets information about a model, including its name, the description (if
  // set), and the default version (if at least one version of the model has
  // been deployed).
  rpc GetModel(GetModelRequest) returns (Model) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/models/*}"
    };
  }

  // Deletes a model.
  //
  // You can only delete a model if there are no versions in it. You can delete
  // versions by calling
  // [projects.models.versions.delete](/ml/reference/rest/v1/projects.models.versions/delete).
  rpc DeleteModel(DeleteModelRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/models/*}"
    };
  }

  // Creates a new version of a model from a trained TensorFlow model.
  //
  // If the version created in the cloud by this call is the first deployed
  // version of the specified model, it will be made the default version of the
  // model. When you add a version to a model that already has one or more
  // versions, the default version does not automatically change. If you want a
  // new version to be the default, you must call
  // [projects.models.versions.setDefault](/ml/reference/rest/v1/projects.models.versions/setDefault).
  rpc CreateVersion(CreateVersionRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/models/*}/versions"
      body: "version"
    };
  }

  // Gets basic information about all the versions of a model.
  //
  // If you expect that a model has a lot of versions, or if you need to handle
  // only a limited number of results at a time, you can request that the list
  // be retrieved in batches (called pages):
  rpc ListVersions(ListVersionsRequest) returns (ListVersionsResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/models/*}/versions"
    };
  }

  // Gets information about a model version.
  //
  // Models can have multiple versions. You can call
  // [projects.models.versions.list](/ml/reference/rest/v1/projects.models.versions/list)
  // to get the same information that this method returns for all of the
  // versions of a model.
  rpc GetVersion(GetVersionRequest) returns (Version) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/models/*/versions/*}"
    };
  }

  // Deletes a model version.
  //
  // Each model can have multiple versions deployed and in use at any given
  // time. Use this method to remove a single version.
  //
  // Note: You cannot delete the version that is set as the default version
  // of the model unless it is the only remaining version.
  rpc DeleteVersion(DeleteVersionRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/models/*/versions/*}"
    };
  }

  // Designates a version to be the default for the model.
  //
  // The default version is used for prediction requests made against the model
  // that don't specify a version.
  //
  // The first version to be created for a model is automatically set as the
  // default. You must make any subsequent changes to the default version
  // setting manually using this method.
  rpc SetDefaultVersion(SetDefaultVersionRequest) returns (Version) {
    option (google.api.http) = {
      post: "/v1/{name=projects/*/models/*/versions/*}:setDefault"
      body: "*"
    };
  }
}

// Represents a machine learning solution.
//
// A model can have multiple versions, each of which is a deployed, trained
// model ready to receive prediction requests. The model itself is just a
// container.
message Model {
  // Required. The name specified for the model when it was created.
  //
  // The model name must be unique within the project it is created in.
  string name = 1;

  // Optional. The description specified for the model when it was created.
  string description = 2;

  // Output only. The default version of the model. This version will be used to
  // handle prediction requests that do not specify a version.
  //
  // You can change the default version by calling
  // [projects.methods.versions.setDefault](/ml/reference/rest/v1/projects.models.versions/setDefault).
  Version default_version = 3;

  // Optional. The list of regions where the model is going to be deployed.
  // Currently only one region per model is supported.
  // Defaults to 'us-central1' if nothing is set.
  repeated string regions = 4;

  // Optional. If true, enables StackDriver Logging for online prediction.
  // Default is false.
  bool online_prediction_logging = 5;
}

// Represents a version of the model.
//
// Each version is a trained model deployed in the cloud, ready to handle
// prediction requests. A model can have multiple versions. You can get
// information about all of the versions of a given model by calling
// [projects.models.versions.list](/ml/reference/rest/v1/projects.models.versions/list).
message Version {
  // Required.The name specified for the version when it was created.
  //
  // The version name must be unique within the model it is created in.
  string name = 1;

  // Optional. The description specified for the version when it was created.
  string description = 2;

  // Output only. If true, this version will be used to handle prediction
  // requests that do not specify a version.
  //
  // You can change the default version by calling
  // [projects.methods.versions.setDefault](/ml/reference/rest/v1/projects.models.versions/setDefault).
  bool is_default = 3;

  // Required. The Google Cloud Storage location of the trained model used to
  // create the version. See the
  // [overview of model deployment](/ml/docs/concepts/deployment-overview) for
  // more informaiton.
  //
  // When passing Version to
  // [projects.models.versions.create](/ml/reference/rest/v1/projects.models.versions/create)
  // the model service uses the specified location as the source of the model.
  // Once deployed, the model version is hosted by the prediction service, so
  // this location is useful only as a historical record.
  string deployment_uri = 4;

  // Output only. The time the version was created.
  google.protobuf.Timestamp create_time = 5;

  // Output only. The time the version was last used for prediction.
  google.protobuf.Timestamp last_use_time = 6;

  // Optional. The Google Cloud ML runtime version to use for this deployment.
  // If not set, Google Cloud ML will choose a version.
  string runtime_version = 8;

  // Optional. Manually select the number of nodes to use for serving the
  // model. If unset (i.e., by default), the number of nodes used to serve
  // the model automatically scales with traffic. However, care should be
  // taken to ramp up traffic according to the model's ability to scale. If
  // your model needs to handle bursts of traffic beyond it's ability to
  // scale, it is recommended you set this field appropriately.
  ManualScaling manual_scaling = 9;
}

// Options for manually scaling a model.
message ManualScaling {
  // The number of nodes to allocate for this model. These nodes are always up,
  // starting from the time the model is deployed, so the cost of operating
  // this model will be proportional to nodes * number of hours since
  // deployment.
  int32 nodes = 1;
}

// Request message for the CreateModel method.
message CreateModelRequest {
  // Required. The project name.
  //
  // Authorization: requires `Editor` role on the specified project.
  string parent = 1;

  // Required. The model to create.
  Model model = 2;
}

// Request message for the ListModels method.
message ListModelsRequest {
  // Required. The name of the project whose models are to be listed.
  //
  // Authorization: requires `Viewer` role on the specified project.
  string parent = 1;

  // Optional. A page token to request the next page of results.
  //
  // You get the token from the `next_page_token` field of the response from
  // the previous call.
  string page_token = 4;

  // Optional. The number of models to retrieve per "page" of results. If there
  // are more remaining results than this number, the response message will
  // contain a valid value in the `next_page_token` field.
  //
  // The default value is 20, and the maximum page size is 100.
  int32 page_size = 5;
}

// Response message for the ListModels method.
message ListModelsResponse {
  // The list of models.
  repeated Model models = 1;

  // Optional. Pass this token as the `page_token` field of the request for a
  // subsequent call.
  string next_page_token = 2;
}

// Request message for the GetModel method.
message GetModelRequest {
  // Required. The name of the model.
  //
  // Authorization: requires `Viewer` role on the parent project.
  string name = 1;
}

// Request message for the DeleteModel method.
message DeleteModelRequest {
  // Required. The name of the model.
  //
  // Authorization: requires `Editor` role on the parent project.
  string name = 1;
}

// Uploads the provided trained model version to Cloud Machine Learning.
message CreateVersionRequest {
  // Required. The name of the model.
  //
  // Authorization: requires `Editor` role on the parent project.
  string parent = 1;

  // Required. The version details.
  Version version = 2;
}

// Request message for the ListVersions method.
message ListVersionsRequest {
  // Required. The name of the model for which to list the version.
  //
  // Authorization: requires `Viewer` role on the parent project.
  string parent = 1;

  // Optional. A page token to request the next page of results.
  //
  // You get the token from the `next_page_token` field of the response from
  // the previous call.
  string page_token = 4;

  // Optional. The number of versions to retrieve per "page" of results. If
  // there are more remaining results than this number, the response message
  // will contain a valid value in the `next_page_token` field.
  //
  // The default value is 20, and the maximum page size is 100.
  int32 page_size = 5;
}

// Response message for the ListVersions method.
message ListVersionsResponse {
  // The list of versions.
  repeated Version versions = 1;

  // Optional. Pass this token as the `page_token` field of the request for a
  // subsequent call.
  string next_page_token = 2;
}

// Request message for the GetVersion method.
message GetVersionRequest {
  // Required. The name of the version.
  //
  // Authorization: requires `Viewer` role on the parent project.
  string name = 1;
}

// Request message for the DeleteVerionRequest method.
message DeleteVersionRequest {
  // Required. The name of the version. You can get the names of all the
  // versions of a model by calling
  // [projects.models.versions.list](/ml/reference/rest/v1/projects.models.versions/list).
  //
  // Authorization: requires `Editor` role on the parent project.
  string name = 1;
}

// Request message for the SetDefaultVersion request.
message SetDefaultVersionRequest {
  // Required. The name of the version to make the default for the model. You
  // can get the names of all the versions of a model by calling
  // [projects.models.versions.list](/ml/reference/rest/v1/projects.models.versions/list).
  //
  // Authorization: requires `Editor` role on the parent project.
  string name = 1;
}