Skip to content

Commit 431a7e0

Browse files
committed
Assert jobId in tests
1 parent c48bc0c commit 431a7e0

File tree

5 files changed

+31
-14
lines changed

5 files changed

+31
-14
lines changed

graphdatascience/algo/algo_proc_runner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def estimate(self, G: Graph, **config: Any) -> "Series[Any]":
2626

2727
class StreamModeRunner(AlgoProcRunner):
2828
def __call__(self, G: Graph, **config: Any) -> DataFrame:
29-
# insert job id if not existing
3029
return self._run_procedure(G, config)
3130

3231

graphdatascience/tests/unit/session/test_aura_graph_data_science.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ def test_remote_algo_write() -> None:
7878
gds.pageRank.write(G, writeProperty="pr")
7979

8080
assert query_runner.last_query() == "CALL gds.pageRank.write($graph_name, $config)"
81+
jobId = query_runner.last_params().get("config", {}).get("jobId", "")
8182
assert query_runner.last_params() == {
8283
"graph_name": "foo",
83-
"config": {"writeProperty": "pr"},
84+
"config": {"writeProperty": "pr", "jobId": jobId},
8485
}
8586

8687

@@ -97,11 +98,13 @@ def test_remote_algo_write_configuration() -> None:
9798
gds.pageRank.write(G, writeProperty="pr", concurrency=12, arrowConfiguration={"batch_size": 98})
9899

99100
assert query_runner.last_query() == "CALL gds.pageRank.write($graph_name, $config)"
101+
jobId = query_runner.last_params().get("config", {}).get("jobId", "")
100102
assert query_runner.last_params() == {
101103
"graph_name": "foo",
102104
"config": {
103105
"writeProperty": "pr",
104106
"concurrency": 12,
107+
"jobId": jobId,
105108
"arrowConfiguration": {"batch_size": 98},
106109
},
107110
}

graphdatascience/tests/unit/test_graph_ops.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,16 @@ def test_project_subgraph(runner: CollectingQueryRunner, gds: GraphDataScience)
8282
runner.last_query()
8383
== "CALL " + "gds.graph.filter($graph_name, $from_graph_name, $node_filter, $relationship_filter, $config)"
8484
)
85-
assert runner.last_params() == {
85+
86+
actualParams = runner.last_params()
87+
jobId = actualParams.get("config", {}).get("jobId", "")
88+
89+
assert actualParams == {
8690
"graph_name": "s",
8791
"from_graph_name": "g",
8892
"node_filter": "n.x > 1",
8993
"relationship_filter": "*",
90-
"config": {"concurrency": 2},
94+
"config": {"concurrency": 2, "jobId": jobId},
9195
}
9296

9397

@@ -611,11 +615,13 @@ def test_graph_generate(runner: CollectingQueryRunner, gds: GraphDataScience) ->
611615
gds.graph.generate("g", 1337, 42, orientation="NATURAL")
612616

613617
assert runner.last_query() == "CALL gds.graph.generate($graph_name, $node_count, $average_degree, $config)"
618+
619+
jobId = runner.last_params().get("config", {}).get("jobId", "")
614620
assert runner.last_params() == {
615621
"graph_name": "g",
616622
"node_count": 1337,
617623
"average_degree": 42,
618-
"config": {"orientation": "NATURAL"},
624+
"config": {"orientation": "NATURAL", "jobId": jobId},
619625
}
620626

621627

graphdatascience/tests/unit/test_simple_algo.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,77 +17,85 @@ def test_simple_mutate(runner: CollectingQueryRunner, gds: GraphDataScience, G:
1717
gds.algoName.mutate(G, mutateProperty="rank", dampingFactor=0.2, tolerance=0.3)
1818

1919
assert runner.last_query() == "CALL gds.algoName.mutate($graph_name, $config)"
20+
jobId = runner.last_params().get("config", {}).get("jobId", "")
2021
assert runner.last_params() == {
2122
"graph_name": GRAPH_NAME,
22-
"config": {"mutateProperty": "rank", "dampingFactor": 0.2, "tolerance": 0.3},
23+
"config": {"mutateProperty": "rank", "dampingFactor": 0.2, "tolerance": 0.3, "jobId": jobId},
2324
}
2425

2526

2627
def test_simple_stats(runner: CollectingQueryRunner, gds: GraphDataScience, G: Graph) -> None:
2728
gds.algoName.stats(G, dampingFactor=0.2, tolerance=0.3)
2829

2930
assert runner.last_query() == "CALL gds.algoName.stats($graph_name, $config)"
31+
jobId = runner.last_params().get("config", {}).get("jobId", "")
3032
assert runner.last_params() == {
3133
"graph_name": GRAPH_NAME,
32-
"config": {"dampingFactor": 0.2, "tolerance": 0.3},
34+
"config": {"dampingFactor": 0.2, "tolerance": 0.3, "jobId": jobId},
3335
}
3436

3537

3638
def test_simple_stream(runner: CollectingQueryRunner, gds: GraphDataScience, G: Graph) -> None:
3739
gds.algoName.stream(G, dampingFactor=0.2, tolerance=0.3)
3840

3941
assert runner.last_query() == "CALL gds.algoName.stream($graph_name, $config)"
42+
jobId = runner.last_params().get("config", {}).get("jobId", "")
4043
assert runner.last_params() == {
4144
"graph_name": GRAPH_NAME,
42-
"config": {"dampingFactor": 0.2, "tolerance": 0.3},
45+
"config": {"dampingFactor": 0.2, "tolerance": 0.3, "jobId": jobId},
4346
}
4447

4548

4649
def test_simple_write(runner: CollectingQueryRunner, gds: GraphDataScience, G: Graph) -> None:
4750
gds.algoName.write(G, writeProperty="rank", dampingFactor=0.2, tolerance=0.3)
4851

4952
assert runner.last_query() == "CALL gds.algoName.write($graph_name, $config)"
53+
jobId = runner.last_params().get("config", {}).get("jobId", "")
5054
assert runner.last_params() == {
5155
"graph_name": GRAPH_NAME,
52-
"config": {"writeProperty": "rank", "dampingFactor": 0.2, "tolerance": 0.3},
56+
"config": {"writeProperty": "rank", "dampingFactor": 0.2, "tolerance": 0.3, "jobId": jobId},
5357
}
5458

5559

5660
def test_simple_mutate_estimate(runner: CollectingQueryRunner, gds: GraphDataScience, G: Graph) -> None:
5761
gds.algoName.mutate.estimate(G, mutateProperty="rank", dampingFactor=0.2, tolerance=0.3)
5862

5963
assert runner.last_query() == "CALL gds.algoName.mutate.estimate($graph_name, $config)"
64+
jobId = runner.last_params().get("config", {}).get("jobId", "")
6065
assert runner.last_params() == {
6166
"graph_name": GRAPH_NAME,
62-
"config": {"mutateProperty": "rank", "dampingFactor": 0.2, "tolerance": 0.3},
67+
"config": {"mutateProperty": "rank", "dampingFactor": 0.2, "tolerance": 0.3, "jobId": jobId},
6368
}
6469

6570

6671
def test_simple_stats_estimate(runner: CollectingQueryRunner, gds: GraphDataScience, G: Graph) -> None:
6772
gds.algoName.stats.estimate(G, dampingFactor=0.2, tolerance=0.3)
6873

6974
assert runner.last_query() == "CALL gds.algoName.stats.estimate($graph_name, $config)"
75+
jobId = runner.last_params().get("config", {}).get("jobId", "")
7076
assert runner.last_params() == {
7177
"graph_name": GRAPH_NAME,
72-
"config": {"dampingFactor": 0.2, "tolerance": 0.3},
78+
"config": {"dampingFactor": 0.2, "tolerance": 0.3, "jobId": jobId},
7379
}
7480

7581

7682
def test_simple_stream_estimate(runner: CollectingQueryRunner, gds: GraphDataScience, G: Graph) -> None:
7783
gds.algoName.stream.estimate(G, dampingFactor=0.2, tolerance=0.3)
7884

7985
assert runner.last_query() == "CALL gds.algoName.stream.estimate($graph_name, $config)"
86+
jobId = runner.last_params().get("config", {}).get("jobId", "")
8087
assert runner.last_params() == {
8188
"graph_name": GRAPH_NAME,
82-
"config": {"dampingFactor": 0.2, "tolerance": 0.3},
89+
"config": {"dampingFactor": 0.2, "tolerance": 0.3, "jobId": jobId},
8390
}
8491

8592

8693
def test_simple_write_estimate(runner: CollectingQueryRunner, gds: GraphDataScience, G: Graph) -> None:
8794
gds.algoName.write.estimate(G, writeProperty="rank", dampingFactor=0.2, tolerance=0.3)
8895

8996
assert runner.last_query() == "CALL gds.algoName.write.estimate($graph_name, $config)"
97+
jobId = runner.last_params().get("config", {}).get("jobId", "")
9098
assert runner.last_params() == {
9199
"graph_name": GRAPH_NAME,
92-
"config": {"writeProperty": "rank", "dampingFactor": 0.2, "tolerance": 0.3},
100+
"config": {"writeProperty": "rank", "dampingFactor": 0.2, "tolerance": 0.3, "jobId": jobId},
93101
}

graphdatascience/tests/unit/test_single_mode_algos.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def G(gds: GraphDataScience) -> Graph:
1818
def test_simple_mutate(runner: CollectingQueryRunner, gds: GraphDataScience, G: Graph) -> None:
1919
gds.triangles(G, maxDegree=2)
2020
assert runner.last_query() == "CALL gds.triangles($graph_name, $config)"
21+
jobId = runner.last_params().get("config", {}).get("jobId", "")
2122
assert runner.last_params() == {
2223
"graph_name": GRAPH_NAME,
23-
"config": {"maxDegree": 2},
24+
"config": {"maxDegree": 2, "jobId": jobId},
2425
}

0 commit comments

Comments
 (0)