Job
API reference for Job
Job
Represents an asynchronous operation in the Fiddler platform.
A Job tracks the execution of long-running operations such as data publishing, model artifact uploads, surrogate model training, and other async tasks. Jobs provide status monitoring, progress tracking, and error handling for operations that may take significant time to complete.
Key Features:
Status Monitoring: Real-time tracking of job execution state
Progress Tracking: Percentage completion for running operations
Error Reporting: Detailed error messages and failure reasons
Timeout Handling: Configurable timeouts for job completion
Responsive Polling: Efficient status checking with backoff strategies
Job States:
PENDING: Job queued and waiting to start execution
STARTED: Job actively running with progress updates
SUCCESS: Job completed successfully
FAILURE: Job failed with detailed error information
RETRY: Job being retried after a failure
REVOKED: Job cancelled or terminated
Example
# Get a job by ID
job = Job.get(id_=”550e8400-e29b-41d4-a716-446655440000”)
print(f”Job: {job.name} - Status: {job.status}”)
print(f”Progress: {job.progress:.1f}%”)
# Wait for job completion
job.wait(timeout=1800) # 30 minute timeout
print(“Job completed successfully!”)
# Monitor job progress in real-time
for job_update in job.watch(interval=10, timeout=3600):
print(f”{job_update.name}: {job_update.progress:.1f}%”)
if job_update.status in [JobStatus.SUCCESS, JobStatus.FAILURE]:
breakInitialize a Job instance.
Creates a job object for tracking asynchronous operations. This constructor is typically used internally when deserializing API responses rather than for direct job creation.
classmethod get(id_, verbose=False)
Retrieve a job by its unique identifier.
Fetches a job from the Fiddler platform using its UUID. This is the primary way to retrieve job information for monitoring async operations.
Parameters
verbose
bool
✗
None
Whether to include detailed task execution information. When True, provides additional debugging and progress details.
Returns
The job instance with current status, progress, and metadata. Return type: Job
Raises
NotFound – If no job exists with the specified ID.
ApiError – If there’s an error communicating with the Fiddler API.
Example
# Get basic job information
job = Job.get(id_=”550e8400-e29b-41d4-a716-446655440000”)
print(f”Job: {job.name} - Status: {job.status}”)
print(f”Progress: {job.progress:.1f}%”)
# Get detailed job information for debugging
detailed_job = Job.get(
id_=”550e8400-e29b-41d4-a716-446655440000”,
verbose=True
)
print(f”Task details: {detailed_job.info}”)
# Check for errors
if job.status == JobStatus.FAILURE:
print(f”Error: {job.error_reason}”)
print(f”Details: {job.error_message}”)watch()
Monitor job progress with real-time status updates.
Continuously polls the job status at specified intervals and yields updated job instances. This method provides real-time monitoring of job progress and automatically handles network errors and retries.
Parameters
interval
int
✗
None
Polling interval in seconds between status checks. Default is configured by JOB_POLL_INTERVAL (typically 5-10 seconds).
timeout
int
✗
None
Maximum time in seconds to monitor the job before giving up. Default is configured by JOB_WAIT_TIMEOUT (typically 1800 seconds).
Yields
Job – Updated job instances with current status and progress.
Raises
TimeoutError – If the job doesn’t complete within the specified timeout.
AsyncJobFailed – If the job fails during execution (raised by wait() method). Return type: Iterator[Job]
Example
# Monitor job progress with default settings
job = model.publish(source=”large_dataset.csv”)
for job_update in job.watch():
print(f”Progress: {job_update.progress:.1f}%”)
print(f”Status: {job_update.status}”)
if job_update.status in [JobStatus.SUCCESS, JobStatus.FAILURE]:
break
# Custom polling interval and timeout
for job_update in job.watch(interval=30, timeout=7200): # 2 hour timeout
print(f”{job_update.name}: {job_update.progress:.1f}%”)
if job_update.status == JobStatus.SUCCESS:
print(“Job completed successfully!”)
break
elif job_update.status == JobStatus.FAILURE:
print(f”Job failed: {job_update.error_message}”)
break
# Progress tracking with custom logic
last_progress = 0
for job_update in job.watch(interval=15):
if job_update.progress > last_progress + 10:
print(f”Progress milestone: {job_update.progress:.1f}%”)
last_progress = job_update.progresswait()
Wait for job completion with automatic progress logging.
Blocks execution until the job completes (successfully or with failure). Provides automatic progress logging and raises an exception if the job fails. This is the most convenient method for simple job completion waiting.
Parameters
interval
int
✗
None
Polling interval in seconds between status checks. Default is configured by JOB_POLL_INTERVAL (typically 5-10 seconds).
timeout
int
✗
None
Maximum time in seconds to wait for job completion. Default is configured by JOB_WAIT_TIMEOUT (typically 1800 seconds).
Raises
TimeoutError – If the job doesn’t complete within the specified timeout.
AsyncJobFailed – If the job fails during execution, includes error details. Return type: None
Example
# Simple job completion waiting
job = model.publish(source=”training_data.csv”)
job.wait() # Blocks until completion
print(“Data publishing completed!”)
# Custom timeout for long-running jobs
job = model.add_artifact(model_dir=”./model_package”)
job.wait(timeout=3600) # 1 hour timeout
print(“Model artifact upload completed!”)
# Handle job failures
try:
job = model.publish(source=”invalid_data.csv”)
job.wait()
except AsyncJobFailed as e:
print(f”Job failed: {e}”)
# Handle failure (retry, alert, etc.)
# Fast polling for critical operations
job = model.update_surrogate(dataset_id=dataset.id)
job.wait(interval=5, timeout=600) # 5 second polling, 10 min timeoutLast updated
Was this helpful?