Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit 23d3a5e

Browse files
feat(v1): Add support for scheduling_policy (#115)
* feat: implement minCpuPlatform --- feat: Enable scheduling_policy in v1 --- feat: update TaskGroup doc PiperOrigin-RevId: 540043151 Source-Link: googleapis/googleapis@50a39ef Source-Link: https://github.com/googleapis/googleapis-gen/commit/5bdc561934be9a4ad3244358288bae8ea65b8bd1 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNWJkYzU2MTkzNGJlOWE0YWQzMjQ0MzU4Mjg4YmFlOGVhNjViOGJkMSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat(v1): Add support for scheduling_policy docs(v1): Minor clarifications for TaskGroup and min_cpu_platform PiperOrigin-RevId: 540265821 Source-Link: googleapis/googleapis@71856b9 Source-Link: https://github.com/googleapis/googleapis-gen/commit/f194a119b94d3b1b96043e74ea6fef7eb42eb798 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZjE5NGExMTliOTRkM2IxYjk2MDQzZTc0ZWE2ZmVmN2ViNDJlYjc5OCJ9 * 🦉 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 <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 8561b02 commit 23d3a5e

File tree

5 files changed

+36
-13
lines changed

5 files changed

+36
-13
lines changed

google/cloud/batch_v1/types/job.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,6 @@ class InstancePolicy(proto.Message):
622622
The minimum CPU platform.
623623
See
624624
https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform.
625-
Not yet implemented.
626625
provisioning_model (google.cloud.batch_v1.types.AllocationPolicy.ProvisioningModel):
627626
The provisioning model.
628627
accelerators (MutableSequence[google.cloud.batch_v1.types.AllocationPolicy.Accelerator]):
@@ -841,8 +840,8 @@ class PlacementPolicy(proto.Message):
841840

842841

843842
class TaskGroup(proto.Message):
844-
r"""A TaskGroup contains one or multiple Tasks that share the
845-
same Runnable but with different runtime parameters.
843+
r"""A TaskGroup defines one or more Tasks that all share the same
844+
TaskSpec.
846845
847846
Attributes:
848847
name (str):
@@ -860,6 +859,9 @@ class TaskGroup(proto.Message):
860859
Max number of tasks that can run in parallel. Default to
861860
min(task_count, 1000). Field parallelism must be 1 if the
862861
scheduling_policy is IN_ORDER.
862+
scheduling_policy (google.cloud.batch_v1.types.TaskGroup.SchedulingPolicy):
863+
Scheduling policy for Tasks in the TaskGroup. The default
864+
value is AS_SOON_AS_POSSIBLE.
863865
task_environments (MutableSequence[google.cloud.batch_v1.types.Environment]):
864866
An array of environment variable mappings, which are passed
865867
to Tasks with matching indices. If task_environments is used
@@ -873,8 +875,6 @@ class TaskGroup(proto.Message):
873875
Tasks in the Task's parent TaskGroup, and the specific
874876
Task's index in the TaskGroup (0 through BATCH_TASK_COUNT -
875877
1).
876-
877-
task_environments supports up to 200 entries.
878878
task_count_per_node (int):
879879
Max number of tasks that can be run on a VM
880880
at the same time. If not specified, the system
@@ -891,6 +891,26 @@ class TaskGroup(proto.Message):
891891
tasks in the same TaskGroup.
892892
"""
893893

894+
class SchedulingPolicy(proto.Enum):
895+
r"""How Tasks in the TaskGroup should be scheduled relative to
896+
each other.
897+
898+
Values:
899+
SCHEDULING_POLICY_UNSPECIFIED (0):
900+
Unspecified.
901+
AS_SOON_AS_POSSIBLE (1):
902+
Run Tasks as soon as resources are available.
903+
904+
Tasks might be executed in parallel depending on parallelism
905+
and task_count values.
906+
IN_ORDER (2):
907+
Run Tasks sequentially with increased task
908+
index.
909+
"""
910+
SCHEDULING_POLICY_UNSPECIFIED = 0
911+
AS_SOON_AS_POSSIBLE = 1
912+
IN_ORDER = 2
913+
894914
name: str = proto.Field(
895915
proto.STRING,
896916
number=1,
@@ -908,6 +928,11 @@ class TaskGroup(proto.Message):
908928
proto.INT64,
909929
number=5,
910930
)
931+
scheduling_policy: SchedulingPolicy = proto.Field(
932+
proto.ENUM,
933+
number=6,
934+
enum=SchedulingPolicy,
935+
)
911936
task_environments: MutableSequence[task.Environment] = proto.RepeatedField(
912937
proto.MESSAGE,
913938
number=9,

google/cloud/batch_v1alpha/types/job.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,6 @@ class InstancePolicy(proto.Message):
743743
The minimum CPU platform.
744744
See
745745
https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform.
746-
Not yet implemented.
747746
provisioning_model (google.cloud.batch_v1alpha.types.AllocationPolicy.ProvisioningModel):
748747
The provisioning model.
749748
accelerators (MutableSequence[google.cloud.batch_v1alpha.types.AllocationPolicy.Accelerator]):
@@ -993,8 +992,8 @@ class PlacementPolicy(proto.Message):
993992

994993

995994
class TaskGroup(proto.Message):
996-
r"""A TaskGroup contains one or multiple Tasks that share the
997-
same Runnable but with different runtime parameters.
995+
r"""A TaskGroup defines one or more Tasks that all share the same
996+
TaskSpec.
998997
999998
Attributes:
1000999
name (str):
@@ -1039,8 +1038,6 @@ class TaskGroup(proto.Message):
10391038
Tasks in the Task's parent TaskGroup, and the specific
10401039
Task's index in the TaskGroup (0 through BATCH_TASK_COUNT -
10411040
1).
1042-
1043-
task_environments supports up to 200 entries.
10441041
task_count_per_node (int):
10451042
Max number of tasks that can be run on a VM
10461043
at the same time. If not specified, the system
@@ -1072,7 +1069,6 @@ class SchedulingPolicy(proto.Enum):
10721069
IN_ORDER (2):
10731070
Run Tasks sequentially with increased task
10741071
index.
1075-
Not yet implemented.
10761072
"""
10771073
SCHEDULING_POLICY_UNSPECIFIED = 0
10781074
AS_SOON_AS_POSSIBLE = 1

samples/generated_samples/snippet_metadata_google.cloud.batch.v1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-batch",
11-
"version": "0.11.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

samples/generated_samples/snippet_metadata_google.cloud.batch.v1alpha.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-batch",
11-
"version": "0.11.0"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

tests/unit/gapic/batch_v1/test_batch_service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2582,6 +2582,7 @@ def test_create_job_rest(request_type):
25822582
},
25832583
"task_count": 1083,
25842584
"parallelism": 1174,
2585+
"scheduling_policy": 1,
25852586
"task_environments": {},
25862587
"task_count_per_node": 2022,
25872588
"require_hosts_file": True,
@@ -2931,6 +2932,7 @@ def test_create_job_rest_bad_request(
29312932
},
29322933
"task_count": 1083,
29332934
"parallelism": 1174,
2935+
"scheduling_policy": 1,
29342936
"task_environments": {},
29352937
"task_count_per_node": 2022,
29362938
"require_hosts_file": True,

0 commit comments

Comments
 (0)