Skip to content

Commit fc850dc

Browse files
merge to template tests
1 parent 494a2de commit fc850dc

File tree

5 files changed

+23
-36
lines changed

5 files changed

+23
-36
lines changed

tests/run.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
clear
22
python3 test/setup.py &&
33
# pytest test/test_centrality.py::TestCentrality::test_degree_centrality1 #test/test_ml.py
4-
pytest test/test_centrality.py::TestCentrality::test_pagerank
4+
# pytest test/test_centrality.py::TestCentrality::test_pagerank
55
# pytest test/test_ml.py
6+
pytest test/test_centrality.py::TestCentrality
67
echo 'done'

tests/test/baseline/create_baselines.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66

77
def run():
8-
PagerankBaseline(data_path_root, baseline_path_root).run()
9-
# DegreeCentralityBaseline(data_path_root, baseline_path_root).run()
8+
# PagerankBaseline(data_path_root, baseline_path_root).run()
9+
DegreeCentralityBaseline(data_path_root, baseline_path_root).run()
1010
# FastRPBaseline(data_path_root, baseline_path_root).run()
1111

1212

tests/test/setup.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import json
22
import os
33
import re
4-
import time
54
from glob import glob
65

76
import pyTigerGraph as tg
87
from dotenv import load_dotenv
98
from pyTigerGraph.datasets import Datasets
10-
from tqdm import tqdm, trange
9+
from tqdm import tqdm
1110

1211
import util
1312
from baseline import create_baselines
@@ -17,17 +16,6 @@
1716
pattern = re.compile(r'"name":\s*"tg_.*"')
1817

1918

20-
# def add_reverse_edge_to_schema(ds: Datasets):
21-
# with open(f"{dataset.tmp_dir}/{ds.name}/create_schema.gsql") as f:
22-
# schema: str = f.read()
23-
# with open(f"{dataset.tmp_dir}/{ds.name}/create_schema.gsql", "w") as f:
24-
# schema = schema.replace(
25-
# "ADD DIRECTED EDGE Cite (from Paper, to Paper, time Int, is_train Bool, is_val Bool);",
26-
# 'ADD DIRECTED EDGE Cite (from Paper, to Paper, time Int, is_train Bool, is_val Bool) WITH REVERSE_EDGE="reverse_Cite";',
27-
# )
28-
# f.write(schema)
29-
#
30-
#
3119
def get_query_path(q_name):
3220
pth = glob(f"../algorithms/**/{q_name}.gsql", recursive=True)
3321
return pth[0]
@@ -40,9 +28,6 @@ def get_template_queries() -> list[str]:
4028
name = p.replace("../", "").split(".")[0].split("/")
4129
pkg = ".".join(x for x in name[:-1])
4230
name = ".".join(x for x in name)
43-
# if ".degree_cent" not in name:
44-
# if "louvain" not in name:
45-
# continue
4631
paths.append((name, p))
4732
packages.append(pkg)
4833

@@ -51,9 +36,6 @@ def get_template_queries() -> list[str]:
5136

5237

5338
if __name__ == "__main__":
54-
# print(get_template_queries())
55-
create_baselines.run()
56-
exit(0)
5739
host_name = os.environ["HOST_NAME"]
5840
user_name = os.environ["USER_NAME"]
5941
password = os.environ["PASS"]
@@ -75,7 +57,9 @@ def get_template_queries() -> list[str]:
7557

7658
dataset = Datasets("graph_algorithms_testing")
7759
conn.ingestDataset(dataset, getToken=True)
78-
conn.getToken()
60+
61+
if os.environ.get("USE_TKN", "true").lower() == "true":
62+
conn.getToken()
7963

8064
conn.graphname = graph_name
8165
# install the queries
@@ -109,7 +93,7 @@ def get_template_queries() -> list[str]:
10993

11094
pkg_queries = []
11195
queries = [q[0] for q in queries]
112-
reg = re.compile(r"- (.*)\(.*\)") # find insatlled pacakge query names
96+
reg = re.compile(r"- (.*)\(.*\)") # find installed pacakge query names
11397
for pkg in packages:
11498
r = conn.gsql(f"SHOW PACKAGE {pkg}")
11599
for p in reg.findall(r):

tests/test/test_centrality.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ def test_degree_centrality4(self, test_name):
347347
# )
348348
# self.check_result(baseline, result, template_flag)
349349
#
350+
@pytest.mark.skip(reason="Still testing pagerank")
350351
@pytest.mark.parametrize("test_name", undirected_graphs + directed_graphs)
351352
def test_pagerank(self, test_name):
352353
params = {

tests/test/util.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66
load_dotenv()
77

88

9-
def get_featurizer(graph_name="graph_algorithms_testing"):
10-
host_name = os.getenv("HOST_NAME")
11-
user_name = os.getenv("USER_NAME")
12-
password = os.getenv("PASS")
13-
conn = tg.TigerGraphConnection(
14-
host=host_name,
15-
username=user_name,
16-
password=password,
17-
graphname=graph_name,
18-
)
19-
if os.environ.get("USE_TKN", "true").lower() == "true":
20-
conn.getToken()
9+
def get_featurizer(conn:tg.TigerGraphConnection=None, graph_name="graph_algorithms_testing"):
10+
if conn is None:
11+
host_name = os.getenv("HOST_NAME")
12+
user_name = os.getenv("USER_NAME")
13+
password = os.getenv("PASS")
14+
conn = tg.TigerGraphConnection(
15+
host=host_name,
16+
username=user_name,
17+
password=password,
18+
graphname=graph_name,
19+
)
20+
if os.environ.get("USE_TKN", "true").lower() == "true":
21+
conn.getToken()
2122
f = conn.gds.featurizer()
2223
return f
2324

0 commit comments

Comments
 (0)