Skip to content

feat: ContainerCodeExecutor should support input_files and output_files#5321

Open
hamdi-sakly wants to merge 4 commits intogoogle:mainfrom
hamdi-sakly:feat/container
Open

feat: ContainerCodeExecutor should support input_files and output_files#5321
hamdi-sakly wants to merge 4 commits intogoogle:mainfrom
hamdi-sakly:feat/container

Conversation

@hamdi-sakly
Copy link
Copy Markdown

Problem

ContainerCodeExecutor currently ignores CodeExecutionInput.input_files and always returns an empty output_files list, making it impossible to:

  • Pass files into the container
  • Retrieve generated files from the container

Solution

Implement file I/O support using Docker's archive API:

Input files

Use container.put_archive() to copy input files into the container before code execution.

  • Input directory: /tmp/inputs/ (configurable via input_dir)

Output files

Use container.get_archive() to retrieve files from the container after execution.

  • Output directory: /tmp/outputs/ (configurable via output_dir)

Configuration changes

Added configurable parameters:

  • input_dir (default: /tmp/inputs)
  • output_dir (default: /tmp/outputs)

This approach is self-contained and does not require:

  • Host filesystem access
  • Docker bind mounts

Testing Plan

Unit Tests

Added:
tests/unittests/code_executors/test_container_code_executor.py

Test coverage

TestContainerCodeExecutorInit

  • Initialization with new parameters

TestExecuteCode

  • Basic execution
  • Input files handling
  • Output files retrieval

TestPutInputFiles

  • Tar archive creation
  • put_archive calls verification

TestGetOutputFiles

  • Archive extraction
  • Handling missing output directory (404 case)

TestMimeTypeGuessing

  • MIME type detection

Test Status

  • Unit tests pass locally (syntax validation successful)
  • Full pytest collection failed due to unrelated environment issue:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant