@@ -62,13 +62,12 @@ def _auto_func(func_name: str, /, *args: Any, **kwargs: Any) -> Any:
6262 """
6363 dfunc = _registered_algorithms [func_name ]
6464
65- backend_priority = []
65+ backend_priority : list [ str ] = []
6666 if nxadb .convert .GPU_AVAILABLE and nx .config .backends .arangodb .use_gpu :
6767 backend_priority .append ("cugraph" )
6868
6969 for backend in backend_priority :
70- if not dfunc .__wrapped__ ._should_backend_run (backend , * args , ** kwargs ):
71- logger .warning (f"'{ func_name } ' cannot be run on backend '{ backend } '" )
70+ if not _should_backend_run (backend , func_name , * args , ** kwargs ):
7271 continue
7372
7473 try :
@@ -80,14 +79,48 @@ def _auto_func(func_name: str, /, *args: Any, **kwargs: Any) -> Any:
8079 )
8180
8281 except NotImplementedError :
83- logger .warning (f"'{ func_name } ' not implemented for backend '{ backend } '" )
82+ logger .debug (f"'{ func_name } ' not implemented for backend '{ backend } '" )
8483 pass
8584
8685 default_backend = "networkx"
8786 logger .debug (f"'{ func_name } ' running on default backend '{ default_backend } '" )
8887 return _run_with_backend (default_backend , dfunc , args , kwargs )
8988
9089
90+ def _should_backend_run (
91+ backend_name : str , func_name : str , * args : Any , ** kwargs : Any
92+ ) -> bool :
93+ """
94+ Determine if a specific backend should be used for a given algorithm.
95+
96+ Copied from networkx-3.4.1/networkx/utils/backends.py#L1514-L1535
97+ to patch the implementation for backwards compatibility, as the signature of
98+ this function in NetworkX 3.3 is different from the one in NetworkX 3.4.
99+
100+ :param backend_name: The name of the backend to check.
101+ :type backend_name: str
102+ :param func_name: The name of the algorithm/function to be run.
103+ :type func_name: str
104+ :param args: Variable length argument list for the function.
105+ :type args: Any
106+ :param kwargs: Arbitrary keyword arguments for the function.
107+ :type kwargs: Any
108+ :returns: Whether the backend should be used.
109+ :rtype: bool
110+ """
111+ if backend_name == "networkx" :
112+ return True
113+
114+ backend = _load_backend (backend_name )
115+ should_run = backend .should_run (func_name , args , kwargs )
116+ if isinstance (should_run , str ) or not should_run :
117+ reason = f", because: { should_run } " if isinstance (should_run , str ) else ""
118+ logger .debug (f"Backend '{ backend_name } ' not used for '{ func_name } ' ({ reason } )" )
119+ return False
120+
121+ return True
122+
123+
91124def _run_with_backend (
92125 backend_name : str ,
93126 dfunc : NetworkXFunction ,
0 commit comments