Implementation:Googleapis Python genai Tunings Get
| Knowledge Sources | |
|---|---|
| Domains | Fine_Tuning, Operations |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete tool for retrieving tuning job status and monitoring progress provided by the google-genai tunings module.
Description
Tunings.get retrieves the current state of a tuning job by its resource name. It returns an updated TuningJob object with the current state (JOB_STATE_SUCCEEDED, JOB_STATE_FAILED, etc.), tuned_model (available when complete), training metrics, and timestamps. This is used in polling loops to monitor job progress.
Usage
Call client.tunings.get(name=job_name) periodically to check job status. The name parameter is the resource name from the TuningJob returned by tunings.tune. Check tuning_job.state for completion status.
Code Reference
Source Location
- Repository: googleapis/python-genai
- File: google/genai/tunings.py
- Lines: L1703
Signature
class Tunings:
def get(
self,
*,
name: str,
config: Optional[types.GetTuningJobConfigOrDict] = None,
) -> types.TuningJob:
"""Gets a tuning job by name.
Args:
name: Tuning job resource name.
config: Optional request configuration.
"""
Import
from google import genai
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| name | str | Yes | Tuning job resource name from TuningJob.name |
| config | Optional[GetTuningJobConfigOrDict] | No | Optional request config |
Outputs
| Name | Type | Description |
|---|---|---|
| TuningJob | types.TuningJob | Updated job with .state, .tuned_model, .create_time, .end_time |
Usage Examples
Polling Loop
import time
from google import genai
client = genai.Client(vertexai=True, project="my-project", location="us-central1")
# After launching a job
job_name = tuning_job.name
while True:
job = client.tunings.get(name=job_name)
print(f"State: {job.state}")
if job.state == "JOB_STATE_SUCCEEDED":
print(f"Tuned model: {job.tuned_model.endpoint}")
break
elif job.state in ("JOB_STATE_FAILED", "JOB_STATE_CANCELLED"):
print(f"Job ended: {job.state}")
break
time.sleep(60) # Poll every 60 seconds
Use Tuned Model After Completion
# Once job succeeds, use the tuned model
job = client.tunings.get(name=job_name)
if job.state == "JOB_STATE_SUCCEEDED":
response = client.models.generate_content(
model=job.tuned_model.endpoint,
contents="Classify: This product is amazing!"
)
print(response.text)