-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
ENH : Adding backend_info
entry point
#27
Conversation
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.
This looks nice! Thanks!
Here are some comments -- but mostly questions...
- perhaps we should raise an exception for invalid
n_jobs
. My thinking is that If they specified an input that doesn't make sense they probably meant something else. - Having
n_jobs=-2
means 1 CPU is left untouched. That off-by-one value might cause confusion. Maybe-1
should mean all-but-one. That would match indexing wherea[:-1]
returns all but the last element. - The case
n_jobs==0
is currently not valid. What do you think about making that mean use-all-cpus? With this and the previous comment the docstring would say "if n_jobs <= 0, thenn_cpus + n_jobs
cpus are used." - I guess the doc_string for n_jobs should say what
n_cpus
means. - you removed some examples from the doc_strings. I'm fine with that, but would like to write down the criteria for what part of the NX function doc_string we will keep for the nx-parallel doc_string. What criteria did you use? (this will be flexible for a while until we figure out what is best, but probably good to start discussing it).
:)
I initially thought of raising an exception, but in joblib when you pass
Here also I was trying to follow the n_jobs from joblib. In sklearn also the default is -1 and it also means using all the CPUs. But, I know it makes more sense to make 0 or all the cores as default. In this issue(joblib/joblib#1504) they have mentioned they cannot make such a change because it's a big project and it'll impact a lot of people. But, we can make 0 as default if we want. :)
I didn't remove a lot of things(only examples related networkx and not nx-parallel and see also section, i'll add nx-parallel specific egs soon), as i wanted to discuss it with you and @MridulS . I don't think we should remove all of the Thanks! |
def all_pairs_bellman_ford_path(G, weight="weight"): | ||
"""Compute shortest paths between all nodes in a weighted graph. | ||
def all_pairs_bellman_ford_path(G, weight="weight", n_jobs=-1): | ||
"""Parallelly computes shortest paths between all nodes in a weighted graph. |
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.
You are right that we need to find better wording here. The NetworkX wording obviously doesn't include parallel. But "parallelly" is almost never used for computing. (I could be wrong here, but I haven't seen it. The definition of the word exists, but it doesn't seem to be used in computing. Please let me know if I'm wrong with this.)
Other possible words/phrases:
"""Computes in parallel shortest paths between all nodes in a weighted graph.
"""Computes, in parallel, shortest paths between all nodes in a weighted graph.
"""Computes shortest paths between all nodes in a weighted graph in parallel
"""Computes shortest paths between all nodes in a weighted graph (parallel version)
"""Parallel version of networkx.all_pairs_bellman_ford_path
"""Parallel algorithm for shortest_paths between all nodes in a weighted graph
Thoughts?
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.
Here’s another idea for wording:
Parallel computation of …..
I made a separate PR for adding |
Also, I have updated the docs and removed a lot of them. Please let me know if you think I have removed too much somewhere. Thanks! Also, this failed workflow test seems unrelated to the changes I've made. |
I had a question and a suggestion related to the documentation issue: Question : Suggestion : |
I understand your comment about making n_job changes in a separate PR. We will have to think about it more. I don't think you have removed too much -- but we do need to figure out what we will use the doc_strings for before we know how much to remove or keep. Python allows the assignment and reassignment of doc_strings on functions within a single python session. The doc_string is held as a string in the We should figure out who we are aiming for with the doc_strings. Are we wanting them in the code where people reading the code will see? Are we wanting them at the python interpretter level so people in Ipython can type I think an early step is to figure out how to add a box with a few lines to the NX documentation. Like cugraph does for this:https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.centrality.betweenness_centrality.html |
In the recent commit, I've made it so that the docstring of all functions is extracted, and then from that the |
I've made this PR independent from PR#7219 and updated the first comment indicating all the changes made. Thanks! |
backend_info
entry point
Alright, let's try this out with nx main docs. |
Hmm, this doesn't seem to work, I can't see nx-parallel show up in the docs. I'll debug this later this week. |
the problem might be from this line So, to solve this we can check if the given values for keys(extra_parameters and extra_docstring) are |
running this script shows what get_info returns : import nx_parallel as nxp
l = nxp.get_info()
for i in l:
if i != "functions":
print(i)
print(l[i])
print()
else:
print(i)
for j in l[i]:
print(j)
print(l[i][j])
print() output :
|
I don't think this is the issue bcoz after re-running the tests under networkx/networkx#7219 , the nx-parallel note was still not appearing in the documentation artifact. |
#55 resolves this |
[UPDATED]
__init__.py
files and tried to make the code consistent in a few placesget_info()
function inutils.backend
(to show nx-parallel docs on the main networkx docs webpage)[Addedget_info()
inutils.backend
instead ofnx_parallel/__init__.py
because to extract the docstrings of all the algorithms we need to import all algos in nx_parallel and doing that in__init__.py
gives circular import error]python -m pytest --doctest-modules --pyargs nx_parallel
from wf tests, bcoz error due to no examples in docstring to testAssumption(syntax) : The docstring of functions should be as follows