A Micro-benchmarking Framework for Python Type Inference Tools
๐ Features:
- ๐ Contains 154 code snippets to test and benchmark.
- ๐ท Offers 845 type annotations across a diverse set of Python functionalities.
- ๐ Organized into 18 distinct categories targeting various Python features.
- ๐ข Seamlessly manages the execution of containerized tools.
- ๐ Efficiently transforms inferred types into a standardized format.
- ๐ Automatically produces meaningful metrics for in-depth assessment and comparison.
[New] TypeEvalPy Autogen
- ๐ค Autogenerates code snippets and ground truth to scale the benchmark based on the original
TypeEvalPy benchmark.
- ๐ The autogen benchmark now contains:
- Python files: 7121
- Type annotations: 78373
๐ ๏ธ Supported Tools
๐ TypeEvalPy Leaderboard
Below is a comparison showcasing exact matches across different tools and LLMs on the Autogen benchmark.
(Auto-generated based on the the analysis run on 30 Aug 2024)
:whale: Running with Docker
1๏ธโฃ Clone the repo
git clone https://github.com/secure-software-engineering/TypeEvalPy.git
2๏ธโฃ Build Docker image
docker build -t typeevalpy .
3๏ธโฃ Run TypeEvalPy
๐ Takes about 30mins on first run to build Docker containers.
๐ Results will be generated in the results folder within the root directory of the repository.
Each results folder will have a timestamp, allowing you to easily track and compare different runs.
Correlation of CSV Files Generated to Tables in ICSE Paper
Here is how the auto-generated CSV tables relate to the paper's tables:
Additionally, there are CSV tables that are not included in the paper:
paper_table_4.csv - containing Sound and Complete values for 18 micro-benchmark categories.
paper_table_6.csv - featuring Sensitivity analysis.
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ./results:/app/results \
typeevalpy
๐ง Optionally, run analysis on specific tools:
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ./results:/app/results \
typeevalpy --runners headergen scalpel
๐ Run analysis on custom benchmarks:
Here, running with the autogen benchmark on HeaderGen
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ./results:/app/results \
typeevalpy \
--runners headergen \
--custom_benchmark_dir /app/autogen_typeevalpy_benchmark
๐ ๏ธ Available options: headergen, pyright, scalpel, jedi, hityper, type4py, hityperdl
๐ค Running TypeEvalPy with LLMs
TypeEvalPy integrates with LLMs through Ollama, streamlining their management. Begin by setting up your environment:
- Create Configuration File: Copy the
config_template.yaml from the src directory and rename it to config.yaml.
In the config.yaml, configure in the following:
openai_key: your key for accessing OpenAI's models.
ollama_url: the URL for your Ollama instance. For simplicity, we recommend deploying Ollama using their Docker container. Get started with Ollama here.
prompt_id: set this to questions_based_2 for optimal performance, based on our tests.
ollama_models: select a list of model tags from the Ollama library. For better operation, ensure the model is pre-downloaded with the ollama pull command.
With the config.yaml configured, run the following command:
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ./results:/app/results \
typeevalpy --runners ollama
Running From Source...
1. ๐ฅ Installation
Clone the repo
git clone https://github.com/secure-software-engineering/TypeEvalPy.git
Install Dependencies and Set Up Virtual Environment
Run the following commands to set up your virtual environment and activate the virtual environment.
python3 -m venv .env
source .env/bin/activate
pip install -r requirements.txt
2. ๐ Usage: Running the Analysis
Navigate to the src Directory
cd src
Execute the Analyzer
Run the following command to start the benchmarking process on all tools:
python main_runner.py
or
Run analysis on specific tools
python main_runner.py --runners headergen scalpel
Running TypeEvalPy Autogen
To generate an extended version of the original TypeEvalPy benchmark to include many more Python types, run the following commands:
Navigate to the autogen Directory
cd autogen
Execute the Generation Script
Run the following command to start the generation process:
python generate_typeevalpy_dataset.py
This will generate a folder in the repo root with the autogen benchmark with the current date.
Running TypeEvalPy with ManyType4Py dataset