Class Job<I,​O>


  • public class Job<I,​O>
    extends java.lang.Object
    A class represents an inference job.
    • Constructor Detail

      • 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 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 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,
                                         java.lang.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 java.util.Optional<JobFunction<I,​O>> getRunner()
        Returns the task to run for the job.
        Returns:
        the task to run for the job