Class Workflow

java.lang.Object
ai.djl.serving.workflow.Workflow
All Implemented Interfaces:
AutoCloseable

public class Workflow extends Object implements AutoCloseable
A flow of executing Models and custom functions.
  • Field Details

  • Constructor Details

    • Workflow

      public Workflow(ai.djl.serving.wlm.WorkerPoolConfig<ai.djl.modality.Input,ai.djl.modality.Output> wpc)
      Constructs a workflow containing only a single workerPoolConfig.
      Parameters:
      wpc - the workerPoolConfig for the workflow
    • Workflow

      public Workflow(String name, String version, Map<String,ai.djl.serving.wlm.WorkerPoolConfig<ai.djl.modality.Input,ai.djl.modality.Output>> wpcs, Map<String,WorkflowExpression> expressions, Map<String,Map<String,Object>> configs, Map<String,WorkflowFunction> funcs)
      Constructs a workflow.
      Parameters:
      name - workflow name
      version - workflow version
      wpcs - a map of executableNames for a wpc (how it is referred to in the WorkflowExpressions to model
      expressions - a map of names to refer to an expression to the expression
      configs - the configuration objects
      funcs - the custom functions used in the workflow
  • Method Details

    • getWpcs

      public Collection<ai.djl.serving.wlm.WorkerPoolConfig<ai.djl.modality.Input,ai.djl.modality.Output>> getWpcs()
      Returns the WorkerPoolConfigs used in the workflow.
      Returns:
      the wpcs used in the workflow
    • getWpcMap

      public Map<String,ai.djl.serving.wlm.WorkerPoolConfig<ai.djl.modality.Input,ai.djl.modality.Output>> getWpcMap()
      Returns the wpc map in the workflow.
      Returns:
      the wpc map in the workflow
    • prepare

      public void prepare(ai.djl.serving.wlm.WorkLoadManager wlm)
      Prepares this workflow for use.

      This is idempotent and can be safely re-called if this is already prepared. It should re-call to ensure preparedness.

      Parameters:
      wlm - the wlm to prepare with
    • execute

      public CompletableFuture<ai.djl.modality.Output> execute(ai.djl.serving.wlm.WorkLoadManager wlm, ai.djl.modality.Input input)
      Executes a workflow with an input.
      Parameters:
      wlm - the wlm to run the workflow with
      input - the input
      Returns:
      a future of the result of the execution
    • getName

      public String getName()
      Returns the workflow name.
      Returns:
      the workflow name
    • getVersion

      public String getVersion()
      Returns the workflow version.
      Returns:
      the workflow version
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable