custom_job.proto 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.cloud.aiplatform.v1;
  16. import "google/api/field_behavior.proto";
  17. import "google/api/resource.proto";
  18. import "google/cloud/aiplatform/v1/encryption_spec.proto";
  19. import "google/cloud/aiplatform/v1/env_var.proto";
  20. import "google/cloud/aiplatform/v1/io.proto";
  21. import "google/cloud/aiplatform/v1/job_state.proto";
  22. import "google/cloud/aiplatform/v1/machine_resources.proto";
  23. import "google/protobuf/duration.proto";
  24. import "google/protobuf/timestamp.proto";
  25. import "google/rpc/status.proto";
  26. import "google/api/annotations.proto";
  27. option csharp_namespace = "Google.Cloud.AIPlatform.V1";
  28. option go_package = "google.golang.org/genproto/googleapis/cloud/aiplatform/v1;aiplatform";
  29. option java_multiple_files = true;
  30. option java_outer_classname = "CustomJobProto";
  31. option java_package = "com.google.cloud.aiplatform.v1";
  32. option php_namespace = "Google\\Cloud\\AIPlatform\\V1";
  33. option ruby_package = "Google::Cloud::AIPlatform::V1";
  34. // Represents a job that runs custom workloads such as a Docker container or a
  35. // Python package. A CustomJob can have multiple worker pools and each worker
  36. // pool can have its own machine and input spec. A CustomJob will be cleaned up
  37. // once the job enters terminal state (failed or succeeded).
  38. message CustomJob {
  39. option (google.api.resource) = {
  40. type: "aiplatform.googleapis.com/CustomJob"
  41. pattern: "projects/{project}/locations/{location}/customJobs/{custom_job}"
  42. };
  43. // Output only. Resource name of a CustomJob.
  44. string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  45. // Required. The display name of the CustomJob.
  46. // The name can be up to 128 characters long and can be consist of any UTF-8
  47. // characters.
  48. string display_name = 2 [(google.api.field_behavior) = REQUIRED];
  49. // Required. Job spec.
  50. CustomJobSpec job_spec = 4 [(google.api.field_behavior) = REQUIRED];
  51. // Output only. The detailed state of the job.
  52. JobState state = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  53. // Output only. Time when the CustomJob was created.
  54. google.protobuf.Timestamp create_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  55. // Output only. Time when the CustomJob for the first time entered the
  56. // `JOB_STATE_RUNNING` state.
  57. google.protobuf.Timestamp start_time = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
  58. // Output only. Time when the CustomJob entered any of the following states:
  59. // `JOB_STATE_SUCCEEDED`, `JOB_STATE_FAILED`, `JOB_STATE_CANCELLED`.
  60. google.protobuf.Timestamp end_time = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
  61. // Output only. Time when the CustomJob was most recently updated.
  62. google.protobuf.Timestamp update_time = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
  63. // Output only. Only populated when job's state is `JOB_STATE_FAILED` or
  64. // `JOB_STATE_CANCELLED`.
  65. google.rpc.Status error = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
  66. // The labels with user-defined metadata to organize CustomJobs.
  67. //
  68. // Label keys and values can be no longer than 64 characters
  69. // (Unicode codepoints), can only contain lowercase letters, numeric
  70. // characters, underscores and dashes. International characters are allowed.
  71. //
  72. // See https://goo.gl/xmQnxf for more information and examples of labels.
  73. map<string, string> labels = 11;
  74. // Customer-managed encryption key options for a CustomJob. If this is set,
  75. // then all resources created by the CustomJob will be encrypted with the
  76. // provided encryption key.
  77. EncryptionSpec encryption_spec = 12;
  78. }
  79. // Represents the spec of a CustomJob.
  80. message CustomJobSpec {
  81. // Required. The spec of the worker pools including machine type and Docker image.
  82. // All worker pools except the first one are optional and can be skipped by
  83. // providing an empty value.
  84. repeated WorkerPoolSpec worker_pool_specs = 1 [(google.api.field_behavior) = REQUIRED];
  85. // Scheduling options for a CustomJob.
  86. Scheduling scheduling = 3;
  87. // Specifies the service account for workload run-as account.
  88. // Users submitting jobs must have act-as permission on this run-as account.
  89. // If unspecified, the [AI Platform Custom Code Service
  90. // Agent](https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents)
  91. // for the CustomJob's project is used.
  92. string service_account = 4;
  93. // The full name of the Compute Engine
  94. // [network](/compute/docs/networks-and-firewalls#networks) to which the Job
  95. // should be peered. For example, `projects/12345/global/networks/myVPC`.
  96. // [Format](/compute/docs/reference/rest/v1/networks/insert)
  97. // is of the form `projects/{project}/global/networks/{network}`.
  98. // Where {project} is a project number, as in `12345`, and {network} is a
  99. // network name.
  100. //
  101. // Private services access must already be configured for the network. If left
  102. // unspecified, the job is not peered with any network.
  103. string network = 5 [(google.api.resource_reference) = {
  104. type: "compute.googleapis.com/Network"
  105. }];
  106. // The Cloud Storage location to store the output of this CustomJob or
  107. // HyperparameterTuningJob. For HyperparameterTuningJob,
  108. // the baseOutputDirectory of
  109. // each child CustomJob backing a Trial is set to a subdirectory of name
  110. // [id][google.cloud.aiplatform.v1.Trial.id] under its parent HyperparameterTuningJob's
  111. // baseOutputDirectory.
  112. //
  113. // The following Vertex AI environment variables will be passed to
  114. // containers or python modules when this field is set:
  115. //
  116. // For CustomJob:
  117. //
  118. // * AIP_MODEL_DIR = `<base_output_directory>/model/`
  119. // * AIP_CHECKPOINT_DIR = `<base_output_directory>/checkpoints/`
  120. // * AIP_TENSORBOARD_LOG_DIR = `<base_output_directory>/logs/`
  121. //
  122. // For CustomJob backing a Trial of HyperparameterTuningJob:
  123. //
  124. // * AIP_MODEL_DIR = `<base_output_directory>/<trial_id>/model/`
  125. // * AIP_CHECKPOINT_DIR = `<base_output_directory>/<trial_id>/checkpoints/`
  126. // * AIP_TENSORBOARD_LOG_DIR = `<base_output_directory>/<trial_id>/logs/`
  127. GcsDestination base_output_directory = 6;
  128. }
  129. // Represents the spec of a worker pool in a job.
  130. message WorkerPoolSpec {
  131. // The custom task to be executed in this worker pool.
  132. oneof task {
  133. // The custom container task.
  134. ContainerSpec container_spec = 6;
  135. // The Python packaged task.
  136. PythonPackageSpec python_package_spec = 7;
  137. }
  138. // Optional. Immutable. The specification of a single machine.
  139. MachineSpec machine_spec = 1 [
  140. (google.api.field_behavior) = OPTIONAL,
  141. (google.api.field_behavior) = IMMUTABLE
  142. ];
  143. // Optional. The number of worker replicas to use for this worker pool.
  144. int64 replica_count = 2 [(google.api.field_behavior) = OPTIONAL];
  145. // Disk spec.
  146. DiskSpec disk_spec = 5;
  147. }
  148. // The spec of a Container.
  149. message ContainerSpec {
  150. // Required. The URI of a container image in the Container Registry that is to be run on
  151. // each worker replica.
  152. string image_uri = 1 [(google.api.field_behavior) = REQUIRED];
  153. // The command to be invoked when the container is started.
  154. // It overrides the entrypoint instruction in Dockerfile when provided.
  155. repeated string command = 2;
  156. // The arguments to be passed when starting the container.
  157. repeated string args = 3;
  158. // Environment variables to be passed to the container.
  159. repeated EnvVar env = 4;
  160. }
  161. // The spec of a Python packaged code.
  162. message PythonPackageSpec {
  163. // Required. The URI of a container image in Artifact Registry that will run the
  164. // provided Python package. Vertex AI provides a wide range of executor
  165. // images with pre-installed packages to meet users' various use cases. See
  166. // the list of [pre-built containers for
  167. // training](https://cloud.google.com/vertex-ai/docs/training/pre-built-containers).
  168. // You must use an image from this list.
  169. string executor_image_uri = 1 [(google.api.field_behavior) = REQUIRED];
  170. // Required. The Google Cloud Storage location of the Python package files which are
  171. // the training program and its dependent packages.
  172. // The maximum number of package URIs is 100.
  173. repeated string package_uris = 2 [(google.api.field_behavior) = REQUIRED];
  174. // Required. The Python module name to run after installing the packages.
  175. string python_module = 3 [(google.api.field_behavior) = REQUIRED];
  176. // Command line arguments to be passed to the Python task.
  177. repeated string args = 4;
  178. // Environment variables to be passed to the python module.
  179. repeated EnvVar env = 5;
  180. }
  181. // All parameters related to queuing and scheduling of custom jobs.
  182. message Scheduling {
  183. // The maximum job running time. The default is 7 days.
  184. google.protobuf.Duration timeout = 1;
  185. // Restarts the entire CustomJob if a worker gets restarted.
  186. // This feature can be used by distributed training jobs that are not
  187. // resilient to workers leaving and joining a job.
  188. bool restart_job_on_worker_restart = 3;
  189. }