JobManagerClient¶
-
class
scenebox.clients.
JobManagerClient
(auth_token, asset_manager_url=None, job_id=None, asset_type=None, asset_id=None, username=None, job_type=None, notes=None, description=None, stage=None, tags=None, user_facing=False, task_sync=False, resubmittable=False, task_id=None, email_notification=False)¶ Client for interacting with the Job Manager.
asset_manager_url: URL to asset manager auth_token: Auth token to use job_id: unique identifier of a job asset_type: Type of asset ( used for updating job metadata) asset_id: Asset ID (used for updating job metadata) username: Username (used for updating job metadata) job_type: Type of the job (used for updating job metadata) notes: time-history of the events in the job (started at what time, queued at what time) (used for updating job metadata) description: the description of the job (used for updating job metadata) stage: Job stage (used for updating job metadata) ttl: job’s time to live in seconds sync_interval: Time interval to wait before checking if timeout > TTL or job failure, email_notification: If True, user will receive email notification when job is aborted.
Methods
abort job
finish job
Get the job_manager_client.Job object.
Get the progress of a job in percentage :returns: number between 0 to 100 :rtype: float
Get the status of a job :returns: queued | running | finished | aborted :rtype: str
Resubmit a job.
run job
update the job progress
update the stage of a job
Wait for a job to complete.
Attributes
STATUS_ABORTED
STATUS_FINISHED
STATUS_QUEUED
STATUS_RUNNING
-
run
(cpu_core=None, hostname=None)¶ run job
-
finish
()¶ finish job
-
abort
(revoke_celery_job=False, error_string='', exception=None)¶ abort job
-
update_stage
(stage)¶ update the stage of a job
- Parameters:
stage – a message that could describe the current stage of the job
-
get_status
()¶ Get the status of a job :returns: queued | running | finished | aborted :rtype: str
-
get_progress
()¶ Get the progress of a job in percentage :returns: number between 0 to 100 :rtype: float
-
update_progress
(progress, raise_on_abort_canceled=False, message=None, force_update=False, min_progress=0.0, max_progress=100.0)¶ update the job progress
- Parameters:
progress – percentage of job progress - between 0 and 100
raise_on_abort_canceled – raise JobError if job is canceled or aborted when this is True
message – status update string
force_update – should force update regardless of the last_progress status
min_progress – min progress default at 0
max_progress – max progress default at 100
-
resubmit
()¶ Resubmit a job.
-
get_job
()¶ Get the job_manager_client.Job object.
Can be a currently executing or finished Job.
- Returns:
Job object with the job id
job_id
.- Return type:
Job
-
wait_for_completion
(increments_sec=10, enable_max_wait=False, max_wait_sec=300, progress_callback=None)¶ Wait for a job to complete.
Input a max waiting time before an unfinished job throws an Exception. Choose to either poll while a job is in progress, or enact a callable function
progress_callback()
with every increment set byincrements_sec
.- Parameters:
job_id – The ID of the job in progress.
increments_sec – The amount of time to poll in between checking job status and calling progress_callback().
enable_max_wait – If True, immediately throws an Exception. Intended for use when there is an external timing constraint. Otherwise, does nothing.
max_wait_sec – The maximum amount of time to wait for a job to finish before throwing an exception. Measured in seconds.
progress_callback – Callback function to log the progress of the inference job. The callback should accept a parameter of type float for progress and str for progress message.
- Raises:
JobError – If job encounters an error, and could not complete. If job does not finish after
max_wait_sec
seconds.
-