kumoai.trainer.BatchPredictionJob#

class kumoai.trainer.BatchPredictionJob[source]#

Bases: KumoFuture[BatchPredictionJobResult]

Represents an in-progress batch prediction job.

A BatchPredictionJob object can either be created as the result of predict() with non_blocking=True, or directly with a batch prediction job ID (e.g. of a job created asynchronously in a different environment).

import kumoai

# See `Trainer` documentation:
trainer = kumoai.Trainer(...)

# If a Trainer `predict` is called in nonblocking mode, the response
# will be of type `BatchPredictionJob`:
prediction_job = trainer.predict(..., non_blocking=True)

# You can also construct a `BatchPredictionJob` from a job ID, e.g. one
# that is present in the Kumo Jobs page:
prediction_job = kumoai.BatchPredictionJob("bp-job-...")

# Get the status of the job:
print(prediction_job.status())

# Attach to the job, and poll progress updates:
prediction_job.attach()
# Attaching to batch prediction job <id>. To track this job...
# Predicting (job_id=..., start=..., elapsed=..., status=...). Stage: ...

# Cancel the job:
prediction_job.cancel()

# Wait for the job to complete, and return a `BatchPredictionJobResult`:
prediction_job.result()
Parameters:

job_id (str) – The batch prediction job ID to await completion of.

__init__(job_id)[source]#
property id: str#

The unique ID of this batch prediction job.

result()[source]#

Returns the resolved state of the future.

Raises:

Exception – If the future is complete but in a failed state due to an exception being raised, this method will raise the same exception.

Return type:

BatchPredictionJobResult

future()[source]#

Returns the concurrent.futures.Future object wrapped by this future. It is not recommended to access this object directly.

property tracking_url: str#

Returns a tracking URL pointing to the UI that can be used to monitor the status of an ongoing or completed job.

attach()[source]#

Allows a user to attach to a running batch prediction job, and view its progress inline.

Return type:

BatchPredictionJobResult

progress()[source]#

Returns the progress of an ongoing or completed batch prediction job.

Return type:

PredictionProgress

status()[source]#

Returns the status of a running batch prediction job.

Return type:

JobStatusReport

cancel()[source]#

Cancels a running batch prediction job, and returns True if cancellation succeeded.

Return type:

bool

delete_tags(tags)[source]#

Removes the tags from the job.

Parameters:

tags (List[str]) – The tags to remove.

Return type:

bool

update_tags(tags)[source]#

Updates the tags of the job.

Parameters:

tags (Mapping[str, Optional[str]]) – The tags to update. Note that the value ‘none’ will remove the tag. If the tag is not present, it will be added.

Return type:

bool

static __new__(cls, *args, **kwds)#
done()#

Returns True if this future has been resolved with result(), or False if this future is still in-progress. Note that this method will return True if the future is complete, but in a failed state, and that this method will return False if the job is complete, but the future has not been awaited.

Return type:

bool