tensorbay.client.job#

Basic structures of asynchronous jobs.

class tensorbay.client.job.Job(client, dataset_id, job_updater, title, job_id, job_type, 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.

  • job_type (str) – Type 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>
        "jobType"" <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

class tensorbay.client.job.SquashAndMergeJob(client, *, dataset_id, job_updater, draft_getter, title, job_id, job_type, 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.

  • job_type (str) – Type 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>
        "jobType"" <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

retry()[source]#

Retry a SquashAndMergeJob.

Return type

None

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

Bases: tensorbay.client.job.Job

This class defines BasicSearchJob.

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

  • dataset_id (str) –

  • job_updater (Callable[[str], Dict[str, Any]]) –

  • is_fusion (bool) –

  • title (str) –

  • job_id (str) –

  • job_type (str) –

  • arguments (Dict[str, Any]) –

  • created_at (int) –

  • started_at (Optional[int]) –

  • finished_at (Optional[int]) –

  • status (str) –

  • error_message (str) –

  • result (Optional[Dict[str, Any]]) –

  • description (Optional[str]) –

Return type

None

property result: Optional[Union[tensorbay.client.search.SearchResult, tensorbay.client.search.FusionSearchResult]]#

Get the result of the BasicSearchJob.

Returns

The search result of the BasicSearchJob.

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

Loads a BasicSearchJob object from a response body.

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

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

    {
        "title": <str>
        "jobId": <str>
        "jobType"" <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 BasicSearchJob instance.

  • if_fusion – Whether it is from fusion dataset.

  • is_fusion (bool) –

Returns

The loaded BasicSearchJob object.

Return type

tensorbay.client.job._T

create_dataset(name, alias='', is_public=False)[source]#

Create a TensorBay dataset based on the search job.

Parameters
  • name (str) – Name of the dataset, unique for a user.

  • alias (str) – Alias of the dataset, default is “”.

  • is_public (bool) – Whether the dataset is a public dataset.

Return type

None