|
1 | 1 | # TypeEvalPy: A Micro-benchmarking Framework for Python Type Inference Tools |
2 | 2 |
|
3 | 3 | <p align="center"> |
| 4 | +<br> |
4 | 5 | <img src="TypeEvalPy.jpg" width="60%" align="center"> |
| 6 | +<br> |
5 | 7 | </p> |
6 | 8 |
|
7 | | - |
8 | 9 | ## 📌 **Key Features**: |
| 10 | + |
9 | 11 | - 📜 Contains **154 code snippets** to test and benchmark. |
10 | 12 | - 🏷 Offers **845 type annotations** across a diverse set of Python functionalities. |
11 | 13 | - 📂 Organized into **18 distinct categories** targeting various Python features. |
12 | 14 | - 🚢 Seamlessly manages the execution of **containerized tools**. |
13 | 15 | - 🔄 Efficiently transforms inferred types into a **standardized format**. |
14 | | -- 📊 Produces **meaningful metrics** for in-depth assessment and comparison. |
| 16 | +- 📊 Automatically produces **meaningful metrics** for in-depth assessment and comparison. |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## 🛠️ Supported Tools |
| 21 | + |
| 22 | +| Supported :white_check_mark: | In-progress :wrench: | Planned :bulb: | |
| 23 | +| -------------------------------------------------------- | -------------------------------------------------------------------- | ------------------------------------------ | |
| 24 | +| [HeaderGen](https://github.com/ashwinprasadme/headergen) | [Intellij PSI](https://plugins.jetbrains.com/docs/intellij/psi.html) | [Llama 2](https://ai.meta.com/llama/) | |
| 25 | +| [Jedi](https://github.com/davidhalter/jedi) | [Pyre](https://github.com/facebook/pyre-check) | [ChatGPT](https://openai.com/blog/chatgpt) | |
| 26 | +| [Pyright](https://github.com/microsoft/pyright) | [PySonar2](https://github.com/yinwang0/pysonar2) | |
| 27 | +| [HiTyper](https://github.com/JohnnyPeng18/HiTyper) | [Pytype](https://github.com/google/pytype) | |
| 28 | +| [Scalpel](https://github.com/SMAT-Lab/Scalpel/issues) | [TypeT5](https://github.com/utopia-group/TypeT5) | |
| 29 | +| [Type4Py](https://github.com/saltudelft/type4py) | | |
15 | 30 |
|
16 | 31 | --- |
17 | 32 |
|
18 | 33 | ## 🏆 TypeEvalPy Leaderboard |
19 | 34 |
|
20 | | -Below is a comparison showcasing exact matches across different tools, coupled with `top_n` predictions for our ML-based tools. |
| 35 | +Below is a comparison showcasing exact matches across different tools, coupled with `top_n` predictions for ML-based tools. |
21 | 36 |
|
22 | | -| 🛠️ Tool | Top-n | Function Return Type | Function Parameter Type | Local Variable Type | Total | |
23 | | -|----|----|----|----|----|----| |
24 | | -| **[HeaderGen](https://github.com/ashwinprasadme/headergen)** | 1 | 186 | 56 | 321 | 563 | |
25 | | -| **[Jedi](https://github.com/davidhalter/jedi)** | 1 | 122 | 0 | 293 | 415 | |
26 | | -| **[Pyright](https://github.com/microsoft/pyright)** | 1 | 100 | 8 | 297 | 405 | |
27 | | -| **[HiTyper](https://github.com/JohnnyPeng18/HiTyper)** | 1<br>3<br>5 | 163<br>173<br>175 | 27<br>37<br>37 | 179<br>225<br>229 | 369<br>435<br>441 | |
28 | | -| **[HiTyper (static)](https://github.com/JohnnyPeng18/HiTyper)** | 1 | 141 | 7 | 102 | 250 | |
29 | | -| **[Scalpel](https://github.com/SMAT-Lab/Scalpel/issues)** | 1 | 155 | 32 | 6 | 193 | |
30 | | -| **[Type4Py](https://github.com/saltudelft/type4py)** | 1<br>3<br>5 | 39<br>103<br>109 | 19<br>31<br>31 | 99<br>167<br>174 | 157<br>301<br>314 | |
| 37 | +| Rank | 🛠️ Tool | Top-n | Function Return Type | Function Parameter Type | Local Variable Type | Total | |
| 38 | +|----|----|----|----|----|----|----| |
| 39 | +| 1 | **[HeaderGen](https://github.com/ashwinprasadme/headergen)** | 1 | 186 | 56 | 322 | 564 | |
| 40 | +| 2 | **[Jedi](https://github.com/davidhalter/jedi)** | 1 | 122 | 0 | 293 | 415 | |
| 41 | +| 3 | **[Pyright](https://github.com/microsoft/pyright)** | 1 | 100 | 8 | 297 | 405 | |
| 42 | +| 4 | **[HiTyper](https://github.com/JohnnyPeng18/HiTyper)** | 1<br>3<br>5 | 163<br>173<br>175 | 27<br>37<br>37 | 179<br>225<br>229 | 369<br>435<br>441 | |
| 43 | +| 5 | **[HiTyper (static)](https://github.com/JohnnyPeng18/HiTyper)** | 1 | 141 | 7 | 102 | 250 | |
| 44 | +| 6 | **[Scalpel](https://github.com/SMAT-Lab/Scalpel/issues)** | 1 | 155 | 32 | 6 | 193 | |
| 45 | +| 7 | **[Type4Py](https://github.com/saltudelft/type4py)** | 1<br>3<br>5 | 39<br>103<br>109 | 19<br>31<br>31 | 99<br>167<br>174 | 157<br>301<br>314 | |
| 46 | + |
| 47 | +*<sub>(Auto-generated based on the the analysis run on 20-10-23 14:51)</sub>* |
31 | 48 |
|
32 | 49 | --- |
| 50 | +## :whale: Running with Docker |
| 51 | + |
| 52 | +### 1️⃣ Clone the repo |
| 53 | + |
| 54 | +```bash |
| 55 | +git clone https://github.com/ashwinprasadme/TypeEvalPy.git |
| 56 | +``` |
| 57 | + |
| 58 | +### 2️⃣ Build Docker image |
| 59 | + |
| 60 | +```bash |
| 61 | +docker build -t typeevalpy . |
| 62 | +``` |
| 63 | + |
| 64 | +### 3️⃣ Run TypeEvalPy |
33 | 65 |
|
34 | | -## 📥 Installation |
| 66 | +🕒 Takes about 30mins on first run to build Docker containers. |
35 | 67 |
|
36 | | -1. **Install Dependencies and Set Up Virtual Environment** |
| 68 | +📂 Results will be generated in the `results` folder within the root directory of the repository. |
| 69 | +Each results folder will have a timestamp, allowing you to easily track and compare different runs. |
37 | 70 |
|
38 | | - Run the following commands to set up your virtual environment and activate the virtual environment. |
| 71 | +```bash |
| 72 | +docker run \ |
| 73 | + -v /var/run/docker.sock:/var/run/docker.sock \ |
| 74 | + -v ./results:/app/results \ |
| 75 | + typeevalpy |
| 76 | +``` |
39 | 77 |
|
40 | | - ```bash |
41 | | - python3 -m venv .env |
42 | | - ``` |
| 78 | +🔧 **Optionally**, run analysis on specific tools: |
43 | 79 |
|
44 | | - ```bash |
45 | | - source .env/bin/activate |
46 | | - ``` |
| 80 | +```bash |
| 81 | +docker run \ |
| 82 | + -v /var/run/docker.sock:/var/run/docker.sock \ |
| 83 | + -v ./results:/app/results \ |
| 84 | + typeevalpy --runners headergen scalpel |
| 85 | +``` |
47 | 86 |
|
48 | | - ```bash |
49 | | - pip install -r requirements.txt |
50 | | - ``` |
| 87 | +🛠️ Available options: `headergen`, `pyright`, `scalpel`, `jedi`, `hityper`, `type4py`, `hityperdl` |
51 | 88 |
|
52 | 89 | --- |
53 | 90 |
|
54 | | -## 🚀 Usage: Running the Analysis |
| 91 | +<details> |
| 92 | + <summary><b>Running From Source...</b></summary> |
| 93 | + |
| 94 | + ## 1. 📥 Installation |
| 95 | + |
| 96 | + 1. **Clone the repo** |
| 97 | + |
| 98 | + ```bash |
| 99 | + git clone https://github.com/ashwinprasadme/TypeEvalPy.git |
| 100 | + ``` |
| 101 | + |
| 102 | + |
| 103 | + 2. **Install Dependencies and Set Up Virtual Environment** |
| 104 | + |
| 105 | + Run the following commands to set up your virtual environment and activate the virtual environment. |
| 106 | + |
| 107 | + ```bash |
| 108 | + python3 -m venv .env |
| 109 | + ``` |
| 110 | + |
| 111 | + ```bash |
| 112 | + source .env/bin/activate |
| 113 | + ``` |
| 114 | + |
| 115 | + ```bash |
| 116 | + pip install -r requirements.txt |
| 117 | + ``` |
| 118 | + |
| 119 | + --- |
| 120 | + |
| 121 | + ## 2. 🚀 Usage: Running the Analysis |
55 | 122 |
|
56 | | -1. **Navigate to the `src` Directory** |
| 123 | + 1. **Navigate to the `src` Directory** |
57 | 124 |
|
58 | | - ```bash |
59 | | - cd src |
60 | | - ``` |
| 125 | + ```bash |
| 126 | + cd src |
| 127 | + ``` |
61 | 128 |
|
62 | | -2. **Execute the Analyzer** |
| 129 | + 2. **Execute the Analyzer** |
63 | 130 |
|
64 | | - Run the following command to start the benchmarking process on all tools: |
| 131 | + Run the following command to start the benchmarking process on all tools: |
65 | 132 |
|
66 | | - ```bash |
67 | | - python main_runner.py |
68 | | - ``` |
| 133 | + ```bash |
| 134 | + python main_runner.py |
| 135 | + ``` |
69 | 136 |
|
70 | | - or |
| 137 | + or |
71 | 138 |
|
72 | | - Run analysis on specific tools |
| 139 | + Run analysis on specific tools |
73 | 140 |
|
74 | | - ``` |
75 | | - python main_runner.py --runners headergen hityperdl |
76 | | - ``` |
| 141 | + ``` |
| 142 | + python main_runner.py --runners headergen scalpel |
| 143 | + ``` |
77 | 144 |
|
78 | | - Available options: headergen, pyright, scalpel, jedi, hityper, type4py, hityperdl |
| 145 | +</details> |
79 | 146 |
|
80 | | - The 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. |
81 | 147 |
|
82 | 148 | --- |
83 | 149 |
|
|
0 commit comments