MLServer icon indicating copy to clipboard operation
MLServer copied to clipboard

Unable to use `tritonclient.grpc`

Open tokoko opened this issue 10 months ago • 4 comments

I'm trying to use tritonclient.grpc inside an mlserver model, but looks like they don't really go well with one another. python -c "import mlserver;import tritonclient.grpc" results in a Couldn't build proto file into descriptor pool: duplicate symbol 'inference.ServerLiveRequest' . I'm not a protobuf expert, but seems like both mlserver and tritonclient have protobuf-generated classes from identical (or maybe just similar?) OIP protos and they conflict with one another. Is there any way to work around this? For example, is it realistic for mlserver to use proto classes from tritonclient directly since it's a required dependency anyway?

I think another simpler solution might be changing package declaration in dataplane.proto from inference to something like inference_mlserver.

tokoko avatar May 02 '24 06:05 tokoko

As far as I could tell, the one thing that package name change would affect is Prometheus metrics, package name is part of a key in metrics, I think.

tokoko avatar May 02 '24 14:05 tokoko

Both mlserver and tritonclient.grpc declare a submodule called inference. This leads to the duplicate symbol, which should be solvable through typical means (more specific imports, import ... as, etc).

lc525 avatar May 02 '24 20:05 lc525

Hey, thanks for the response. Unfortunately, I don't think it's that simple. The error happens even with top-level imports, I'm not trying to import anything message related specifically. For example running python -c "import tritonclient.grpc; import mlserver" leads to an error with the following stack trace:

File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/mlserver/__init__.py", line 2, in <module>
    from .server import MLServer
  File "/usr/local/lib/python3.9/site-packages/mlserver/server.py", line 17, in <module>
    from .grpc import GRPCServer
  File "/usr/local/lib/python3.9/site-packages/mlserver/grpc/__init__.py", line 1, in <module>
    from .server import GRPCServer
  File "/usr/local/lib/python3.9/site-packages/mlserver/grpc/server.py", line 9, in <module>
    from .servicers import InferenceServicer
  File "/usr/local/lib/python3.9/site-packages/mlserver/grpc/servicers.py", line 3, in <module>
    from . import dataplane_pb2 as pb
  File "/usr/local/lib/python3.9/site-packages/mlserver/grpc/dataplane_pb2.py", line 16, in <module>
    DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
TypeError: Couldn't build proto file into descriptor pool: duplicate symbol 'inference.ServerLiveRequest'

I'm not exactly sure what this method (_descriptor_pool.Default().AddSerializedFile) does, but looks like it's registering symbols in some global namespace, which can't really be remedied with a simple import ... as ... statement, symbols are hardcoded in both libraries.

tokoko avatar May 02 '24 20:05 tokoko

@lc525 hey, have you had an opportunity to look into this?

tokoko avatar May 08 '24 07:05 tokoko