tensorbay.client.job

Basic structures of asynchronous jobs.

class tensorbay.client.job.Job(client, dataset_id, job_updater, title, job_id, arguments, created_at, started_at, finished_at, status, error_message, result, description='')[source]

Bases: tensorbay.utility.attr.AttrsMixin, tensorbay.utility.repr.ReprMixin

This class defines Job.

Parameters
  • client (tensorbay.client.requests.Client) – The Client.

  • dataset_id (str) – Dataset ID.

  • job_updater (Callable[[str], Dict[str, Any]]) – The function to update the information of the Job instance.

  • title (str) – Title of the Job.

  • job_id (str) – ID of the Job.

  • arguments (Dict[str, Any]) – Arguments of the Job.

  • created_at (int) – The time when the Job is created.

  • started_at (Optional[int]) – The time when the Job is started.

  • finished_at (Optional[int]) – The time when the Job is finished.

  • status (str) – The status of the Job.

  • error_message (str) – The error message of the Job.

  • result (Optional[Dict[str, Any]]) – The result of the Job.

  • description (Optional[str]) – The description of the Job.

Return type

None

classmethod from_response_body(body, *, client, dataset_id, job_updater)[source]

Loads a Job object from a response body.

Parameters
  • body (Dict[str, Any]) –

    The response body which contains the information of a job, whose format should be like:

    {
        "title": <str>
        "jobId": <str>
        "arguments": <object>
        "createdAt": <int>
        "startedAt": <int>
        "finishedAt": <int>
        "status": <str>
        "errorMessage": <str>
        "result": <object>
        "description": <str>
    }
    

  • client (tensorbay.client.requests.Client) – The Client.

  • dataset_id (str) – Dataset ID.

  • job_updater (Callable[[str], Dict[str, Any]]) – The function to update the information of the Job instance.

Returns

The loaded Job object.

Return type

tensorbay.client.job._T

update(until_complete=False)[source]

Update attrs of the Job instance.

Parameters

until_complete (bool) – Whether to update job information until it is complete.

Return type

None

abort()[source]

Abort a Job.

Return type

None

retry()[source]

Retry a Job.

Return type

None

class tensorbay.client.job.SquashAndMergeJob(client, dataset_id, job_updater, draft_getter, title, job_id, arguments, created_at, started_at, finished_at, status, error_message, result, description='')[source]

Bases: tensorbay.client.job.Job

This class defines SquashAndMergeJob.

Parameters
  • client (tensorbay.client.requests.Client) – The Client.

  • dataset_id (str) – Dataset ID.

  • job_updater (Callable[[str], Dict[str, Any]]) – The function to update the information of the Job instance.

  • draft_getter (Callable[[int], tensorbay.client.struct.Draft]) – The function to get draft by draft_number.

  • title (str) – Title of the Job.

  • job_id (str) – ID of the Job.

  • arguments (Dict[str, Any]) – Arguments of the Job.

  • created_at (int) – The time when the Job is created.

  • started_at (Optional[int]) – The time when the Job is started.

  • finished_at (Optional[int]) – The time when the Job is finished.

  • status (str) – The status of the Job.

  • error_message (str) – The error message of the Job.

  • result (Optional[Dict[str, Any]]) – The result of the Job.

  • description (Optional[str]) – The description of the Job.

Return type

None

property result: Optional[tensorbay.client.struct.Draft]

Get the result of the SquashAndMergeJob.

Returns

The draft obtained from SquashAndMergeJob.

classmethod from_response_body(body, *, client, dataset_id, job_updater, draft_getter)[source]

Loads a SquashAndMergeJob object from a response body.

Parameters
  • body (Dict[str, Any]) –

    The response body which contains the information of a SquashAndMergeJob, whose format should be like:

    {
        "title": <str>
        "jobId": <str>
        "arguments": <object>
        "createdAt": <int>
        "startedAt": <int>
        "finishedAt": <int>
        "status": <str>
        "errorMessage": <str>
        "result": <object>
        "description": <str>
    }
    

  • client (tensorbay.client.requests.Client) – The Client.

  • dataset_id (str) – Dataset ID.

  • job_updater (Callable[[str], Dict[str, Any]]) – The function to update the information of the SquashAndMergeJob instance.

  • draft_getter (Callable[[int], tensorbay.client.struct.Draft]) – The function to get draft by draft_number.

Returns

The loaded SquashAndMergeJob object.

Return type

tensorbay.client.job._T