Allow backends to implement should_run#7257
Conversation
I don't think we should restrict it to cases where a conversion would be done. I think we should allow backend developers the freedom to communicate that they may be too slow, buggy, experimental, etc. for specific operations/corner cases even if the graph is already converted. Of course, the backend should also be able to see if a conversion would be required or not and use that to influence its decision too. The "reason" string is crucial here for a good UX (and I think it should be required). clarification: if |
|
@eriknw and I met offline and discussed that this PR could be merged with the policy in place to only consider Merging it now will allow |
dschult
left a comment
There was a problem hiding this comment.
This looks like a possibly useful feature depending on whether the developers understand it well and implement it well. But that is true for all code:)
I'm approving this -- but given the discussion today, if you want to delay merging it that is fine with me too.
|
Thanks @dschult! I think this is good to go in. It shouldn't hurt anything, and it gives backends a chance to improve UX (if they return False for IIRC, we'll want to do more with this in the future (such as using the returned string in logging, warning, or introspection), and we said this PR isn't a "must have" for 3.3, but I think it's still "nice to have". @rlratzel am I missing anything? If nothing else, it's good to get this in so it's easier for me to refactor the dispatching code :) |
* Allow backends to implement `should_run` * Handle str return types for `can_run` and `should_run`
As discussed in the weekly dispatching call (and first proposed by @rlratzel I believe), this PR adds
should_runthat is likecan_run, but answers whether the backend should be called (converting if necessary).Right now, this only applies to when networkx graphs would be converted to backend graphs before running the networkx algorithm, so it would be accurate to call it
should_convert_and_run, but that's wordy, and we'll probably add more sophisticated things soon such as caching and backend-to-backend conversions, soshould_runis more generically accurate and useful.should_rundoes not get used...backend=...is given