Skip to content

Commit 5f2be4f

Browse files
authored
Merge pull request #95 from adamnsch/graph-get-error-msg
Add transparency of currently targeted database
2 parents 8be417d + 9bfa7f3 commit 5f2be4f

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

changelog/1.1.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* Added support for new GDS library 2.1 signature of gds.graph.removeNodeProperties.
1313
* Added support for new function `gds.close` which calls `.close()` on a `GraphDataScience` object's underlying Neo4j driver.
1414
* Added new method `gds.alpha.graph.construct` to construct a GDS graph from pandas `DataFrame`s, which works if the GDS Flight server is enabled.
15+
* Added new function `gds.database` which can be used to see which database is currently being targeted.
1516

1617

1718
## Bug fixes
@@ -20,6 +21,7 @@
2021
## Improvements
2122

2223
* 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.
2325

2426

2527
## 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/graph_data_science.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ def __getattr__(self, attr: str) -> CallBuilder:
8989
def set_database(self, db: str) -> None:
9090
self._query_runner.set_database(db)
9191

92+
def database(self) -> str:
93+
return self._query_runner.database()
94+
9295
def run_cypher(self, query: str, params: Dict[str, Any] = {}) -> DataFrame:
9396
return self._query_runner.run_query(query, params)
9497

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)