@@ -57,19 +57,9 @@ def create_for_db(
5757 query_runner = Neo4jQueryRunner (
5858 endpoint , auto_close = False , bookmarks = bookmarks , database = database , show_progress = show_progress
5959 )
60-
6160 else :
6261 raise ValueError (f"Invalid endpoint type: { type (endpoint )} " )
6362
64- if Neo4jQueryRunner ._NEO4J_DRIVER_VERSION >= SemanticVersion (5 , 21 , 0 ):
65- notifications_logger = logging .getLogger ("neo4j.notifications" )
66- # the client does not expose YIELD fields so we just skip these warnings for now
67- notifications_logger .addFilter (
68- lambda record : (
69- "The query used a deprecated field from a procedure" in record .msg and "by 'gds." in record .msg
70- )
71- )
72-
7363 return query_runner
7464
7565 @staticmethod
@@ -96,15 +86,6 @@ def create_for_session(
9686 instance_description = "GDS Session" ,
9787 )
9888
99- if Neo4jQueryRunner ._NEO4J_DRIVER_VERSION >= SemanticVersion (5 , 21 , 0 ):
100- notifications_logger = logging .getLogger ("neo4j.notifications" )
101- # the client does not expose YIELD fields so we just skip these warnings for now
102- notifications_logger .addFilter (
103- lambda record : (
104- "The query used a deprecated field from a procedure" in record .msg and "by 'gds." in record .msg
105- )
106- )
107-
10889 return query_runner
10990
11091 @staticmethod
@@ -137,6 +118,30 @@ def __init__(
137118 )
138119 self ._instance_description = instance_description
139120
121+ self .__configure_warnings_filter ()
122+
123+ def __configure_warnings_filter (self ) -> None :
124+ if Neo4jQueryRunner ._NEO4J_DRIVER_VERSION >= SemanticVersion (5 , 21 , 0 ):
125+ notifications_logger = logging .getLogger ("neo4j.notifications" )
126+ # the client does not expose YIELD fields so we just skip these warnings for now
127+ notifications_logger .addFilter (
128+ lambda record : (
129+ "The query used a deprecated field from a procedure" in record .msg and "by 'gds." in record .msg
130+ )
131+ )
132+ notifications_logger .addFilter (
133+ lambda record : "The procedure has a deprecated field" in record .msg and "gds." in record .msg
134+ )
135+
136+ # Though pandas support may be experimental in the `neo4j` package, it should always
137+ # be supported in the `graphdatascience` package.
138+ warnings .filterwarnings (
139+ "ignore" ,
140+ message = r"^pandas support is experimental and might be changed or removed in future versions$" ,
141+ )
142+
143+ warnings .filterwarnings ("ignore" , message = r".*The procedure has a deprecated field.*by 'gds.*" )
144+
140145 def __run_cypher_simplified_for_query_progress_logger (self , query : str , database : Optional [str ]) -> DataFrame :
141146 # progress logging should not retry a lot as it perodically fetches the latest progress anyway
142147 connectivity_retry_config = Neo4jQueryRunner .ConnectivityRetriesConfig (max_retries = 2 )
@@ -169,39 +174,17 @@ def run_cypher(
169174 else :
170175 raise e
171176
172- # Though pandas support may be experimental in the `neo4j` package, it should always
173- # be supported in the `graphdatascience` package.
174- warnings .filterwarnings (
175- "ignore" ,
176- message = r"^pandas support is experimental and might be changed or removed in future versions$" ,
177- )
178-
179- # since 2025.04
180- warnings .filterwarnings (
181- "ignore" ,
182- message = r"The procedure has a deprecated field" ,
183- )
184-
185177 df = result .to_df ()
186178
187179 if self ._NEO4J_DRIVER_VERSION < SemanticVersion (5 , 0 , 0 ):
188180 self ._last_bookmarks = [session .last_bookmark ()]
189181 else :
190182 self ._last_bookmarks = session .last_bookmarks ()
191183
192- if (
193- Neo4jQueryRunner ._NEO4J_DRIVER_VERSION >= SemanticVersion (5 , 21 , 0 )
194- and result ._warn_notification_severity == "WARNING"
195- ):
196- # the client does not expose YIELD fields so we just skip these warnings for now
197- warnings .filterwarnings (
198- "ignore" , message = r".*The query used a deprecated field from a procedure\. .* by 'gds.* "
199- )
200- else :
201- notifications = result .consume ().notifications
202- if notifications :
203- for notification in notifications :
204- self ._forward_cypher_warnings (notification )
184+ notifications = result .consume ().notifications
185+ if notifications :
186+ for notification in notifications :
187+ self ._forward_cypher_warnings (notification )
205188
206189 return df
207190
0 commit comments