Skip to content
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
15 changes: 6 additions & 9 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ jobs:
with:
fetch-depth: 1

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10.12" # Replace with the version you need
run: uv sync

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install mypy>=1.7.1
- name: Type Check Source Code
run: mypy src
run: uv run mypy src

41 changes: 13 additions & 28 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,21 @@
name: Pylint
name: Pylint Linting

on: [pull_request]

jobs:
build:
linting:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
- uses: actions/checkout@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
pip install -r requirements.txt
# - name: Analysing the code with pylint
# run: |
# pylint $(git ls-files '*.py')
- name: Run Pylint
run: |
PYLINT_OUTPUT=$(pylint $(git ls-files '*.py') || true)
PYLINT_SCORE=$(echo "$PYLINT_OUTPUT" | grep 'rated at' | sed 's/.*rated at \([0-9.]*\)\/10.*/\1/')
echo "PYLINT_SCORE=$PYLINT_SCORE" >> $GITHUB_ENV
echo "$PYLINT_OUTPUT"
fetch-depth: 1

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Set up Python
run: uv sync

- name: Fail if below threshold (8)
run: |
if (( $(echo "$PYLINT_SCORE < 8.0" |bc -l) )); then
exit 1
fi
- name: Lint Source Code
run: uv run pylint src
19 changes: 5 additions & 14 deletions .github/workflows/unitttest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@ jobs:
with:
fetch-depth: 1

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10.12" # Replace with the version you need
run: uv sync

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Unit Tests
run: |
source ./env.sh
python3 tests/test_ast.py
python3 tests/test_polymorphism.py
python3 tests/test_dependency.py
python3 tests/test_rewrite.py
python3 tests/test_alpha_equiv.py
run: uv run pytest
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ result/
evaluation_log.txt
banned.txt

alpharewrite/

*.pdf
*.png
*.csv
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extension-pkg-whitelist=
fail-on=

# Specify a score threshold under which the program will exit with error.
fail-under=10
fail-under=9

# Interpret the stdin as a python script, whose filename needs to be passed as
# the module_or_package argument.
Expand Down Expand Up @@ -340,7 +340,7 @@ indent-after-paren=4
indent-string=' '

# Maximum number of characters on a single line.
max-line-length=80
max-line-length=100

# Maximum number of lines in a module.
max-module-lines=1000
Expand Down
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,12 @@ uv sync # create a virtual environment, and install dependencies

## Building TF-Bench From Scratch (Optional)

### Getting Required Data

```sh
./scripts/init.sh
```

This script will download raw data from [Hackage](https://hackage.haskell.org/).

### TF-Bench

This script will build the benchmark (Prelude with NL) from the raw data.

```sh
uv run reprocess_benchmark.py -i benchmark/ -o TF-Bench.json
uv run --project . scripts/preprocess_benchmark.py
```

### TF-Bench_pure
Expand All @@ -40,6 +32,8 @@ cd alpharewrite

stack build
stack exec alpharewrite-exe 1 TF-Bench.json > TF-Bench.pure.json

cd ..
```

For details, please refer to the README of [alpharewrite](https://github.com/SecurityLab-UCD/alpharewrite).
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies = [
"ollama==0.2.1",
"openai==1.30.5",
"pathos>=0.3.3",
"pylint>=3.3.6",
"pytest>=8.0.0",
"python-dotenv==1.0.1",
"requests==2.32.3",
Expand All @@ -31,3 +32,6 @@ dependencies = [
"tree-sitter-haskell==0.21.0",
"types-requests>=2.31.0",
]
[tool.pytest.ini_options]
pythonpath = ["."]

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from funcy import lmap


def main(input_raw_benchmark_path: str = "benchmark", output_path: str = "Benchmark-F.json"):
def main(input_raw_benchmark_path: str = "benchmark", output_path: str = "tfb.json"):

# read in all files ending with .md in the input_raw_benchmark_path
tasks: list[BenchmarkTask] = []
Expand Down
2 changes: 1 addition & 1 deletion src/hoogle.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def main(
# Also transform them back into dictionaries for json format
filtered = (
(tasks_w_dep)
.filter(lambda d: d.dependencies != None)
.filter(lambda d: d.dependencies is not None)
.map(lambda x: x.__dict__)
.value
)
Expand Down
83 changes: 0 additions & 83 deletions tests/test_rewrite.py

This file was deleted.

65 changes: 65 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.