Skip to content

Commit abbeafa

Browse files
author
Amitayush Thakur
committed
Added data_gen test
1 parent 268404d commit abbeafa

File tree

6 files changed

+69
-6
lines changed

6 files changed

+69
-6
lines changed

.github/workflows/github-build-actions.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,16 @@ jobs:
7575
- name: List repository files (debug step)
7676
run: find . -type f
7777

78-
- name: Run tests
78+
- name: Run Simple Env Test
7979
shell: bash
8080
run: |
8181
eval $(opam env)
8282
source $HOME/.elan/env
83-
python src/test/simple_env_test.py
83+
python src/test/simple_env_test.py
84+
85+
- name: Run Data Gen Test
86+
shell: bash
87+
run: |
88+
eval $(opam env)
89+
source $HOME/.elan/env
90+
python src/test/simple_data_gen_test.py

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ action = ProofAction(
193193

194194
## Generating Proof Step Data:
195195

196+
>NOTE: Make sure that you have installed the `itp-interface` package before running the following commands.
197+
196198
1.a. You need to run the following command to generate sample proof step data for Lean 4:
197199
```
198200
run-itp-data-gen --config-dir src/itp_interface/main/configs --config-name simple_lean_data_gen

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ requires = [
55
build-backend = "hatchling.build"
66
[project]
77
name = "itp_interface"
8-
version = "1.1.1"
8+
version = "1.1.2"
99
authors = [
1010
{ name="Amitayush Thakur", email="[email protected]" },
1111
]

src/itp_interface/main/configs/benchmark/simple_benchmark_lean.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ few_shot_metadata_filename_for_retrieval:
66
dfs_data_path_for_retrieval:
77
dfs_metadata_filename_for_retrieval:
88
datasets:
9-
- project: data/test/lean4_proj
9+
- project: src/data/test/lean4_proj
1010
files:
1111
- path: Lean4Proj/Basic.lean
1212
theorems: "*"

src/itp_interface/main/run_tool.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,17 +420,19 @@ def run_data_generation(experiment: Experiments, log_dir: str, logger: logging.L
420420
time.sleep(10)
421421
logger.info(f"Finished running experiment: \n{experiment.to_json(indent=4)}")
422422

423-
@hydra.main(config_path="configs", config_name="experiments", version_base="1.2")
423+
@hydra.main(config_path="configs", config_name="simple_lean_data_gen", version_base="1.2")
424424
def main(cfg):
425425
os.environ["PYTHONPATH"] = f"{root_dir}:{os.environ.get('PYTHONPATH', '')}"
426426
# RayUtils.init_ray(num_of_cpus=cfg.run_settings.pool_size, object_store_memory_in_gb=100)
427427
experiment = parse_config(cfg)
428-
os.chdir(root_dir)
428+
# os.chdir(root_dir)
429429
# top_level_dir = os.path.dirname(root_dir)
430430
# top_level_dir = os.path.dirname(top_level_dir)
431431
# os.chdir(top_level_dir)
432432
log_dir = ".log/data_generation/benchmark/{}/{}".format(experiment.benchmark.name, time.strftime("%Y%m%d-%H%M%S"))
433433
os.makedirs(log_dir, exist_ok=True)
434+
abs_path = os.path.abspath(log_dir)
435+
print(f"Log Dir: {abs_path}")
434436
log_path = os.path.join(log_dir, "eval.log")
435437
logger = setup_logger(__name__, log_path, logging.INFO, '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
436438
logger.info(f"Pid: {os.getpid()}")

src/test/simple_data_gen_test.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import unittest
2+
import os
3+
import subprocess
4+
5+
class TestDataGen(unittest.TestCase):
6+
def test_proof_step_data_gen(self):
7+
"""
8+
Test that the 'run-itp-data-gen' command runs successfully with the given configuration.
9+
"""
10+
# Construct the command as a single string.
11+
command = (
12+
"run-itp-data-gen --config-dir=src/itp_interface/main/configs "
13+
"--config-name=simple_lean_data_gen.yaml"
14+
)
15+
16+
try:
17+
# Run the command using shell=True so that the shell does the PATH lookup.
18+
result = subprocess.run(
19+
command,
20+
shell=True,
21+
capture_output=True,
22+
text=True,
23+
timeout=700
24+
)
25+
except subprocess.TimeoutExpired as e:
26+
self.fail(f"'run-itp-data-gen' command timed out: {e}")
27+
except Exception as e:
28+
self.fail(f"Error running 'proof-wala-search': {e}")
29+
30+
# Check that the command exited with a return code of 0.
31+
self.assertEqual(
32+
result.returncode, 0,
33+
msg=f"'run-itp-data-gen' failed with return code {result.returncode}. Stderr: {result.stderr}"
34+
)
35+
36+
# Print all the files in the .log/data_generation/benchmark/simple_benchmark_lean
37+
# directory to see what was generated.
38+
# Do a list and pick the last folder in the list as per the sorted order
39+
dirs = sorted(os.listdir(".log/data_generation/benchmark/simple_benchmark_lean"))
40+
print(dirs)
41+
last_dir = dirs[-1]
42+
train_data = os.path.join(".log/data_generation/benchmark/simple_benchmark_lean", last_dir, "train")
43+
data_gen_file = os.path.join(train_data, "local_data_0000000016.json")
44+
print("Data Gen File:", data_gen_file)
45+
with open(data_gen_file, "r") as f:
46+
print(f.read())
47+
48+
def main():
49+
unittest.main()
50+
51+
if __name__ == '__main__':
52+
main()

0 commit comments

Comments
 (0)