InferenceJob

class InferenceJob(job_pb, owner, device, model, date, inputs)

Inference job for a model, user provided inputs, and a device.

An inference job should not be constructed directly. It is constructed by the hub client through qai_hub.submit_inference_job(), or qai_hub.get_job().

device

The device for this job.

Type:

Device

model

The model for the job.

Type:

Model

date

The time this job was submitted.

Type:

datetime

inputs

The inputs provided by user.

Type:

Dataset

disable_sharing()

Disable all sharing for this job.

Return type:

None

download_output_data(filename=None)

Returns the downloaded output data, either in memory or as a h5f file.

If the job is not ready, this function will block until completion.

Parameters:

filename (Optional[str]) – If filename is specified the output data is downloaded to file, otherwise to memory.

Returns:

The downloaded output data, filename, or None if the job failed.

Return type:

DatasetEntries | str | None

download_results(artifacts_dir)

Returns all the results of an inference job.

If the job is not ready, this function will block until completion.

Parameters:

artifacts_dir (str) – Directory name where the job artifacts are stored. If the directory does not exist, it is cretaed.

Returns:

Job results.

Return type:

InferenceJobResult

get_output_dataset()

Returns the output dataset for a job.

If the job is not ready, this function will block until completion.

Returns:

The output data if the job succeeded

Return type:

Dataset | None

get_sharing()

Get the list of email addresses of users that this job has been shared with.

Return type:

List[str]

get_status()

Returns the status of a job.

Returns:

The status of the job

Return type:

JobStatus

modify_sharing(add_emails=[], delete_emails=[])

Modifies the list of users that the job is shared with.

Return type:

None

set_name(job_name)

Sets the name of a job to the specified value.

Return type:

None

property url: str

Returns the URL for the job.

Returns:

The URL for the job.

Return type:

str

wait(timeout=None)

Block until this job finishes.

Parameters:

timeout (Optional[int]) –

If provided, a TimeoutError will be raised after waiting this many seconds.

If None, this client will not time out the job, meaning it will block an indefinite amount of time waiting for the job to finish.

HOWEVER, Qualcomm AI Hub will fail / time out any job a set amount of time after its creation. Therefore, even if timeout is None, the runtime of this method will still have a finite upper bound.

Returns:

The final, “finished” (SUCCESS or FAILED) status for this job.

Return type:

str

Raises:

TimeoutError – Raised only if a client-side timeout occurs, when param “timeout” != None. If the Qualcomm AI Hub server times out the job, this error will NOT be raised, and a FAILED job status will be returned instead.