Skip to content

Commit ed51ca2

Browse files
Dockerfile, Leaderboard generation, Minor fixes
1 parent 5b4e22e commit ed51ca2

File tree

6 files changed

+262
-98
lines changed

6 files changed

+262
-98
lines changed

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM python:3.10-slim
2+
3+
WORKDIR /app
4+
5+
COPY . /app
6+
7+
RUN pip install --trusted-host pypi.python.org -r requirements.txt
8+
9+
WORKDIR /app/src
10+
11+
# Run app.py when the container launches
12+
ENTRYPOINT ["python", "main_runner.py"]

README.md

Lines changed: 107 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,149 @@
11
# TypeEvalPy: A Micro-benchmarking Framework for Python Type Inference Tools
22

33
<p align="center">
4+
<br>
45
<img src="TypeEvalPy.jpg" width="60%" align="center">
6+
<br>
57
</p>
68

7-
89
## 📌 **Key Features**:
10+
911
- 📜 Contains **154 code snippets** to test and benchmark.
1012
- 🏷 Offers **845 type annotations** across a diverse set of Python functionalities.
1113
- 📂 Organized into **18 distinct categories** targeting various Python features.
1214
- 🚢 Seamlessly manages the execution of **containerized tools**.
1315
- 🔄 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) | |
1530

1631
---
1732

1833
## 🏆 TypeEvalPy Leaderboard
1934

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.
2136

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>*
3148

3249
---
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
3365

34-
## 📥 Installation
66+
🕒 Takes about 30mins on first run to build Docker containers.
3567

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.
3770

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+
```
3977

40-
```bash
41-
python3 -m venv .env
42-
```
78+
🔧 **Optionally**, run analysis on specific tools:
4379

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+
```
4786

48-
```bash
49-
pip install -r requirements.txt
50-
```
87+
🛠️ Available options: `headergen`, `pyright`, `scalpel`, `jedi`, `hityper`, `type4py`, `hityperdl`
5188

5289
---
5390

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
55122

56-
1. **Navigate to the `src` Directory**
123+
1. **Navigate to the `src` Directory**
57124

58-
```bash
59-
cd src
60-
```
125+
```bash
126+
cd src
127+
```
61128

62-
2. **Execute the Analyzer**
129+
2. **Execute the Analyzer**
63130

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:
65132

66-
```bash
67-
python main_runner.py
68-
```
133+
```bash
134+
python main_runner.py
135+
```
69136

70-
or
137+
or
71138

72-
Run analysis on specific tools
139+
Run analysis on specific tools
73140

74-
```
75-
python main_runner.py --runners headergen hityperdl
76-
```
141+
```
142+
python main_runner.py --runners headergen scalpel
143+
```
77144

78-
Available options: headergen, pyright, scalpel, jedi, hityper, type4py, hityperdl
145+
</details>
79146

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.
81147

82148
---
83149

src/main_analyze_results.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -969,27 +969,27 @@ def run_results_analyzer():
969969
results_dir = results_dir / "analysis_results"
970970
# Move logs
971971
# TODO: Improve generation of logs files
972-
os.rename("results_analysis.log", f"{str(results_dir)}/results_analysis.log")
973-
os.rename(
972+
shutil.move("results_analysis.log", f"{str(results_dir)}/results_analysis.log")
973+
shutil.move(
974974
"results_analysis_info.log", f"{str(results_dir)}/results_analysis_info.log"
975975
)
976-
os.rename(
976+
shutil.move(
977977
"tools_error_result_data.csv",
978978
f"{str(results_dir)}/tools_error_result_data.csv",
979979
)
980-
os.rename(
980+
shutil.move(
981981
"tools_sound_complete_data.csv",
982982
f"{str(results_dir)}/tools_sound_complete_data.csv",
983983
)
984-
os.rename(
984+
shutil.move(
985985
"tools_exact_match_data.csv",
986986
f"{str(results_dir)}/tools_exact_match_data.csv",
987987
)
988-
os.rename(
988+
shutil.move(
989989
"tools_exact_match_category_data.csv",
990990
f"{str(results_dir)}/tools_exact_match_category_data.csv",
991991
)
992-
os.rename(
992+
shutil.move(
993993
"tools_sensitivities_data.csv",
994994
f"{str(results_dir)}/tools_sensitivities_data.csv",
995995
)
@@ -998,23 +998,23 @@ def run_results_analyzer():
998998
os.makedirs(results_dir / "missing", exist_ok=True)
999999
os.makedirs(results_dir / "paper_tables", exist_ok=True)
10001000

1001-
os.rename(
1001+
shutil.move(
10021002
"paper_table_1.csv",
10031003
f"{str(results_dir)}/paper_tables/paper_table_1.csv",
10041004
)
1005-
os.rename(
1005+
shutil.move(
10061006
"paper_table_2.csv",
10071007
f"{str(results_dir)}/paper_tables/paper_table_2.csv",
10081008
)
1009-
os.rename(
1009+
shutil.move(
10101010
"paper_table_3.csv",
10111011
f"{str(results_dir)}/paper_tables/paper_table_3.csv",
10121012
)
10131013
shutil.copy(
10141014
f"{str(results_dir)}/tools_sound_complete_data.csv",
10151015
f"{str(results_dir)}/paper_tables/paper_table_4.csv",
10161016
)
1017-
os.rename(
1017+
shutil.move(
10181018
"paper_table_5.csv",
10191019
f"{str(results_dir)}/paper_tables/paper_table_5.csv",
10201020
)
@@ -1023,20 +1023,20 @@ def run_results_analyzer():
10231023
f"{str(results_dir)}/paper_tables/paper_table_6.csv",
10241024
)
10251025
for tool in list(tools_results.keys()):
1026-
os.rename(
1026+
shutil.move(
10271027
f"{tool}_mismatches_reasons.csv",
10281028
f"{str(results_dir)}/mismatches/{tool}_mismatches_reasons.csv",
10291029
)
1030-
os.rename(
1030+
shutil.move(
10311031
f"{tool}_not_found_reasons.csv",
10321032
f"{str(results_dir)}/missing/{tool}_not_found_reasons.csv",
10331033
)
10341034

10351035
if tool in utils.ML_TOOLS:
1036-
os.rename(
1036+
shutil.move(
10371037
f"top_n_table_{tool}.csv", f"{str(results_dir)}/top_n_table_{tool}.csv"
10381038
)
1039-
os.rename(
1039+
shutil.move(
10401040
f"top_n_exact_match_table_{tool}.csv",
10411041
f"{str(results_dir)}/top_n_exact_match_table_{tool}.csv",
10421042
)

src/main_runner.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import os
3+
import shutil
34
import tarfile
45
import time
56
from argparse import ArgumentParser
@@ -299,7 +300,9 @@ def get_args():
299300

300301
def main():
301302
args = get_args()
302-
host_results_path = f"../results/results_{datetime.now().strftime('%d-%m %H:%M')}"
303+
host_results_path = (
304+
f"../results/results_{datetime.now().strftime('%d-%m-%y %H:%M')}"
305+
)
303306

304307
available_runners = {
305308
"headergen": (
@@ -345,7 +348,7 @@ def main():
345348

346349
run_results_analyzer()
347350

348-
os.rename("main_runner.log", f"{str(host_results_path)}/main_runner.log")
351+
shutil.move("main_runner.log", f"{str(host_results_path)}/main_runner.log")
349352

350353

351354
if __name__ == "__main__":

0 commit comments

Comments
 (0)