Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add notebook for detecting missing requirements #42

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ To reproduce our benchmarks, you can go through the notebooks provided in the `/
* [Create generated code samples from chatGPT/gemini/mistral/codellama/...](demo/create_samples.ipynb)
* [Evaluate samples by executing code](demo/evaluate_samples.ipynb)
* [Summarize evaluation](demo/summarize_evaluation.ipynb)
* [Detect missing requirements](demo/detect_missing_requirements.ipynb): In case this notebook lists missing requirements, that can be installed, the benchmark maintainers may add those requirements and run the evaluation step again.

## Extending the benchmark

Expand Down
121 changes: 121 additions & 0 deletions demo/detect_missing_requirements.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "1bba302e-f153-4c4a-96fd-dbbca7d52a15",
"metadata": {},
"source": [
"# Detecting missing requirements\n",
"\n",
"With this notebook we can scan \"..._results.jsonl\" files for failed imports. Some of those might lead to adding them to our requirements.txt"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "9d38d653-6471-4e55-8607-89f7d6250e4d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"No_module_named 'sklearn.umap'\", \"passed\": false}\n",
"No_module_named 'qhull'\", \"passed\": false}\n",
"No_module_named 'statsmodels'\", \"passed\": false}\n",
"No_module_named 'gdal'\", \"passed\": false}\n",
"No_module_named 'utils'\", \"passed\": false}\n",
"No_module_named 'nd2reader'\", \"passed\": false}\n",
"No_module_named 'osgeo'\", \"passed\": false}\n",
"No_module_named 'xarray'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'convex_hull'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'convex_hull_2D'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'convexhull'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'convex_hull_3d'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'convex_hull'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'Pillow'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'convex_hull_3d'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n",
"No_module_named 'scipy.udumap'\", \"passed\": false}\n",
"No_module_named 'convex_hull_3d'\", \"passed\": false}\n",
"No_module_named 'skimage.label'\", \"passed\": false}\n"
]
}
],
"source": [
"import os\n",
"\n",
"# Step 1: Define the directory and get all files\n",
"directory = \"../data/\"\n",
"files = os.listdir(directory)\n",
"\n",
"# Step 2: Filter for files ending with \"_results.jsonl\"\n",
"result_files = [file for file in files if file.endswith('_results.jsonl')]\n",
"\n",
"# Step 3: Loop through each file and process it\n",
"for file_name in result_files:\n",
" file_path = os.path.join(directory, file_name)\n",
" try:\n",
" with open(file_path, 'r') as file:\n",
" # Read the file line by line\n",
" for line in file:\n",
" # Check if \"ImportError:\" is in the line\n",
" if \"No module named\" in line:\n",
" line = line.replace(\"No module named\", \"No_module_named\")\n",
" words = line.split()\n",
" # Find the index of \"No module named\"\n",
" index = words.index(\"No_module_named\")\n",
" # Print \"ImportError:\" and the next 10 words\n",
" error_message = words[index:index+11]\n",
" print(' '.join(error_message))\n",
" except IOError as e:\n",
" print(f\"Could not read file {file_name}: {e}\")\n",
" except ValueError as e:\n",
" print(f\"Problem processing line in file {file_name}: {e}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "83636fa0-665f-4bb1-9e39-410ace7c321d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 5
}