Skip to content

Commit b8cd8b5

Browse files
committed
Add get method to CatalogEndpoints
1 parent 57a344d commit b8cd8b5

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/graphdatascience/procedure_surface/api/catalog/catalog_endpoints.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616

1717

1818
class CatalogEndpoints(ABC):
19+
@abstractmethod
20+
def get(self, graph_name: str) -> GraphV2:
21+
"""Retrieve a handle to a graph from the graph catalog.
22+
23+
Parameters
24+
----------
25+
graph_name
26+
The name of the graph.
27+
28+
Returns
29+
-------
30+
GraphV2
31+
A handle to the graph.
32+
"""
33+
pass
34+
1935
@abstractmethod
2036
def construct(
2137
self,

src/graphdatascience/procedure_surface/arrow/catalog/catalog_arrow_endpoints.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ def __init__(
5656
protocol_version = ProtocolVersionResolver(query_runner).resolve()
5757
self._project_protocol = ProjectProtocol.select(protocol_version)
5858

59+
def get(self, graph_name: str) -> GraphV2:
60+
if not self.list(graph_name):
61+
raise ValueError(f"A graph with name '{graph_name}' does not exist in the catalog.")
62+
return get_graph(graph_name, self._arrow_client)
63+
5964
def project(
6065
self,
6166
graph_name: str,

src/graphdatascience/procedure_surface/cypher/catalog_cypher_endpoints.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ def __init__(self, cypher_runner: Neo4jQueryRunner, arrow_client: GdsArrowClient
3939
self._cypher_runner = cypher_runner
4040
self._arrow_client = arrow_client
4141

42+
def get(self, graph_name: str) -> GraphV2:
43+
if not self.list(graph_name):
44+
raise ValueError(f"A graph with name '{graph_name}' does not exist in the catalog.")
45+
return get_graph(graph_name, self.cypher_runner)
46+
4247
def construct(
4348
self,
4449
graph_name: str,

0 commit comments

Comments
 (0)