Improve usability of LinkNavigator from python#919
Improve usability of LinkNavigator from python#919tmadlener wants to merge 6 commits intoAIDASoft:masterfrom
Conversation
|
@tmadlener, I quickly tested, seems to work with mutables now 👀 |
|
Thanks for checking. |
f8ee675 to
4aace31
Compare
|
We should add also the python wrapping parts here to make it really easy to use. |
| /// Overload for cppyy that makes things work with mutable handles | ||
| template <typename ToU = ToT> | ||
| std::enable_if_t<!std::is_same_v<FromT, ToU>, std::vector<WeightedObject<FromT>>> | ||
| getLinked(const ToT::mutable_type& object) const { | ||
| return getLinked(ToT(object), podio::ReturnFrom); | ||
| } | ||
|
|
There was a problem hiding this comment.
I didn't check but would it still work with cppyy if std::enable_if was changed to requires and concept? (here and I the code we already have for immutable object)
eb9b908 to
878eb49
Compare
|
I made Claude come up with some "python bindings" and this looks like a reasonable solution to me. The one thing that doesn't yet transpire through the whole cppyy machinery is the capabilities of structured bindings for the podio/tests/unittests/links.cpp Line 665 in 2a69481 But trying to do the same in python currently fails with |
878eb49 to
982dd69
Compare
|
Many CI jobs are failing due to the @jmcarcell do you think adding the workarounds that were added to resolve #770 (#808 and #775) should also be added to the |
|
I have pushed a fix, as usual it is not trivial and it's in a different place from the other cases. I'll think about this tomorrow. |
|
Thanks :) @dudarboh do you want to give this another go before we merge to see if it indeed fixes the issues you observed? |
Attempt for checking whether this is enough to get some parts of the LinkNavigator work more easily from the python side
Simple factory function with the same name, that takes care of the proper instantiation
3828d77 to
a39f56a
Compare
|
I quickly tested everything looks good, @tmadlener . Could we maybe also add import edm4hep
import ROOT
ROOT.podio.LinkCollection[edm4hep.ReconstructedParticle, edm4hep.MCParticle]works, but import edm4hep
import podio
podio.LinkCollection[edm4hep.ReconstructedParticle, edm4hep.MCParticle]doesn't |
|
Would the use case for that be to write |
|
I think only for writing. Reading works fine now without providing explicit temlplate arguments: |
Attempt for checking whether this is enough to get some parts of the LinkNavigator work more easily from the python side
BEGINRELEASENOTES
Mutablehandles toLinkNavigator::getLinkedto make python bindings also work withMutablehandles.ENDRELEASENOTES
See #918 for some more discussion and insights.
@dudarboh this currently adds the "easy" part of more overloads that should hopefully help with calling
getLinkedwithMutablehandles. It doesn't yet add any other python wrapping for improving the other cumbersome parts that you found.