[ESI] Expose accelerator through AcceleratorConnection py api (#8781)

It is possible that the `AcceleratorConnection` that is instantiated has handed ownership of a constructed accelerator through ` `AcceleratorConnection::takeOwnership`. In that case, it should be possible to retrieve a handle to the given accelerator through the python API. That is this PR.
This commit is contained in:
Morten Borup Petersen 2025-07-29 08:36:22 +02:00 committed by GitHub
parent 7f9e66f5f5
commit d9545ff5a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -41,6 +41,13 @@ class AcceleratorConnection:
def get_service_hostmem(self) -> cpp.HostMem:
return self.cpp_accel.get_service_hostmem()
def get_accelerator(self) -> "Accelerator":
"""
Return an accelerator that may be owned by this accelerator connection.
If no accelerator is owned, will throw.
"""
return Accelerator(self.cpp_accel.get_accelerator())
from .esiCppAccel import HostMemOptions

View File

@ -414,7 +414,9 @@ PYBIND11_MODULE(esiCppAccel, m) {
[](AcceleratorConnection &acc) {
return acc.getService<services::HostMem>({});
},
py::return_value_policy::reference);
py::return_value_policy::reference)
.def("get_accelerator", &AcceleratorConnection::getAccelerator,
py::return_value_policy::reference);
py::class_<Manifest>(m, "Manifest")
.def(py::init<Context &, std::string>())