[python] Link lifetimes of SOMAArray
and ManagedQuery
#3516
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue and/or context:
[sc-61128]
Changes:
ManagedQuery
class, analogous to the otherSOMAObject
classes, serving as a thin wrapper around theclib.ManagedQuery
pybind11 object. This class links together the lifetime ofclib.ManagedQuery
to the high-levelSOMAArray
object (notclib.SOMAArray
)_util.py
to use the_array
stored inManagedQuery
, eliminating the need to pass the array in as a separate argumentSOMArray
instances at the same URI iterate using distinctManagedQuery
instancesNotes for Reviewer:
Another solution for the reported bug is to pass a
shared_ptr<SOMAArray>
instead ofunique_ptr
into theclib.ManagedQuery
constructor. This is similar to what we already do forclib.SOMAContext
. We attempted this solution, but it was unfeasible to a bug in the Pybind11 library. A pull request addressing this issue is currently under review: pybind/pybind11#2839. Given the current circumstances, the most effective solution is to implement this high-level thin wrapper class.