Skip to content

Commit 084a9c9

Browse files
test: update e2e tests
1 parent c2cba57 commit 084a9c9

File tree

6 files changed

+31
-36
lines changed

6 files changed

+31
-36
lines changed

tests/e2e_tests/conftest.py

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,59 +5,48 @@
55

66

77
def run_generate_test(tmp_path: Path, config_name: str):
8-
"""
9-
Run the generate test with the given configuration file and temporary path.
10-
11-
Args:
12-
tmp_path: pytest temporary path
13-
config_name: configuration file name (e.g. "atomic_config.yaml")
14-
15-
Returns:
16-
tuple: (run_folder, json_files[0])
17-
"""
188
repo_root = Path(__file__).resolve().parents[2]
199
os.chdir(repo_root)
2010

21-
config_path = repo_root / "graphgen" / "configs" / config_name
22-
output_dir = tmp_path / "output"
23-
output_dir.mkdir(parents=True, exist_ok=True)
11+
config_path = repo_root / config_name
2412

2513
result = subprocess.run(
2614
[
2715
"python",
2816
"-m",
29-
"graphgen.generate",
17+
"graphgen.run",
3018
"--config_file",
3119
str(config_path),
32-
"--output_dir",
33-
str(output_dir),
3420
],
3521
capture_output=True,
3622
text=True,
3723
check=False,
3824
)
3925
assert result.returncode == 0, f"Script failed with error: {result.stderr}"
4026

41-
data_root = output_dir / "data" / "graphgen"
42-
assert data_root.exists(), f"{data_root} does not exist"
43-
run_folders = sorted(data_root.iterdir(), key=lambda p: p.name, reverse=True)
44-
assert run_folders, f"No run folders found in {data_root}"
27+
run_root = repo_root / "cache" / "output"
28+
assert run_root.exists(), f"{run_root} does not exist"
29+
run_folders = sorted(
30+
[p for p in run_root.iterdir() if p.is_dir()], key=lambda p: p.name, reverse=True
31+
)
32+
assert run_folders, f"No run folders found in {run_root}"
4533
run_folder = run_folders[0]
4634

47-
config_saved = run_folder / "config.yaml"
48-
assert config_saved.exists(), f"{config_saved} not found"
35+
node_dirs = [p for p in run_folder.iterdir() if p.is_dir()]
36+
assert node_dirs, f"No node outputs found in {run_folder}"
4937

50-
json_files = list(run_folder.glob("*.json"))
51-
assert json_files, f"No JSON output found in {run_folder}"
38+
json_files = []
39+
for nd in node_dirs:
40+
json_files.extend(nd.glob("*.jsonl"))
41+
assert json_files, f"No JSONL output found under nodes in {run_folder}"
5242

53-
log_files = list(run_folder.glob("*.log"))
54-
assert log_files, "No log file generated"
43+
log_file = repo_root / "cache" / "logs" / "Driver.log"
44+
assert log_file.exists(), "No log file generated"
5545

5646
with open(json_files[0], "r", encoding="utf-8") as f:
57-
data = json.load(f)
58-
assert (
59-
isinstance(data, list) and len(data) > 0
60-
), "JSON output is empty or not a list"
47+
first_line = f.readline().strip()
48+
assert first_line, "JSONL output is empty"
49+
data = json.loads(first_line)
50+
assert isinstance(data, dict), "First JSONL record is not a dict"
6151

6252
return run_folder, json_files[0]
63-

tests/e2e_tests/test_generate_aggregated.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44

55

66
def test_generate_aggregated(tmp_path: Path):
7-
run_generate_test(tmp_path, "aggregated_config.yaml")
7+
run_generate_test(
8+
tmp_path, "examples/generate/generate_aggregated_qa/aggregated_config.yaml"
9+
)

tests/e2e_tests/test_generate_atomic.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44

55

66
def test_generate_atomic(tmp_path: Path):
7-
run_generate_test(tmp_path, "atomic_config.yaml")
7+
run_generate_test(
8+
tmp_path, "examples/generate/generate_atomic_qa/atomic_config.yaml"
9+
)

tests/e2e_tests/test_generate_cot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55

66
def test_generate_cot(tmp_path: Path):
7-
run_generate_test(tmp_path, "cot_config.yaml")
7+
run_generate_test(tmp_path, "examples/generate/generate_cot_qa/cot_config.yaml")

tests/e2e_tests/test_generate_multi_hop.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44

55

66
def test_generate_multi_hop(tmp_path: Path):
7-
run_generate_test(tmp_path, "multi_hop_config.yaml")
7+
run_generate_test(
8+
tmp_path, "examples/generate/generate_multi_hop_qa/multi_hop_config.yaml"
9+
)

tests/e2e_tests/test_generate_vqa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55

66
def test_generate_vqa(tmp_path: Path):
7-
run_generate_test(tmp_path, "vqa_config.yaml")
7+
run_generate_test(tmp_path, "examples/generate/generate_vqa/vqa_config.yaml")

0 commit comments

Comments
 (0)