Skip to content

Commit 8a3a49b

Browse files
committed
Fix imports
1 parent 9569339 commit 8a3a49b

File tree

6 files changed

+37
-10
lines changed

6 files changed

+37
-10
lines changed

examples/graph-analytics-serverless-spark.ipynb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,25 +215,28 @@
215215
]
216216
},
217217
{
218-
"metadata": {},
219218
"cell_type": "markdown",
219+
"metadata": {},
220220
"source": [
221221
"The user wants to add a 1-second delay (sleep) within the loop that waits for the import job to finish. This requires importing the `time` module and adding `time.sleep(1)` inside the `while` loop at the end of the cell.\n",
222222
"\n"
223223
]
224224
},
225225
{
226-
"metadata": {},
227226
"cell_type": "markdown",
228-
"source": "<llm-snippet-file>graph-analytics-serverless-spark.ipynb</llm-snippet-file>\n"
227+
"metadata": {},
228+
"source": [
229+
"<llm-snippet-file>graph-analytics-serverless-spark.ipynb</llm-snippet-file>\n"
230+
]
229231
},
230232
{
231-
"metadata": {},
232233
"cell_type": "code",
233-
"outputs": [],
234234
"execution_count": null,
235+
"metadata": {},
236+
"outputs": [],
235237
"source": [
236238
"import time\n",
239+
"\n",
237240
"import pandas as pd\n",
238241
"import pyarrow\n",
239242
"from pyspark.sql import functions\n",
@@ -280,8 +283,8 @@
280283
]
281284
},
282285
{
283-
"metadata": {},
284286
"cell_type": "markdown",
287+
"metadata": {},
285288
"source": [
286289
"## Running Algorithms\n",
287290
"\n",

src/graphdatascience/arrow_client/v1/gds_arrow_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
from graphdatascience.arrow_client.authenticated_flight_client import AuthenticatedArrowClient, ConnectionInfo
1616
from graphdatascience.arrow_client.v1.data_mapper_utils import deserialize_single
1717

18+
from ...procedure_surface.arrow.error_handler import handle_flight_error
1819
from ...semantic_version.semantic_version import SemanticVersion
19-
from ..error_handler import handle_flight_error
2020

2121

2222
class GdsArrowClient:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import re
2+
3+
from neo4j.exceptions import ClientError
4+
from pyarrow import flight
5+
6+
7+
def handle_flight_error(e: Exception) -> None:
8+
if isinstance(e, flight.FlightServerError | flight.FlightInternalError | ClientError):
9+
original_message = e.args[0] if len(e.args) > 0 else e.message
10+
improved_message = original_message.replace(
11+
"Flight RPC failed with message: org.apache.arrow.flight.FlightRuntimeException: ", ""
12+
)
13+
improved_message = improved_message.replace(
14+
"Flight returned internal error, with message: org.apache.arrow.flight.FlightRuntimeException: ", ""
15+
)
16+
improved_message = improved_message.replace(
17+
"Failed to invoke procedure `gds.arrow.project`: Caused by: org.apache.arrow.flight.FlightRuntimeException: ",
18+
"",
19+
)
20+
improved_message = re.sub(r"(\. )?gRPC client debug context: .+$", "", improved_message)
21+
22+
raise flight.FlightServerError(improved_message)
23+
else:
24+
raise e

src/graphdatascience/procedure_surface/cypher/catalog_cypher_endpoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self, cypher_runner: Neo4jQueryRunner, arrow_client: GdsArrowClient
4242
def get(self, graph_name: str) -> GraphV2:
4343
if not self.list(graph_name):
4444
raise ValueError(f"A graph with name '{graph_name}' does not exist in the catalog.")
45-
return get_graph(graph_name, self.cypher_runner)
45+
return get_graph(graph_name, self._cypher_runner)
4646

4747
def construct(
4848
self,

src/graphdatascience/query_runner/session_query_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
from graphdatascience.query_runner.termination_flag import TerminationFlag
1414
from graphdatascience.server_version.server_version import ServerVersion
1515

16-
from ..arrow_client.error_handler import handle_flight_error
1716
from ..call_parameters import CallParameters
17+
from ..procedure_surface.arrow.error_handler import handle_flight_error
1818
from ..session.dbms.protocol_resolver import ProtocolVersionResolver
1919
from .protocol.project_protocols import ProjectProtocol
2020
from .protocol.write_protocols import WriteProtocol

tests/unit/arrow_client/V1/test_gds_arrow_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
)
1616

1717
from graphdatascience.arrow_client.authenticated_flight_client import AuthenticatedArrowClient
18-
from graphdatascience.arrow_client.error_handler import handle_flight_error
1918
from graphdatascience.arrow_client.v1.gds_arrow_client import GdsArrowClient
19+
from graphdatascience.procedure_surface.arrow.error_handler import handle_flight_error
2020
from graphdatascience.query_runner.arrow_authentication import UsernamePasswordAuthentication
2121
from graphdatascience.query_runner.arrow_info import ArrowInfo
2222

0 commit comments

Comments
 (0)