From 623d0a56345bf5491fa21e910deddff1df7e074c Mon Sep 17 00:00:00 2001 From: KrishnanPrash <140860868+KrishnanPrash@users.noreply.github.com> Date: Fri, 30 Aug 2024 18:22:34 -0500 Subject: [PATCH] chore: Expose `TRITONSERVER_Server` instance in Python In-Process API (#385) Co-authored-by: Neelay Shah Co-authored-by: GuanLuo <41310872+GuanLuo@users.noreply.github.com> --- .gitignore | 1 + python/tritonserver/_api/_server.py | 3 +++ python/tritonserver/_c/tritonserver_pybind.cc | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 0e9f099a2..9948de3b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /build /.vscode *.so +*__pycache__/ diff --git a/python/tritonserver/_api/_server.py b/python/tritonserver/_api/_server.py index 9e78f8ac2..b85d2e5c6 100644 --- a/python/tritonserver/_api/_server.py +++ b/python/tritonserver/_api/_server.py @@ -621,6 +621,9 @@ def stop(self) -> None: self._server.stop() self._server = Server._UnstartedServer() + def _ptr(self): + return self._server._ptr() + def unregister_model_repository(self, repository_path: str) -> None: """Unregister model repository diff --git a/python/tritonserver/_c/tritonserver_pybind.cc b/python/tritonserver/_c/tritonserver_pybind.cc index 6017b3d7e..e7cd4b53b 100644 --- a/python/tritonserver/_c/tritonserver_pybind.cc +++ b/python/tritonserver/_c/tritonserver_pybind.cc @@ -2107,6 +2107,11 @@ PYBIND11_MODULE(triton_bindings, m) .export_values(); py::class_(m, "TRITONSERVER_Server") .def(py::init()) + .def( + "_ptr", + [](PyServer& server) { + return reinterpret_cast(server.Ptr()); + }) .def("stop", &PyServer::Stop) .def("register_model_repository", &PyServer::RegisterModelRepository) .def("unregister_model_repository", &PyServer::UnregisterModelRepository)