server
server copied to clipboard
Allow introspection and static analysis of `pb_utils` (Python backend)
Is your feature request related to a problem? Please describe.
When writing the model.py
file for a Python backend model, it is very difficult to correctly use triton_python_backend_utils
(aka pb_utils
). I can't install the module locally, but even if I try to develop inside the container, the python module itself does not provide objects like InferenceRequest
.
This means I can't do any kind of pre-run checks that my code works, such as with an IDE or a linter. I have no way to discover methods or properties of essential pb_utils
objects; if it's not discussed in documentation, I can't know it exists.
Further, these same "missing" objects aren't able to be used at type hints, which is odd.
This is a really unfortunate developer experience, and leads to a lot of back and forth when developing: update model.py
, restart server, make request.
While I don't understand the details, I know this is related to the C code. This is somewhat understandable, but other FFI-heavy python code doesn't seem to have these issues, e.g. numpy
, PyTorch, etc.
Describe the solution you'd like I would like to be able to
- statically check my
pb_utils
-using code for correctness, with tools like Pylance, Pylint, ruff, etc - interactively discover the API for this module
- use all classes as type hints
My preference would be for this to be possible outside of the provided containers (a package on PyPI?), but an in-container solution would still be a big improvement. If I could exec into a container, start a python interpreter, and import triton_python_backend_utils as pb_utils
then exposed all the functions and classes available at runtime, that'd be huge!
I suspect this involves some additional code to make explicit the C dependencies, but I'm not too sure what that looks like.
Describe alternatives you've considered Because this code is only available within the container, I'm not too sure what else I could do. If I'm missing something that would improve my developer experience here, I'm all ears!
P.S. I'm sorry if this isn't the right place for this; looks like Issues and Discussions have been disabled in the Python Backend repository