Skip to main content

AddCoPilotToPod

Adds CoPilot-related containers and volumes to a Kubernetes PodSpec if CoPilot is enabled. It configures init containers for downloading inputs and a sidecar container for uploading outputs, based on the task's interface and CoPilot configuration.

def AddCoPilotToPod(
ctx: context.Context,
cfg: config.FlyteCoPilotConfig,
coPilotPod: *v1.PodSpec,
iFace: *core.TypedInterface,
taskExecMetadata: core2.TaskExecutionMetadata,
inputPaths: io.InputFilePaths,
outputPaths: io.OutputFilePaths,
pilot: *core.DataLoadingConfig
) - > error

Configures a Kubernetes PodSpec to include CoPilot containers for data loading and uploading, enabling efficient data handling for tasks. This function should be used to inject CoPilot functionality into a pod definition.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, used for logging and cancellation.
cfgconfig.FlyteCoPilotConfigThe CoPilot configuration, including default paths, volume names, and timeouts.
coPilotPod*v1.PodSpecThe Kubernetes PodSpec to which CoPilot volumes and init containers will be added.
iFace*core.TypedInterfaceThe typed interface of the task, containing definitions for inputs and outputs, used to determine what data needs to be handled by CoPilot.
taskExecMetadatacore2.TaskExecutionMetadataMetadata about the task execution, including task ID and resource overrides, used for logging and calculating storage size.
inputPathsio.InputFilePathsThe paths to the input files for the task, which CoPilot will download.
outputPathsio.OutputFilePathsThe paths for the output files of the task, which CoPilot will upload.
pilot*core.DataLoadingConfigThe data loading configuration for CoPilot, indicating if it's enabled and specifying custom input/output paths and format.

Returns

TypeDescription
errorAn error if any configuration or container creation fails, otherwise nil.