-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Log "can/should run" and caching in dispatch machinery #7568
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
Conversation
Schefflera-Arboricola
left a comment
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.
Thanks @eriknw :)
networkx/utils/backends.py
Outdated
| _logger.debug( | ||
| "Backend '%s' does not implement `%s'", backend_name, self.name | ||
| ) |
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.
Do we want to log it and also raise an exception here? isn't the error msg sufficient?
>>> nx.degree_centrality(G, backend="parallel")
Backend 'parallel' does not implement `degree_centrality'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/workspaces/networkx/networkx/utils/decorators.py", line 789, in func
return argmap._lazy_compile(__wrapper)(*args, **kwargs)
File "<class 'networkx.utils.decorators.argmap'> compilation 29", line 3, in argmap_degree_centrality_26
File "/workspaces/networkx/networkx/utils/backends.py", line 911, in __call__
return self._convert_and_call(
File "/workspaces/networkx/networkx/utils/backends.py", line 1371, in _convert_and_call
raise RuntimeError(msg)
RuntimeError: 'degree_centrality' not implemented by parallelThere 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.
Hmm, that duplication is kind of unfortunate. Nice attention to detail.
I just pushed a change that doesn't write that log message when that exception will be raised. The log message may have info that doesn't show up in the warnings--specifically, the string returned by can_run--so maybe a little duplication is okay if the log message may be more helpful.
Co-authored-by: Aditi Juneja <91629733+Schefflera-Arboricola@users.noreply.github.com>
Co-authored-by: Aditi Juneja <91629733+Schefflera-Arboricola@users.noreply.github.com>
Schefflera-Arboricola
left a comment
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.
MridulS
left a comment
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.
Not a blocker for this PR but we really need to find good ways to test the backends.py file.
* Log "can run" and "should run" in dispatch machinery * Also add logging for using cache * Make code more concise by combining branches for `should_run` Co-authored-by: Aditi Juneja <91629733+Schefflera-Arboricola@users.noreply.github.com> * Make code more concise by combining branches for `can_run` Co-authored-by: Aditi Juneja <91629733+Schefflera-Arboricola@users.noreply.github.com> * Don't log if info also in error message * Log when falling back to networkx too --------- Co-authored-by: Aditi Juneja <91629733+Schefflera-Arboricola@users.noreply.github.com> Co-authored-by: Mridul Seth <seth.mridul@gmail.com>
This adds informative logging messages for
can_runandshould_runto better understand behaviors of dispatching.