Skip to content

Commit 9bfa7f3

Browse files
committed
Add db information to gds.graph.get error message
1 parent 2bb91e9 commit 9bfa7f3

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

changelog/1.1.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
## Improvements
2222

2323
* The functions `gds.graph.streamNodeProperty` and `gds.graph.streamRelationshipProperty` can leverage the Arrow Flight server of GDS to improve throughput.
24+
* Improved error message of `gds.graph.get` to include currently targeted database if graph not found.
2425

2526

2627
## Other changes

graphdatascience/graph/graph_proc_runner.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ def list(self, G: Optional[Graph] = None) -> DataFrame:
7676
@client_only_endpoint("gds.graph")
7777
def get(self, graph_name: str) -> Graph:
7878
if not self.exists(graph_name)["exists"]:
79-
raise ValueError(f"No projected graph named '{graph_name}' exists")
79+
raise ValueError(
80+
f"No projected graph named '{graph_name}' exists in current database '{self._query_runner.database()}'"
81+
)
8082

8183
return Graph(graph_name, self._query_runner, self._server_version)
8284

graphdatascience/tests/integration/test_graph_ops.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ def test_graph_get(gds: GraphDataScience) -> None:
142142
G = gds.graph.get(GRAPH_NAME)
143143
assert G.name() == GRAPH_NAME
144144

145-
with pytest.raises(ValueError):
145+
with pytest.raises(
146+
ValueError,
147+
match=f"No projected graph named 'bogusName' exists in current database '{gds.database()}'",
148+
):
146149
gds.graph.get("bogusName")
147150

148151

0 commit comments

Comments
 (0)