Class ContainerCodeExecutor


public class ContainerCodeExecutor extends BaseCodeExecutor
A code executor that uses a custom container to execute code.
  • Constructor Details

    • ContainerCodeExecutor

      @Deprecated public ContainerCodeExecutor(String baseUrl, String image, String dockerPath)
      Deprecated.
      Use one of the static factory methods instead.
      Initializes the ContainerCodeExecutor. Either dockerPath or image must be set.
  • Method Details

    • fromImage

      public static ContainerCodeExecutor fromImage(String baseUrl, String image)
      Creates a ContainerCodeExecutor from an image.
      Parameters:
      baseUrl - The base url of the user hosted Docker client.
      image - The tag of the predefined image or custom image to run on the container.
    • fromImage

      public static ContainerCodeExecutor fromImage(String image)
      Creates a ContainerCodeExecutor from an image.
      Parameters:
      image - The tag of the predefined image or custom image to run on the container.
    • fromDockerPath

      public static ContainerCodeExecutor fromDockerPath(String baseUrl, String dockerPath)
      Creates a ContainerCodeExecutor from a Dockerfile path.
      Parameters:
      baseUrl - The base url of the user hosted Docker client.
      dockerPath - The path to the directory containing the Dockerfile.
    • fromDockerPath

      public static ContainerCodeExecutor fromDockerPath(String dockerPath)
      Creates a ContainerCodeExecutor from a Dockerfile path.
      Parameters:
      dockerPath - The path to the directory containing the Dockerfile.
    • stateful

      public boolean stateful()
      Description copied from class: BaseCodeExecutor
      Whether the code executor is stateful. Default to False.
      Overrides:
      stateful in class BaseCodeExecutor
    • optimizeDataFile

      public boolean optimizeDataFile()
      Description copied from class: BaseCodeExecutor
      If true, extract and process data files from the model request and attach them to the code executor.

      Supported data file MimeTypes are [text/csv]. Default to False.

      Overrides:
      optimizeDataFile in class BaseCodeExecutor
    • executeCode

      public CodeExecutionUtils.CodeExecutionResult executeCode(InvocationContext invocationContext, CodeExecutionUtils.CodeExecutionInput codeExecutionInput)
      Description copied from class: BaseCodeExecutor
      Executes code and return the code execution result.

      This method may perform blocking operations.

      Specified by:
      executeCode in class BaseCodeExecutor
      Parameters:
      invocationContext - The invocation context of the code execution.
      codeExecutionInput - The code execution input.
      Returns:
      The code execution result.