Package ai.djl.serving.wlm
Class Job<I,O>
- java.lang.Object
-
- ai.djl.serving.wlm.Job<I,O>
-
public class Job<I,O> extends java.lang.ObjectA class represents an inference job.
-
-
Constructor Summary
Constructors Constructor Description Job(WorkerPoolConfig<I,O> wpc, I input)Constructs a newJobinstance.Job(WorkerPoolConfig<I,O> wpc, I input, JobFunction<I,O> runner)Constructs a newJobinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IgetInput()Returns the input data.OgetOutput()Returns the output data.java.util.Optional<JobFunction<I,O>>getRunner()Returns the task to run for the job.longgetWaitingMicroSeconds()Returns the wait time of this job.WorkerPoolConfig<I,O>getWpc()Returns the worker pool config that is associated with this job.static <I,O>
voidrunAll(java.util.List<Job<I,O>> jobs, JobFunction<I,O> f)Runs aJobFunctionon a batch of jobs and sets the result in their output.static voidsetFailOutput(Job<ai.djl.modality.Input,ai.djl.modality.Output> job, int code, java.lang.String message)Sets aJoboutput to a failure.voidsetOutput(O output)Sets the output of the job.
-
-
-
Constructor Detail
-
Job
public Job(WorkerPoolConfig<I,O> wpc, I input)
Constructs a newJobinstance.- Parameters:
wpc- the model to run the jobinput- the input data
-
Job
public Job(WorkerPoolConfig<I,O> wpc, I input, JobFunction<I,O> runner)
Constructs a newJobinstance.- Parameters:
wpc- the model to run the jobinput- the input datarunner- the function to run on worker
-
-
Method Detail
-
runAll
public static <I,O> void runAll(java.util.List<Job<I,O>> jobs, JobFunction<I,O> f) throws ai.djl.translate.TranslateException
Runs aJobFunctionon a batch of jobs and sets the result in their output.- Type Parameters:
I- the input typeO- the output type- Parameters:
jobs- the jobs to run and updatef- the function to run- Throws:
ai.djl.translate.TranslateException- if the jobs fail to run
-
setFailOutput
public static void setFailOutput(Job<ai.djl.modality.Input,ai.djl.modality.Output> job, int code, java.lang.String message)
Sets aJoboutput to a failure.- Parameters:
job- the job to set the output oncode- the failure codemessage- the failure message
-
getWpc
public WorkerPoolConfig<I,O> getWpc()
Returns the worker pool config that is associated with this job.- Returns:
- the worker pool config that is associated with this job
-
getInput
public I getInput()
Returns the input data.- Returns:
- the input data
-
getOutput
public O getOutput()
Returns the output data.- Returns:
- the output data
-
setOutput
public void setOutput(O output)
Sets the output of the job.- Parameters:
output- the job output
-
getWaitingMicroSeconds
public long getWaitingMicroSeconds()
Returns the wait time of this job.- Returns:
- the wait time of this job in mirco seconds
-
getRunner
public java.util.Optional<JobFunction<I,O>> getRunner()
Returns the task to run for the job.- Returns:
- the task to run for the job
-
-