diff --git a/google/cloud/batch_v1alpha/types/batch.py b/google/cloud/batch_v1alpha/types/batch.py index c73ea20..b3fb405 100644 --- a/google/cloud/batch_v1alpha/types/batch.py +++ b/google/cloud/batch_v1alpha/types/batch.py @@ -163,6 +163,9 @@ class ListJobsRequest(proto.Message): Parent path. filter (str): List filter. + order_by (str): + Sort results. Supported are "name", "name desc", + "create_time", "create_time desc", and "". page_size (int): Page size. page_token (str): @@ -177,6 +180,10 @@ class ListJobsRequest(proto.Message): proto.STRING, number=4, ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) page_size: int = proto.Field( proto.INT32, number=2, @@ -230,6 +237,9 @@ class ListTasksRequest(proto.Message): Task filter, null filter matches all Tasks. Filter string should be of the format State=TaskStatus.State e.g. State=RUNNING + order_by (str): + Sort results. Supported are "name", "name desc", + "create_time", "create_time desc", and "". page_size (int): Page size. page_token (str): @@ -244,6 +254,10 @@ class ListTasksRequest(proto.Message): proto.STRING, number=2, ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) page_size: int = proto.Field( proto.INT32, number=3, diff --git a/google/cloud/batch_v1alpha/types/job.py b/google/cloud/batch_v1alpha/types/job.py index e5fec49..ea83fd1 100644 --- a/google/cloud/batch_v1alpha/types/job.py +++ b/google/cloud/batch_v1alpha/types/job.py @@ -515,6 +515,8 @@ class AllocationPolicy(proto.Message): reserved. network (google.cloud.batch_v1alpha.types.AllocationPolicy.NetworkPolicy): The network policy. + placement (google.cloud.batch_v1alpha.types.AllocationPolicy.PlacementPolicy): + The placement policy. """ class ProvisioningModel(proto.Enum): @@ -547,13 +549,16 @@ class LocationPolicy(proto.Message): Attributes: allowed_locations (MutableSequence[str]): A list of allowed location names represented by internal - URLs. Each location can be a region or a zone. Only one - region or multiple zones in one region is supported now. For - example, ["regions/us-central1"] allow VMs in any zones in - region us-central1. ["zones/us-central1-a", - "zones/us-central1-c"] only allow VMs in zones us-central1-a - and us-central1-c. All locations end up in different regions - would cause errors. For example, ["regions/us-central1", + URLs. + + Each location can be a region or a zone. Only one region or + multiple zones in one region is supported now. For example, + ["regions/us-central1"] allow VMs in any zones in region + us-central1. ["zones/us-central1-a", "zones/us-central1-c"] + only allow VMs in zones us-central1-a and us-central1-c. + + All locations end up in different regions would cause + errors. For example, ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b", "zones/us-west1-a"] contains 2 regions "us-central1" and "us-west1". An error is expected in this case. @@ -574,7 +579,8 @@ class LocationPolicy(proto.Message): class Disk(proto.Message): r"""A new persistent disk or a local ssd. A VM can only have one local SSD setting but multiple local SSD - partitions. https://cloud.google.com/compute/docs/disks#pdspecs. + partitions. See + https://cloud.google.com/compute/docs/disks#pdspecs and https://cloud.google.com/compute/docs/disks#localssds. This message has `oneof`_ fields (mutually exclusive fields). @@ -587,20 +593,24 @@ class Disk(proto.Message): Attributes: image (str): Name of a public or custom image used as the data source. - For example, the following are all valid URLs: (1) Specify - the image by its family name: - projects/{project}/global/images/family/{image_family} (2) - Specify the image version: - projects/{project}/global/images/{image_version} You can - also use Batch customized image in short names. The + For example, the following are all valid URLs: + + - Specify the image by its family name: + projects/{project}/global/images/family/{image_family} + - Specify the image version: + projects/{project}/global/images/{image_version} + + You can also use Batch customized image in short names. The following image values are supported for a boot disk: - "batch-debian": use Batch Debian images. "batch-centos": use - Batch CentOS images. "batch-cos": use Batch - Container-Optimized images. + + - "batch-debian": use Batch Debian images. + - "batch-centos": use Batch CentOS images. + - "batch-cos": use Batch Container-Optimized images. This field is a member of `oneof`_ ``data_source``. snapshot (str): Name of a snapshot used as the data source. + Snapshot is not supported as boot disk now. This field is a member of `oneof`_ ``data_source``. type_ (str): @@ -609,11 +619,13 @@ class Disk(proto.Message): disks and boot disks use "pd-balanced", "pd-extreme", "pd-ssd" or "pd-standard". size_gb (int): - Disk size in GB. For persistent disk, this field is ignored - if ``data_source`` is ``image`` or ``snapshot``. For local - SSD, size_gb should be a multiple of 375GB, otherwise, the - final size will be the next greater multiple of 375 GB. For - boot disk, Batch will calculate the boot disk size based on + Disk size in GB. + + For persistent disk, this field is ignored if + ``data_source`` is ``image`` or ``snapshot``. For local SSD, + size_gb should be a multiple of 375GB, otherwise, the final + size will be the next greater multiple of 375 GB. For boot + disk, Batch will calculate the boot disk size based on source image and task requirements if you do not speicify the size. If both this field and the boot_disk_mib field in task spec's compute_resource are defined, Batch will only @@ -728,8 +740,9 @@ class InstancePolicy(proto.Message): machine_type (str): The Compute Engine machine type. min_cpu_platform (str): - The minimum CPU platform. See - ``https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform``. + The minimum CPU platform. + See + https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform. Not yet implemented. provisioning_model (google.cloud.batch_v1alpha.types.AllocationPolicy.ProvisioningModel): The provisioning model. @@ -737,16 +750,19 @@ class InstancePolicy(proto.Message): The accelerators attached to each VM instance. boot_disk (google.cloud.batch_v1alpha.types.AllocationPolicy.Disk): - Book disk to be created and attached to each + Boot disk to be created and attached to each VM by this InstancePolicy. Boot disk will be - deleted when the VM is deleted. + deleted when the VM is deleted. Batch API now + only supports booting from image. disks (MutableSequence[google.cloud.batch_v1alpha.types.AllocationPolicy.AttachedDisk]): Non-boot disks to be attached for each VM created by this InstancePolicy. New disks will be deleted when the VM is deleted. reservation (str): - If specified, VMs will be allocated only - inside the matching reservation. + If specified, VMs will consume only the + specified reservation. If not specified + (default), VMs will consume any applicable + reservation. """ allowed_machine_types: MutableSequence[str] = proto.RepeatedField( @@ -837,21 +853,23 @@ class NetworkInterface(proto.Message): Attributes: network (str): - The URL of an existing network resource. - You can specify the network as a full or partial - URL. For example, the following are all valid - URLs: - https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network} - projects/{project}/global/networks/{network} - global/networks/{network} + The URL of an existing network resource. You can specify the + network as a full or partial URL. + + For example, the following are all valid URLs: + + - https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network} + - projects/{project}/global/networks/{network} + - global/networks/{network} subnetwork (str): - The URL of an existing subnetwork resource in - the network. You can specify the subnetwork as a - full or partial URL. For example, the following - are all valid URLs: - https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetwork} - projects/{project}/regions/{region}/subnetworks/{subnetwork} - regions/{region}/subnetworks/{subnetwork} + The URL of an existing subnetwork resource in the network. + You can specify the subnetwork as a full or partial URL. + + For example, the following are all valid URLs: + + - https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetwork} + - projects/{project}/regions/{region}/subnetworks/{subnetwork} + - regions/{region}/subnetworks/{subnetwork} no_external_ip_address (bool): Default is false (with an external IP address). Required if no external public IP @@ -894,6 +912,36 @@ class NetworkPolicy(proto.Message): message="AllocationPolicy.NetworkInterface", ) + class PlacementPolicy(proto.Message): + r"""PlacementPolicy describes a group placement policy for the + VMs controlled by this AllocationPolicy. + + Attributes: + collocation (str): + UNSPECIFIED vs. COLLOCATED (default + UNSPECIFIED). Use COLLOCATED when you want VMs + to be located close to each other for low + network latency between the VMs. No placement + policy will be generated when collocation is + UNSPECIFIED. + max_distance (int): + When specified, causes the job to fail if more than + max_distance logical switches are required between VMs. + Batch uses the most compact possible placement of VMs even + when max_distance is not specified. An explicit max_distance + makes that level of compactness a strict requirement. Not + yet implemented + """ + + collocation: str = proto.Field( + proto.STRING, + number=1, + ) + max_distance: int = proto.Field( + proto.INT64, + number=2, + ) + location: LocationPolicy = proto.Field( proto.MESSAGE, number=1, @@ -937,6 +985,11 @@ class NetworkPolicy(proto.Message): number=7, message=NetworkPolicy, ) + placement: PlacementPolicy = proto.Field( + proto.MESSAGE, + number=10, + message=PlacementPolicy, + ) class TaskGroup(proto.Message): @@ -954,12 +1007,14 @@ class TaskGroup(proto.Message): task spec. task_count (int): Number of Tasks in the TaskGroup. - default is 1 + Default is 1. parallelism (int): Max number of tasks that can run in parallel. Default to - min(task_count, 1000). + min(task_count, 1000). Field parallelism must be 1 if the + scheduling_policy is IN_ORDER. scheduling_policy (google.cloud.batch_v1alpha.types.TaskGroup.SchedulingPolicy): - Scheduling policy for Tasks in the TaskGroup. + Scheduling policy for Tasks in the TaskGroup. The default + value is AS_SOON_AS_POSSIBLE. allocation_policy (google.cloud.batch_v1alpha.types.AllocationPolicy): Compute resource allocation for the TaskGroup. If specified, it overrides resources @@ -1011,9 +1066,17 @@ class SchedulingPolicy(proto.Enum): Unspecified. AS_SOON_AS_POSSIBLE (1): Run Tasks as soon as resources are available. + + Tasks might be executed in parallel depending on parallelism + and task_count values. + IN_ORDER (2): + Run Tasks sequentially with increased task + index. + Not yet implemented. """ SCHEDULING_POLICY_UNSPECIFIED = 0 AS_SOON_AS_POSSIBLE = 1 + IN_ORDER = 2 name: str = proto.Field( proto.STRING, diff --git a/google/cloud/batch_v1alpha/types/task.py b/google/cloud/batch_v1alpha/types/task.py index ce7d44b..1ab92ed 100644 --- a/google/cloud/batch_v1alpha/types/task.py +++ b/google/cloud/batch_v1alpha/types/task.py @@ -148,7 +148,7 @@ class State(proto.Enum): Values: STATE_UNSPECIFIED (0): - unknown state + Unknown state. PENDING (1): The Task is created and waiting for resources. @@ -160,6 +160,9 @@ class State(proto.Enum): The Task has failed. SUCCEEDED (5): The Task has succeeded. + UNEXECUTED (6): + The Task has not been executed when the Job + finishes. """ STATE_UNSPECIFIED = 0 PENDING = 1 @@ -167,6 +170,7 @@ class State(proto.Enum): RUNNING = 3 FAILED = 4 SUCCEEDED = 5 + UNEXECUTED = 6 state: State = proto.Field( proto.ENUM, @@ -279,10 +283,11 @@ class Container(proto.Message): the "docker run" command when running this container, e.g. "--network host". block_external_network (bool): - If set to true, external network access to - and from container will be blocked. The - container will use the default internal network - 'goog-internal'. + If set to true, external network access to and from + container will be blocked, containers that are with + block_external_network as true can still communicate with + each other, network cannot be specified in the + ``container.options`` field. username (str): Optional username for logging in to a docker registry. If username matches ``projects/*/secrets/*/versions/*`` then diff --git a/samples/generated_samples/snippet_metadata_google.cloud.batch.v1.json b/samples/generated_samples/snippet_metadata_google.cloud.batch.v1.json index c9b168e..e2df106 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.batch.v1.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.batch.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-batch", - "version": "0.10.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/samples/generated_samples/snippet_metadata_google.cloud.batch.v1alpha.json b/samples/generated_samples/snippet_metadata_google.cloud.batch.v1alpha.json index b82fd6d..4862cc9 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.batch.v1alpha.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.batch.v1alpha.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-batch", - "version": "0.10.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/scripts/fixup_batch_v1alpha_keywords.py b/scripts/fixup_batch_v1alpha_keywords.py index d359e28..b764236 100644 --- a/scripts/fixup_batch_v1alpha_keywords.py +++ b/scripts/fixup_batch_v1alpha_keywords.py @@ -43,8 +43,8 @@ class batchCallTransformer(cst.CSTTransformer): 'delete_job': ('name', 'reason', 'request_id', ), 'get_job': ('name', ), 'get_task': ('name', ), - 'list_jobs': ('parent', 'filter', 'page_size', 'page_token', ), - 'list_tasks': ('parent', 'filter', 'page_size', 'page_token', ), + 'list_jobs': ('parent', 'filter', 'order_by', 'page_size', 'page_token', ), + 'list_tasks': ('parent', 'filter', 'order_by', 'page_size', 'page_token', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: diff --git a/tests/unit/gapic/batch_v1alpha/test_batch_service.py b/tests/unit/gapic/batch_v1alpha/test_batch_service.py index 0f24a6f..e481c4a 100644 --- a/tests/unit/gapic/batch_v1alpha/test_batch_service.py +++ b/tests/unit/gapic/batch_v1alpha/test_batch_service.py @@ -2670,6 +2670,10 @@ def test_create_job_rest(request_type): } ] }, + "placement": { + "collocation": "collocation_value", + "max_distance": 1264, + }, }, "labels": {}, "task_environments": {}, @@ -3049,6 +3053,10 @@ def test_create_job_rest_bad_request( } ] }, + "placement": { + "collocation": "collocation_value", + "max_distance": 1264, + }, }, "labels": {}, "task_environments": {}, @@ -4187,6 +4195,7 @@ def test_list_tasks_rest_required_fields(request_type=batch.ListTasksRequest): assert not set(unset_fields) - set( ( "filter", + "order_by", "page_size", "page_token", ) @@ -4247,6 +4256,7 @@ def test_list_tasks_rest_unset_required_fields(): set( ( "filter", + "orderBy", "pageSize", "pageToken", )