Reference documentation and code samples for the Google Cloud Batch V1 Client class TaskGroup.
A TaskGroup defines one or more Tasks that all share the same TaskSpec.
Generated from protobuf messagegoogle.cloud.batch.v1.TaskGroup
Namespace
Google \ Cloud \ Batch \ V1
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ name
string
Output only. TaskGroup name. The system generates this field based on parent Job name. For example: "projects/123456/locations/us-west1/jobs/job01/taskGroups/group01".
Required. Tasks in the group share the same task spec.
↳ task_count
int|string
Number of Tasks in the TaskGroup. Default is 1.
↳ parallelism
int|string
Max number of tasks that can run in parallel. Default to min(task_count, parallel tasks per job limit). See:Job Limits. Field parallelism must be 1 if the scheduling_policy is IN_ORDER.
↳ scheduling_policy
int
Scheduling policy for Tasks in the TaskGroup. The default value is AS_SOON_AS_POSSIBLE.
An array of environment variable mappings, which are passed to Tasks with matching indices. If task_environments is used then task_count should not be specified in the request (and will be ignored). Task count will be the length of task_environments. Tasks get a BATCH_TASK_INDEX and BATCH_TASK_COUNT environment variable, in addition to any environment variables set in task_environments, specifying the number of Tasks in the Task's parent TaskGroup, and the specific Task's index in the TaskGroup (0 through BATCH_TASK_COUNT - 1).
↳ task_count_per_node
int|string
Max number of tasks that can be run on a VM at the same time. If not specified, the system will decide a value based on available compute resources on a VM and task requirements.
↳ require_hosts_file
bool
When true, Batch will populate a file with a list of all VMs assigned to the TaskGroup and set the BATCH_HOSTS_FILE environment variable to the path of that file. Defaults to false. The host file supports up to 1000 VMs.
↳ permissive_ssh
bool
When true, Batch will configure SSH to allow passwordless login between VMs running the Batch tasks in the same TaskGroup.
↳ run_as_non_root
bool
Optional. If not set or set to false, Batch uses the root user to execute runnables. If set to true, Batch runs the runnables using a non-root user. Currently, the non-root user Batch used is generated by OS Login. For more information, seeAbout OS Login.
getName
Output only. TaskGroup name.
The system generates this field based on parent Job name.
For example:
"projects/123456/locations/us-west1/jobs/job01/taskGroups/group01".
Returns
Type
Description
string
setName
Output only. TaskGroup name.
The system generates this field based on parent Job name.
For example:
"projects/123456/locations/us-west1/jobs/job01/taskGroups/group01".
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getTaskSpec
Required. Tasks in the group share the same task spec.
Default to min(task_count, parallel tasks per job limit).
See:Job Limits.
Field parallelism must be 1 if the scheduling_policy is IN_ORDER.
Returns
Type
Description
int|string
setParallelism
Max number of tasks that can run in parallel.
Default to min(task_count, parallel tasks per job limit).
See:Job Limits.
Field parallelism must be 1 if the scheduling_policy is IN_ORDER.
Parameter
Name
Description
var
int|string
Returns
Type
Description
$this
getSchedulingPolicy
Scheduling policy for Tasks in the TaskGroup.
The default value is AS_SOON_AS_POSSIBLE.
Returns
Type
Description
int
Enum of typeSchedulingPolicy.
setSchedulingPolicy
Scheduling policy for Tasks in the TaskGroup.
The default value is AS_SOON_AS_POSSIBLE.
Parameter
Name
Description
var
int
Enum of typeSchedulingPolicy.
Returns
Type
Description
$this
getTaskEnvironments
An array of environment variable mappings, which are passed to Tasks with
matching indices. If task_environments is used then task_count should
not be specified in the request (and will be ignored). Task count will be
the length of task_environments.
Tasks get a BATCH_TASK_INDEX and BATCH_TASK_COUNT environment variable, in
addition to any environment variables set in task_environments, specifying
the number of Tasks in the Task's parent TaskGroup, and the specific Task's
index in the TaskGroup (0 through BATCH_TASK_COUNT - 1).
An array of environment variable mappings, which are passed to Tasks with
matching indices. If task_environments is used then task_count should
not be specified in the request (and will be ignored). Task count will be
the length of task_environments.
Tasks get a BATCH_TASK_INDEX and BATCH_TASK_COUNT environment variable, in
addition to any environment variables set in task_environments, specifying
the number of Tasks in the Task's parent TaskGroup, and the specific Task's
index in the TaskGroup (0 through BATCH_TASK_COUNT - 1).
Max number of tasks that can be run on a VM at the same time.
If not specified, the system will decide a value based on available
compute resources on a VM and task requirements.
Returns
Type
Description
int|string
setTaskCountPerNode
Max number of tasks that can be run on a VM at the same time.
If not specified, the system will decide a value based on available
compute resources on a VM and task requirements.
Parameter
Name
Description
var
int|string
Returns
Type
Description
$this
getRequireHostsFile
When true, Batch will populate a file with a list of all VMs assigned to
the TaskGroup and set the BATCH_HOSTS_FILE environment variable to the path
of that file. Defaults to false. The host file supports up to 1000 VMs.
Returns
Type
Description
bool
setRequireHostsFile
When true, Batch will populate a file with a list of all VMs assigned to
the TaskGroup and set the BATCH_HOSTS_FILE environment variable to the path
of that file. Defaults to false. The host file supports up to 1000 VMs.
Parameter
Name
Description
var
bool
Returns
Type
Description
$this
getPermissiveSsh
When true, Batch will configure SSH to allow passwordless login between
VMs running the Batch tasks in the same TaskGroup.
Returns
Type
Description
bool
setPermissiveSsh
When true, Batch will configure SSH to allow passwordless login between
VMs running the Batch tasks in the same TaskGroup.
Parameter
Name
Description
var
bool
Returns
Type
Description
$this
getRunAsNonRoot
Optional. If not set or set to false, Batch uses the root user to execute
runnables. If set to true, Batch runs the runnables using a non-root user.
Currently, the non-root user Batch used is generated by OS Login. For more
information, seeAbout OS
Login.
Returns
Type
Description
bool
setRunAsNonRoot
Optional. If not set or set to false, Batch uses the root user to execute
runnables. If set to true, Batch runs the runnables using a non-root user.
Currently, the non-root user Batch used is generated by OS Login. For more
information, seeAbout OS
Login.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-09 UTC."],[],[],null,["# Google Cloud Batch V1 Client - Class TaskGroup (1.2.2)\n\nVersion latestkeyboard_arrow_down\n\n- [1.2.2 (latest)](/php/docs/reference/cloud-batch/latest/V1.TaskGroup)\n- [1.2.1](/php/docs/reference/cloud-batch/1.2.1/V1.TaskGroup)\n- [1.1.7](/php/docs/reference/cloud-batch/1.1.7/V1.TaskGroup)\n- [1.0.3](/php/docs/reference/cloud-batch/1.0.3/V1.TaskGroup)\n- [0.17.0](/php/docs/reference/cloud-batch/0.17.0/V1.TaskGroup)\n- [0.16.10](/php/docs/reference/cloud-batch/0.16.10/V1.TaskGroup)\n- [0.15.0](/php/docs/reference/cloud-batch/0.15.0/V1.TaskGroup)\n- [0.14.0](/php/docs/reference/cloud-batch/0.14.0/V1.TaskGroup)\n- [0.13.1](/php/docs/reference/cloud-batch/0.13.1/V1.TaskGroup)\n- [0.12.1](/php/docs/reference/cloud-batch/0.12.1/V1.TaskGroup)\n- [0.11.3](/php/docs/reference/cloud-batch/0.11.3/V1.TaskGroup)\n- [0.10.0](/php/docs/reference/cloud-batch/0.10.0/V1.TaskGroup)\n- [0.9.0](/php/docs/reference/cloud-batch/0.9.0/V1.TaskGroup)\n- [0.8.0](/php/docs/reference/cloud-batch/0.8.0/V1.TaskGroup)\n- [0.7.0](/php/docs/reference/cloud-batch/0.7.0/V1.TaskGroup)\n- [0.6.0](/php/docs/reference/cloud-batch/0.6.0/V1.TaskGroup)\n- [0.5.2](/php/docs/reference/cloud-batch/0.5.2/V1.TaskGroup)\n- [0.4.0](/php/docs/reference/cloud-batch/0.4.0/V1.TaskGroup)\n- [0.3.0](/php/docs/reference/cloud-batch/0.3.0/V1.TaskGroup)\n- [0.2.2](/php/docs/reference/cloud-batch/0.2.2/V1.TaskGroup) \nReference documentation and code samples for the Google Cloud Batch V1 Client class TaskGroup.\n\nA TaskGroup defines one or more Tasks that all share the same TaskSpec.\n\nGenerated from protobuf message `google.cloud.batch.v1.TaskGroup`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Batch \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getName\n\nOutput only. TaskGroup name.\n\nThe system generates this field based on parent Job name.\nFor example:\n\"projects/123456/locations/us-west1/jobs/job01/taskGroups/group01\".\n\n### setName\n\nOutput only. TaskGroup name.\n\nThe system generates this field based on parent Job name.\nFor example:\n\"projects/123456/locations/us-west1/jobs/job01/taskGroups/group01\".\n\n### getTaskSpec\n\nRequired. Tasks in the group share the same task spec.\n\n### hasTaskSpec\n\n### clearTaskSpec\n\n### setTaskSpec\n\nRequired. Tasks in the group share the same task spec.\n\n### getTaskCount\n\nNumber of Tasks in the TaskGroup.\n\nDefault is 1.\n\n### setTaskCount\n\nNumber of Tasks in the TaskGroup.\n\nDefault is 1.\n\n### getParallelism\n\nMax number of tasks that can run in parallel.\n\nDefault to min(task_count, parallel tasks per job limit).\nSee: [Job Limits](https://cloud.google.com/batch/quotas#job_limits).\nField parallelism must be 1 if the scheduling_policy is IN_ORDER.\n\n### setParallelism\n\nMax number of tasks that can run in parallel.\n\nDefault to min(task_count, parallel tasks per job limit).\nSee: [Job Limits](https://cloud.google.com/batch/quotas#job_limits).\nField parallelism must be 1 if the scheduling_policy is IN_ORDER.\n\n### getSchedulingPolicy\n\nScheduling policy for Tasks in the TaskGroup.\n\nThe default value is AS_SOON_AS_POSSIBLE.\n\n### setSchedulingPolicy\n\nScheduling policy for Tasks in the TaskGroup.\n\nThe default value is AS_SOON_AS_POSSIBLE.\n\n### getTaskEnvironments\n\nAn array of environment variable mappings, which are passed to Tasks with\nmatching indices. If task_environments is used then task_count should\nnot be specified in the request (and will be ignored). Task count will be\nthe length of task_environments.\n\nTasks get a BATCH_TASK_INDEX and BATCH_TASK_COUNT environment variable, in\naddition to any environment variables set in task_environments, specifying\nthe number of Tasks in the Task's parent TaskGroup, and the specific Task's\nindex in the TaskGroup (0 through BATCH_TASK_COUNT - 1).\n\n### setTaskEnvironments\n\nAn array of environment variable mappings, which are passed to Tasks with\nmatching indices. If task_environments is used then task_count should\nnot be specified in the request (and will be ignored). Task count will be\nthe length of task_environments.\n\nTasks get a BATCH_TASK_INDEX and BATCH_TASK_COUNT environment variable, in\naddition to any environment variables set in task_environments, specifying\nthe number of Tasks in the Task's parent TaskGroup, and the specific Task's\nindex in the TaskGroup (0 through BATCH_TASK_COUNT - 1).\n\n### getTaskCountPerNode\n\nMax number of tasks that can be run on a VM at the same time.\n\nIf not specified, the system will decide a value based on available\ncompute resources on a VM and task requirements.\n\n### setTaskCountPerNode\n\nMax number of tasks that can be run on a VM at the same time.\n\nIf not specified, the system will decide a value based on available\ncompute resources on a VM and task requirements.\n\n### getRequireHostsFile\n\nWhen true, Batch will populate a file with a list of all VMs assigned to\nthe TaskGroup and set the BATCH_HOSTS_FILE environment variable to the path\nof that file. Defaults to false. The host file supports up to 1000 VMs.\n\n### setRequireHostsFile\n\nWhen true, Batch will populate a file with a list of all VMs assigned to\nthe TaskGroup and set the BATCH_HOSTS_FILE environment variable to the path\nof that file. Defaults to false. The host file supports up to 1000 VMs.\n\n### getPermissiveSsh\n\nWhen true, Batch will configure SSH to allow passwordless login between\nVMs running the Batch tasks in the same TaskGroup.\n\n### setPermissiveSsh\n\nWhen true, Batch will configure SSH to allow passwordless login between\nVMs running the Batch tasks in the same TaskGroup.\n\n### getRunAsNonRoot\n\nOptional. If not set or set to false, Batch uses the root user to execute\nrunnables. If set to true, Batch runs the runnables using a non-root user.\n\nCurrently, the non-root user Batch used is generated by OS Login. For more\ninformation, see [About OS\nLogin](https://cloud.google.com/compute/docs/oslogin).\n\n### setRunAsNonRoot\n\nOptional. If not set or set to false, Batch uses the root user to execute\nrunnables. If set to true, Batch runs the runnables using a non-root user.\n\nCurrently, the non-root user Batch used is generated by OS Login. For more\ninformation, see [About OS\nLogin](https://cloud.google.com/compute/docs/oslogin)."]]