The Batch team will be pushing a fix out for this particular issue. Meanwhile, to achieve the same request, you could consider using commands like gcloud batch tasks list --job=job_id --location=location --filter=“STATE=FAILED” plus gcloud batch tasks list --job=job_id --location=location --filter=“STATE=PENDING”
Hi, thanks for the reply. Another bug is that if I do gcloud batch tasks list --job=job_id --location=location --filter=“STATE=STATE_UNSPECIFIED” or “STATE=UNEXECUTED”, it will say that it is invalid state even though these are provided here https://cloud.google.com/batch/docs/reference/rest/v1/State
with a minor change to iterate over the tasks and print:
from __future__ import annotations
from collections.abc import Iterable
from google.cloud import batch_v1
def list_tasks(
project_id: str, region: str, job_name: str, group_name: str
) -> Iterable[batch_v1.Task]:
"""
Get a list of all jobs defined in given region.
Args:
project_id: project ID or project number of the Cloud project you want to use.
region: name of the region hosting the jobs.
job_name: name of the job which tasks you want to list.
group_name: name of the group of tasks. Usually it's `group0`.
Returns:
An iterable collection of Task objects.
"""
client = batch_v1.BatchServiceClient()
tasks= client.list_tasks(
parent=f"projects/{project_id}/locations/{region}/jobs/{job_name}/taskGroups/{group_name}"
)
for task in tasks:
print(task)
, it will give error:
google.api_core.exceptions.InvalidArgument: 400 pagesize field is invalid. mismatching token page size error: request page size (0) != token page size (500)
Please try to update to the latest gcloud such as using command gcloud components update and using the gcloud alpha batch tasks list command, hopefully, it would address this issue and your original issue.
I tried the exact Python program as your post and it’s working fine for me, can you please double check your environment like run some other APIs and make sure they are working as intended?