@@ -118,30 +118,6 @@ def __init__(
118118 )
119119 self ._instance_description = instance_description
120120
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-
145121 def __run_cypher_simplified_for_query_progress_logger (self , query : str , database : Optional [str ]) -> DataFrame :
146122 # progress logging should not retry a lot as it perodically fetches the latest progress anyway
147123 connectivity_retry_config = Neo4jQueryRunner .ConnectivityRetriesConfig (max_retries = 2 )
@@ -174,6 +150,8 @@ def run_cypher(
174150 else :
175151 raise e
176152
153+ self .__configure_warnings_filter ()
154+
177155 df = result .to_df ()
178156
179157 if self ._NEO4J_DRIVER_VERSION < SemanticVersion (5 , 0 , 0 ):
@@ -364,6 +342,25 @@ def _verify_connectivity(
364342 if retrys == retry_config .max_retries :
365343 raise UnableToConnectError (f"Unable to connect to the { self ._instance_description } " ) from exception
366344
345+ def __configure_warnings_filter (self ) -> None :
346+ if Neo4jQueryRunner ._NEO4J_DRIVER_VERSION >= SemanticVersion (5 , 21 , 0 ):
347+ notifications_logger = logging .getLogger ("neo4j.notifications" )
348+ # the client does not expose YIELD fields so we just skip these warnings for now
349+ notifications_logger .addFilter (
350+ lambda record : (
351+ "The query used a deprecated field from a procedure" in record .msg and "by 'gds." in record .msg
352+ )
353+ )
354+ notifications_logger .addFilter (
355+ lambda record : "The procedure has a deprecated field" in record .msg and "gds." in record .msg
356+ )
357+ warnings .filterwarnings (
358+ "ignore" ,
359+ message = r"^pandas support is experimental and might be changed or removed in future versions$" ,
360+ )
361+ warnings .filterwarnings ("ignore" , message = r".*The procedure has a deprecated field.*by'gds.*" )
362+ warnings .filterwarnings ("ignore" , message = r".*The query used a deprecated procedure.*by'gds.*" )
363+
367364 class ConnectivityRetriesConfig (NamedTuple ):
368365 max_retries : int = 600
369366 wait_time : int = 1
0 commit comments