From be226750e6783a5994a497106c87cc7183654549 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 16 May 2023 09:20:43 -0400 Subject: [PATCH 1/4] feat: support order_by in ListJobs and ListTasks requests (#108) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: override HTTP URLs for LRO cancel/delete operations PiperOrigin-RevId: 532357846 Source-Link: https://github.com/googleapis/googleapis/commit/5cfe30bb7e28287ef82b319e3df1f6778b9d55fd Source-Link: https://github.com/googleapis/googleapis-gen/commit/0e1e293ad959be26640d593b978cab7fba7ced97 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMGUxZTI5M2FkOTU5YmUyNjY0MGQ1OTNiOTc4Y2FiN2ZiYTdjZWQ5NyJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot --- google/cloud/batch_v1alpha/types/batch.py | 14 ++ google/cloud/batch_v1alpha/types/job.py | 153 ++++++++++++------ google/cloud/batch_v1alpha/types/task.py | 15 +- ...nippet_metadata_google.cloud.batch.v1.json | 2 +- ...t_metadata_google.cloud.batch.v1alpha.json | 2 +- scripts/fixup_batch_v1alpha_keywords.py | 4 +- .../gapic/batch_v1alpha/test_batch_service.py | 10 ++ 7 files changed, 146 insertions(+), 54 deletions(-) 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", ) From 977ce57f89e15b46ead282df89ed371e68631ca6 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 16 May 2023 13:11:51 -0400 Subject: [PATCH 2/4] feat: add support for placement policies (#110) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add support for placement policies feat: per-Runnable labels PiperOrigin-RevId: 532437427 Source-Link: https://github.com/googleapis/googleapis/commit/288aa7fb71c9b6244db1a816cfd4108f811e6049 Source-Link: https://github.com/googleapis/googleapis-gen/commit/615d60f8e98ef120a79410c029b4c72448b53bde Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNjE1ZDYwZjhlOThlZjEyMGE3OTQxMGMwMjliNGM3MjQ0OGI1M2JkZSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot --- google/cloud/batch_v1/types/job.py | 136 ++++++++++++------ google/cloud/batch_v1/types/task.py | 22 ++- .../unit/gapic/batch_v1/test_batch_service.py | 4 + 3 files changed, 115 insertions(+), 47 deletions(-) diff --git a/google/cloud/batch_v1/types/job.py b/google/cloud/batch_v1/types/job.py index 3e58926..a509f7b 100644 --- a/google/cloud/batch_v1/types/job.py +++ b/google/cloud/batch_v1/types/job.py @@ -403,6 +403,8 @@ class AllocationPolicy(proto.Message): reserved. network (google.cloud.batch_v1.types.AllocationPolicy.NetworkPolicy): The network policy. + placement (google.cloud.batch_v1.types.AllocationPolicy.PlacementPolicy): + The placement policy. """ class ProvisioningModel(proto.Enum): @@ -435,13 +437,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. @@ -455,7 +460,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). @@ -468,20 +474,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): @@ -490,11 +500,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 @@ -607,8 +619,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_v1.types.AllocationPolicy.ProvisioningModel): The provisioning model. @@ -616,9 +629,10 @@ class InstancePolicy(proto.Message): The accelerators attached to each VM instance. boot_disk (google.cloud.batch_v1.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_v1.types.AllocationPolicy.AttachedDisk]): Non-boot disks to be attached for each VM created by this InstancePolicy. New disks will @@ -705,21 +719,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 @@ -762,6 +778,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, @@ -787,6 +833,11 @@ class NetworkPolicy(proto.Message): number=7, message=NetworkPolicy, ) + placement: PlacementPolicy = proto.Field( + proto.MESSAGE, + number=10, + message=PlacementPolicy, + ) class TaskGroup(proto.Message): @@ -804,10 +855,11 @@ 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. task_environments (MutableSequence[google.cloud.batch_v1.types.Environment]): An array of environment variable mappings, which are passed to Tasks with matching indices. If task_environments is used diff --git a/google/cloud/batch_v1/types/task.py b/google/cloud/batch_v1/types/task.py index 34bd444..2b23463 100644 --- a/google/cloud/batch_v1/types/task.py +++ b/google/cloud/batch_v1/types/task.py @@ -138,7 +138,7 @@ class State(proto.Enum): Values: STATE_UNSPECIFIED (0): - unknown state + Unknown state. PENDING (1): The Task is created and waiting for resources. @@ -150,6 +150,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 @@ -157,6 +160,7 @@ class State(proto.Enum): RUNNING = 3 FAILED = 4 SUCCEEDED = 5 + UNEXECUTED = 6 state: State = proto.Field( proto.ENUM, @@ -222,6 +226,8 @@ class Runnable(proto.Message): TaskGroup). timeout (google.protobuf.duration_pb2.Duration): Timeout for this Runnable. + labels (MutableMapping[str, str]): + Labels for this Runnable. """ class Container(proto.Message): @@ -247,10 +253,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 @@ -399,6 +406,11 @@ class Barrier(proto.Message): number=8, message=duration_pb2.Duration, ) + labels: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=9, + ) class TaskSpec(proto.Message): diff --git a/tests/unit/gapic/batch_v1/test_batch_service.py b/tests/unit/gapic/batch_v1/test_batch_service.py index 840eabd..4f7842f 100644 --- a/tests/unit/gapic/batch_v1/test_batch_service.py +++ b/tests/unit/gapic/batch_v1/test_batch_service.py @@ -2549,6 +2549,7 @@ def test_create_job_rest(request_type): }, }, "timeout": {"seconds": 751, "nanos": 543}, + "labels": {}, } ], "compute_resource": { @@ -2640,6 +2641,7 @@ def test_create_job_rest(request_type): } ] }, + "placement": {"collocation": "collocation_value", "max_distance": 1264}, }, "labels": {}, "status": { @@ -2896,6 +2898,7 @@ def test_create_job_rest_bad_request( }, }, "timeout": {"seconds": 751, "nanos": 543}, + "labels": {}, } ], "compute_resource": { @@ -2987,6 +2990,7 @@ def test_create_job_rest_bad_request( } ] }, + "placement": {"collocation": "collocation_value", "max_distance": 1264}, }, "labels": {}, "status": { From b13bf7f0af4de2dbff5b4a38168391e39ba20acb Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 25 May 2023 16:16:34 +0000 Subject: [PATCH 3/4] build(deps): bump requests to 2.31.0 [autoapprove] (#112) Source-Link: https://togithub.com/googleapis/synthtool/commit/30bd01b4ab78bf1b2a425816e15b3e7e090993dd Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:9bc5fa3b62b091f60614c08a7fb4fd1d3e1678e326f34dd66ce1eefb5dc3267b --- .github/.OwlBot.lock.yaml | 3 ++- .kokoro/requirements.txt | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index b8edda5..32b3c48 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:2e247c7bf5154df7f98cce087a20ca7605e236340c7d6d1a14447e5c06791bd6 + digest: sha256:9bc5fa3b62b091f60614c08a7fb4fd1d3e1678e326f34dd66ce1eefb5dc3267b +# created: 2023-05-25T14:56:16.294623272Z diff --git a/.kokoro/requirements.txt b/.kokoro/requirements.txt index 66a2172..3b8d7ee 100644 --- a/.kokoro/requirements.txt +++ b/.kokoro/requirements.txt @@ -419,9 +419,9 @@ readme-renderer==37.3 \ --hash=sha256:cd653186dfc73055656f090f227f5cb22a046d7f71a841dfa305f55c9a513273 \ --hash=sha256:f67a16caedfa71eef48a31b39708637a6f4664c4394801a7b0d6432d13907343 # via twine -requests==2.28.1 \ - --hash=sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983 \ - --hash=sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349 +requests==2.31.0 \ + --hash=sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f \ + --hash=sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1 # via # gcp-releasetool # google-api-core From 433be54b7fc61f22896ce024c74375e7410f984e Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 31 May 2023 13:42:28 -0400 Subject: [PATCH 4/4] chore(main): release 0.11.0 (#109) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- .release-please-manifest.json | 2 +- CHANGELOG.md | 10 ++++++++++ google/cloud/batch/gapic_version.py | 2 +- google/cloud/batch_v1/gapic_version.py | 2 +- google/cloud/batch_v1alpha/gapic_version.py | 2 +- .../snippet_metadata_google.cloud.batch.v1.json | 2 +- .../snippet_metadata_google.cloud.batch.v1alpha.json | 2 +- 7 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 7d9b009..78e7f27 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.10.0" + ".": "0.11.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a51a93..f3827d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [0.11.0](https://github.com/googleapis/python-batch/compare/v0.10.0...v0.11.0) (2023-05-25) + + +### Features + +* **v1:** Add support for per-Runnable labels ([977ce57](https://github.com/googleapis/python-batch/commit/977ce57f89e15b46ead282df89ed371e68631ca6)) +* **v1:** Add support for placement policies ([977ce57](https://github.com/googleapis/python-batch/commit/977ce57f89e15b46ead282df89ed371e68631ca6)) +* **v1alpha:** Add support for placement policies ([be22675](https://github.com/googleapis/python-batch/commit/be226750e6783a5994a497106c87cc7183654549)) +* **v1alpha:** Support order_by in ListJobs and ListTasks requests ([be22675](https://github.com/googleapis/python-batch/commit/be226750e6783a5994a497106c87cc7183654549)) + ## [0.10.0](https://github.com/googleapis/python-batch/compare/v0.9.0...v0.10.0) (2023-03-16) diff --git a/google/cloud/batch/gapic_version.py b/google/cloud/batch/gapic_version.py index 267ed2e..111c83c 100644 --- a/google/cloud/batch/gapic_version.py +++ b/google/cloud/batch/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.10.0" # {x-release-please-version} +__version__ = "0.11.0" # {x-release-please-version} diff --git a/google/cloud/batch_v1/gapic_version.py b/google/cloud/batch_v1/gapic_version.py index 267ed2e..111c83c 100644 --- a/google/cloud/batch_v1/gapic_version.py +++ b/google/cloud/batch_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.10.0" # {x-release-please-version} +__version__ = "0.11.0" # {x-release-please-version} diff --git a/google/cloud/batch_v1alpha/gapic_version.py b/google/cloud/batch_v1alpha/gapic_version.py index 267ed2e..111c83c 100644 --- a/google/cloud/batch_v1alpha/gapic_version.py +++ b/google/cloud/batch_v1alpha/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.10.0" # {x-release-please-version} +__version__ = "0.11.0" # {x-release-please-version} 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 e2df106..1c3fed7 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.1.0" + "version": "0.11.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 4862cc9..d9dd8c3 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.1.0" + "version": "0.11.0" }, "snippets": [ {