iris-hep / analysis-grand-challenge

Repository dedicated to AGC preparations & execution
https://agc.readthedocs.io
MIT License
24 stars 39 forks source link

fix: do not import tritonclient.grpc unless needed #139

Closed eguiraud closed 1 year ago

eguiraud commented 1 year ago

The import can error out if triton is not set up correctly, but we do not care whether triton is set up correctly unless we actually want to use it.

Given the error this could also just be a missing dependency, but I think a delayed import makes sense in general.

The error I got after creating an environment according to requirements.txt:

   Traceback (most recent call last):
     File "/home/blue/Tools/miniconda3/envs/agc-py311/lib/python3.11/site-packages/tritonclient/grpc/__init__.py", line 30, in <module>
       from google.protobuf.json_format import MessageToJson
   ModuleNotFoundError: No module named 'google.protobuf'

   The above exception was the direct cause of the following exception:

   Traceback (most recent call last):
     File "/home/blue/Scratchpad/work/agc/analysis-grand-challenge/analyses/cms-open-data-ttbar/ttbar_analysis_pipeline.py", line 63, in <module>
       import tritonclient.grpc as grpcclient
     File "/home/blue/Tools/miniconda3/envs/agc-py311/lib/python3.11/site-packages/tritonclient/grpc/__init__.py", line 39, in <module>
       raise RuntimeError(
   RuntimeError: The installation does not include grpc support. Specify 'grpc' or 'all' while installing the tritonclient package to include the support