-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nx-cugraph: indicate which plc algorithms are used and version_added #4069
Conversation
I'm thinking something like this: import re
import networkx as nx
from networkx.utils.backends import _registered_algorithms as algos
from _nx_cugraph import get_info
from nx_cugraph.interface import BackendInterface
def get_funcpath(func):
return f"{func.__module__}.{func.__name__}"
def add_branch(G, funcpath, plc):
branch = funcpath.split(".")
prev = branch[0]
for i in range(2, len(branch)):
cur = ".".join(branch[:i])
G.add_edge(prev, cur)
prev = cur
if plc is not None:
funcpath += " (" + ", ".join(sorted(plc)) + ")"
G.add_edge(prev, funcpath)
path_to_name = {
get_funcpath(algos[funcname]): funcname
for funcname in get_info()["functions"].keys() & algos.keys()
}
G = nx.DiGraph()
for funcpath in sorted(path_to_name):
funcname = path_to_name[funcpath]
add_branch(G, funcpath, getattr(BackendInterface, funcname)._plc_names)
print(re.sub(r"[A-Za-z_\.]*\.", "", ("\n".join(nx.generate_network_text(G))))) which creates
@rlratzel what do you think and what would you find helpful? I'm not sure if showing PLC usage is helpful to users, but I think it is to us. It may be better to show the dispatch name in parentheses if it's different from the networkx name, and then maybe show PLC usage in a different diagram. |
Here's an example that shows how PLC functions are used:
|
Other metadata that might be nice to add to |
I just added the ability to see what functions are "incomplete" (such as unsupported API) and "different" (such as behavior of RNG). It's a little sobering, but can be a good guide for identifying potential cugraph-core work. It might be nice to be able to filter by complete/incomplete/etc. Also, the regex used by |
/ok to test |
# "backend" used in nx version >= 3.2 | ||
[project.entry-points."networkx.backends"] | ||
cugraph = "nx_cugraph.interface:BackendInterface" | ||
|
||
[project.entry-points."networkx.backend_info"] | ||
cugraph = "_nx_cugraph:get_info" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, this is needed to work with dev version of NetworkX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very neat, thanks! I'm approving but I also had some suggestions I hope you consider. Of all of them, the single metadata
dictionary is my biggest preference.
/ok to test |
/merge |
Pretty simple PR. I would like for us to use this metadata when creating tables of supported algorithms.