Repository navigation
Refactoring and enhancing user-facing Backend and Configs docs - #7404
Conversation
dschult
left a comment
There was a problem hiding this comment.
Thanks for this!
I like the brief descriptions of the backends and all the wording checks.
The reorg is harder for me to visualize by looking at the diff. So I have to view the full source and/or the html docs. They seem good too.
See more minor comments below.
Co-authored-by: Dan Schult <[email protected]>
Co-authored-by: Dan Schult <[email protected]>
Co-authored-by: Dan Schult <[email protected]>
Co-authored-by: Dan Schult <[email protected]>
Co-authored-by: Dan Schult <[email protected]>
dschult
left a comment
There was a problem hiding this comment.
I think this is ready to be merged. I don't see any specific questions yet to be resolved, and we can update the docs further in another PR.
Thanks @Schefflera-Arboricola !
eriknw
left a comment
There was a problem hiding this comment.
Thanks for these changes! This reads better. I left a few comments, and many of them remark on possible future enhancements.
| that is similar to ``can_run``, but answers whether the backend *should* be run | ||
| (converting if necessary). Like ``can_run``, it receives the original arguments |
There was a problem hiding this comment.
I know you moved these lines from elsewhere, but I'm not sure this sentence is fully accurate or clear. should_run is only run when doing conversions. Hence, should_convert_and_run would be a more accurate name. @rlratzel and I have argued about this a couple times, b/c we sometimes get confused.
Perhaps an enhancement to should_run could be to add e.g. requires_conversion=True keyword to make this more clear and more useful.
There was a problem hiding this comment.
Since this is not quite accurate, can we clean up the language here?
| 4. ``on_start_tests`` (Optional): | ||
| A special ``on_start_tests(items)`` function may be defined by the backend. | ||
| It will be called with the list of NetworkX tests discovered. Each item | ||
| is a test object that can be marked as xfail if the backend does not support | ||
| the test using ``item.add_marker(pytest.mark.xfail(reason=...))``. |
There was a problem hiding this comment.
As a future enhancement, I think it would be nice to have a place that demonstrates how to use this effectively. For example, both cugraph and graphblas backends define something like this for convenience. Perhaps a more complete example could be in the backend cookie-cutter that we'd like to make from the j4f or nx-loopback backends, and then this document could link there.
|
|
||
| This decorator function dispatches to | ||
| a different backend implementation based on the input graph types, and it also | ||
| manages all the ``backend_kwargs``. Usage can be any of the following decorator |
There was a problem hiding this comment.
Is this the first place we mention backend_kwargs? How should we talk about backend functions allowing additional keyword arguments? For that matter, do we talk about what get_info is able to return including "additional_docs"?
Also, should we mention backend="my_backend" to choose a bakcend when calling a dispatchable function?
There was a problem hiding this comment.
It is previously mentioned on the "Backends and Config" docs page but this is the first time mentioned on the dispatchable decorator docs page. On the "Backends and Config" docs page, I've made its explanation more detailed. Please look at it and LMK if something doesn't seem right there because I just tried to explain it by looking at the code in __call__ of the dispatchable class, so I might be missing some context there. pls LMK if that looks fine.
I've also added the details of the get_info function as well.
|
|
||
| And you can disable all the loggers by running this:: | ||
|
|
||
| logging.disable(logging.CRITICAL) | ||
|
|
||
| And then re-enable it by running:: | ||
|
|
||
| logging.disable(logging.NOTSET) | ||
|
|
There was a problem hiding this comment.
It might be good to also demonstrate how to disable logging for specific modules, since some applications may want logging elsewhere. To disable the logging calls in the dispatcher, this can be done:
logging.getLogger("networkx.utils.backends").setLevel(logging.CRITICAL)Then of course to re-enable debug logging:
logging.getLogger("networkx.utils.backends").setLevel(logging.DEBUG)For similar reasons, users may want to enable debug logging only for networkx and nothing else. To do that, they can use:
nxl = logging.getLogger("networkx")
nxl.addHandler(logging.StreamHandler())
nxl.setLevel(logging.DEBUG)There was a problem hiding this comment.
This is starting to sound like we are re-documenting how to do logging. Logging needs to be simple and useful to be included.
Can we point to a good link that explains logging in a clear way? Could that let us remove docs here rather than repeating (and continually updating) what is developed and controlled eslewhere?
There was a problem hiding this comment.
I agree, that's a good point. I think backend users and devs might appreciate a short note about how logging can be used to help tune/debug workflows though, so maybe something like this?
Add the following code to enable debug log messages:
import logging
logging.basicConfig(level=logging.DEBUG)
See https://docs.python.org/3/library/logging.html for detailed usage
and https://docs.python.org/3/howto/logging-cookbook.html for additional examples.
If that's too much, maybe just this (or some version of this)?
NetworkX has debug logging which can be enabled to assist backend users and developers in
debugging (e.g. what backend is being used and what args are being passed) using the standard
python logging library. See the Python docs on logging for usage and examples:
https://docs.python.org/3/library/logging.html
https://docs.python.org/3/howto/logging-cookbook.html
There was a problem hiding this comment.
Your first example is certainly not too much: how to turn it on and a pointer to where to learn more.
And I like the second example's first sentence as an overview. Is this too much?
NetworkX has debug logging which can be enabled to assist backend users and developers in
debugging (e.g. what backend is being used and what args are being passed) using the standard
python logging library. Add the following code to enable debug log messages:
import logging
logging.basicConfig(level=logging.DEBUG)
See https://docs.python.org/3/library/logging.html for detailed usage
and https://docs.python.org/3/howto/logging-cookbook.html for additional examples.
There was a problem hiding this comment.
I only added the first link because the second link is very clearly available on the first link's page in a box with the heading "Important". And I also added the code for disabling the logging because that seemed like an important functionality and I thought it would be nice if someone doesn't have to go to an external link to find how it is done.
rlratzel
left a comment
There was a problem hiding this comment.
Very happy to see the new docs for backend developers and testing!
| let you execute an alternative backend implementation instead of NetworkX's | ||
| pure Python dictionaries implementation. Things will almost certainly | ||
| change and break in future releases! | ||
| .. note:: Both NetworkX backend and config systems are experimental. |
There was a problem hiding this comment.
I like the new separate sections in the code for backend users and backend developers, but people reading this doc may not see that and think backends should not be used for production code. Since this doc seems to be aimed at end users, my preference would be to remove this note completely.
dschult
left a comment
There was a problem hiding this comment.
I think this is ready to merge. And we can change things moving forward in other PRs. It doesn't have to be a large rewrite -- but I think this fairly large change really set us on the right track and we can tweak it as needed more easily.
Co-authored-by: Erik Welch <[email protected]>
Co-authored-by: Erik Welch <[email protected]>
eriknw
left a comment
There was a problem hiding this comment.
Looks great to me! Thanks everyone who helped with this, and especially @Schefflera-Arboricola who did most of the work 👍
Thanks for the gentle nudge! The main reason is that I'm still getting used to merging in this org 😂 . @rlratzel and I were also discussing this PR last week, and I wanted to give him a chance to review one last time (he did, and he approved). |
…tworkx#7404) * refactoring and enhancing docs * Update networkx/utils/backends.py Co-authored-by: Dan Schult <[email protected]> * wording change__ Co-authored-by: Dan Schult <[email protected]> * Update configs.py * added docs for logging * renamed LoopbackDispatcher to LoopbackBackendInterface * updated entry_point * updated example * updated logging example * updated experimental note and divided docs into users and developers * reverting renaming * nx to networkx Co-authored-by: Erik Welch <[email protected]> * Update note Co-authored-by: Erik Welch <[email protected]> --------- Co-authored-by: Dan Schult <[email protected]> Co-authored-by: Erik Welch <[email protected]>
Backend and Configsdocs(in cont. with [DOC, DISPATCH] : updated and addedbackend.py's docs #7305)Thank you :)