googleapis / googleapis/python-genai

Batch Job Destination File_Name Missing in Attributes

Open
#1,527 9 comments 2 reactions 1 assignee Assigned to @kkorpal View on GitHub
priority: p3 type: feature request
Dominant language
Python
Stars
4k
Forks
1k
Avg merge
2d 11h
Merged PRs (30d)
40

Description

After executing a batch job using the Input File request and the batch job runs successfully, I am not able to determine the output file name automatically. The default output `predictions.jsonl` file is created in my GCP Storage Bucket as expected, but it is timestamped within the file name and I cannot programmatically determine the file name. I believe there is some error with the request header response not being parsed correctly in python.

#### Incorrect Behavior

```python
print(batch_job.dest)
"format='jsonl' gcs_uri='gs://path-to-bucket-bucket' bigquery_uri=None file_name=None inlined_responses=None"
```

#### Code to reproduce

```python
from google import genai

# Assumes `uploaded_file` is another object already uploaded to the Google Storage Bucket
client = genai.Client()
file_batch_job = client.batches.create(
model="gemini-2.5-flash",
src=uploaded_file.name,
config={
'display_name': "file-upload-job-1",
},
)

job_name = file_batch_job.name
print(f"Created batch job: {job_name}")

completed_states = set([
'JOB_STATE_SUCCEEDED',
'JOB_STATE_FAILED',
'JOB_STATE_CANCELLED',
'JOB_STATE_EXPIRED',
])

print(f"Polling status for job: {job_name}")
batch_job = client.batches.get(name=job_name) # Initial get
while batch_job.state.name not in completed_states:
print(f"Current state: {batch_job.state.name}")
time.sleep(30) # Wait for 30 seconds before polling again
batch_job = client.batches.get(name=job_name)

print(f"Job finished with state: {batch_job.state.name}")
if batch_job.state.name == 'JOB_STATE_FAILED':
print(f"Error: {batch_job.error}")

# Assuming job executed correctly, there should be a file output in the Google Storage Bucket at this point
print(batch_job.dest)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.