A containerized Python code execution service that provides an API for running Python code in isolated sessions. This service is designed for local development and experimentation.
This is intended for local development only - not for production deployment. The service allows arbitrary code execution and is designed to run in a disposable Docker container.
-
Start the service:
cd interpreter docker-compose up --build -d -
Verify it's running:
curl http://localhost:8123/health
-
Stop the service:
docker-compose down
- All code runs inside a Docker container
- Container is disposable - can be rebuilt if corrupted
- No access to host system beyond mounted directories
The Docker container has read-write access to specific host directories:
volumes:
- ../eval/kaggle_data/spooky:/app/spooky:rw
- ../eval/kaggle_data/jigsaw:/app/jigsaw:rw- Modify or delete files in
../eval/kaggle_data/spooky - Modify or delete files in
../eval/kaggle_data/jigsaw - Create new files in these directories
✅ Code CANNOT access:
- Your home directory
- Other projects
- System files
- Any directories outside the mounted volumes
For safer operation, consider changing to read-only mounts in docker-compose.yml:
volumes:
- ../eval/kaggle_data/spooky:/app/spooky:ro # read-only
- ../eval/kaggle_data/jigsaw:/app/jigsaw:ro # read-onlyWhile the service provides basic session isolation, it has important limitations:
- User variables:
x = 1in one session won't affect another session - Session state: Each session maintains its own execution context
- Module modifications: Changes to imported libraries affect ALL sessions
- Global state changes: Modifications to
sys.path,os.environ, etc. are shared - Library monkey-patching: Modifying
json.dumps,numpysettings, etc. corrupts other sessions
# These operations will affect ALL sessions:
import json
json.dumps = custom_function # ❌ Breaks all sessions
import sys
sys.path.append('/custom/path') # ❌ Affects all sessions
import os
os.environ['KEY'] = 'value' # ❌ Global environment change- Data analysis workflows: Reading CSV/JSON files, pandas operations
- Machine learning: Training models, feature engineering
- Visualization: Creating plots with matplotlib, seaborn
- Standard data science: EDA, data cleaning, hypothesis testing
main.py- FastAPI application with endpointscode_executor.py- Core code execution logicsession_manager.py- Session handling and isolationdownload_data.py- Data download from HuggingFaceDockerfile- Container configurationdocker-compose.yml- Service orchestrationrequirements.txt- Python dependencies
To completely remove the service and data:
# Stop and remove containers
docker-compose down
# Remove downloaded data
rm -rf downloaded_data/
# Remove custom uploaded data
rm -rf custom_data/
# Remove Docker images (optional)
docker image prune -f