networkx / nx-parallel

A networkx backend that uses joblib to run graph algorithms in parallel.
BSD 3-Clause "New" or "Revised" License
23 stars 20 forks source link

RuntimeWarning when loading parallel backend #52

Closed dschult closed 5 months ago

dschult commented 6 months ago

I get this locally too, but the pytest logs on CI actions also show a warning:

  C:\Miniconda\envs\testing\lib\site-packages\networkx\utils\backends.py:143: RuntimeWarning: Error encountered when loading info for backend parallel: partially initialized module 'networkx' has no attribute '_dispatchable' (most likely due to a circular import)

I suspect nx-parallel is being imported as part of the networkx import and nx-parallel is importing networkx as part of its import, so we're getting a circular import.

I think the solution is to delay importing networkx from within nx-parallel until after nx-parallel is fully imported. I haven't looked for all the places that import networkx but I suspect it is quite a few.

Is there an easier approach? How does graphblas-algorithms do it? @Schefflera-Arboricola are you getting this warning also?

eriknw commented 6 months ago

Other backends only get loaded when needed such as when calling one of their backends. The networkx.backend_info entry-point is used to provide information without importing the backend (or networkx).

See: