Class Job<I,O>

java.lang.Object
ai.djl.serving.wlm.Job<I,O>

public class Job<I,O> extends Object
A class represents an inference job.
  • Constructor Details

    • Job

      public Job(WorkerPoolConfig<I,O> wpc, I input)
      Constructs a new Job instance.
      Parameters:
      wpc - the model to run the job
      input - the input data
    • Job

      public Job(WorkerPoolConfig<I,O> wpc, I input, JobFunction<I,O> runner)
      Constructs a new Job instance.
      Parameters:
      wpc - the model to run the job
      input - the input data
      runner - the function to run on worker
  • Method Details

    • runAll

      public static <I, O> void runAll(List<Job<I,O>> jobs, JobFunction<I,O> f) throws ai.djl.translate.TranslateException
      Runs a JobFunction on a batch of jobs and sets the result in their output.
      Type Parameters:
      I - the input type
      O - the output type
      Parameters:
      jobs - the jobs to run and update
      f - 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, String message)
      Sets a Job output to a failure.
      Parameters:
      job - the job to set the output on
      code - the failure code
      message - 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 Optional<JobFunction<I,O>> getRunner()
      Returns the task to run for the job.
      Returns:
      the task to run for the job