Skip to content

Repository files navigation

migration_tuning

Test if code models are able to perform/be tuned for migration purposes

Setup

Quick Setup (Recommended)

Run the unified setup script that checks and installs everything automatically:

# Windows
python scripts/setup_all.py

# Linux/Mac
python3 scripts/setup_all.py

This script will:

  • Check for Rust, Node.js, and C++ compiler
  • Automatically install missing tools (where possible)
  • Download Catch2 testing framework
  • Set up Python environment with uv

Manual Setup

If you prefer manual setup or the automated script doesn't work:

1. Install uv (Python package manager)

# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

# Linux/Mac
curl -LsSf https://astral.sh/uv/install.sh | sh

2. Install Python dependencies

uv sync

This will create a virtual environment and install all Python dependencies.

3. Install language toolchains

Node.js (for JavaScript tests)

  • Download and install from: https://nodejs.org/
  • Or use a version manager like nvm:
    nvm install 20
    nvm use 20

Rust (for Rust tests)

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

C++ Compiler (for C++ tests)

  • Linux: sudo apt-get install g++
  • Mac: xcode-select --install
  • Windows: Install MinGW-w64 or use WSL

Catch2 (C++ testing framework)

# Option 1: Download single header (recommended)
python scripts/install_catch2.py

# Option 2: Install via package manager
# Linux: sudo apt-get install catch2
# Mac: brew install catch2
# Or download from: https://github.com/catchorg/Catch2/releases

4. Verify installation

# Activate uv environment
uv run python scripts/setup_environment.py

This will check if all required tools are installed.

Usage

Running data preparation scripts

# 1. Download and split MBPP dataset
uv run python scripts/00_make_splits.py

# 2. Canonicalize the dataset
uv run python scripts/01_canonicalize.py

# 3. Convert tests to different languages
uv run python scripts/02_convert_tests.py

Running test runners

from runners import run_js_test, run_cpp_test, run_rust_test

# Test a JavaScript solution
result = run_js_test(
    test_id=511,
    solution_code="function find_Min_Sum(num) { ... }"
)

# Test a C++ solution
result = run_cpp_test(
    test_id=511,
    solution_code="int find_Min_Sum(int num) { ... }"
)

# Test a Rust solution
result = run_rust_test(
    test_id=511,
    solution_code="pub fn find_Min_Sum(num: i32) -> i32 { ... }"
)

Project Structure

migration_tuning/
├── data/
│   ├── mbpp_raw/          # Raw MBPP dataset
│   ├── splits/            # Train/validation splits
│   └── canonical/         # Canonicalized data
├── gen/
│   ├── tests/             # Generated test files
│   │   ├── js/
│   │   ├── cpp/
│   │   └── rust/
│   └── solutions/         # Solution files
│       ├── js/
│       ├── cpp/
│       └── rust/
├── runners/                # Test runners for each language
├── scripts/                # Data processing scripts
└── pyproject.toml          # uv project configuration

Test Runner Output

Each runner returns a dictionary with:

  • status: 'pass' | 'compile_error' | 'runtime_error' | 'timeout' | 'wrong_answer'
  • passed_tests: Number of tests that passed
  • total_tests: Total number of tests
  • stderr: Error output
  • stdout: Standard output

About

Test if code models are able to perform/be tuned for migration purposes

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages