From 96b335e3c23db1db6a40a871cc993e1e86c7e5c1 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Sat, 23 Sep 2023 17:40:54 +0300 Subject: [PATCH] Fix ignore auto detected `platform` when passing config.pbtxt with `platform` entry --- .gitignore | 6 ++++++ clearml_serving/__main__.py | 11 +++++++++-- clearml_serving/engines/triton/triton_helper.py | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f3038c1..32ff9ae 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ build/ # JetBrains IDE .idea/ +.vscode/ + +tests/huggingface # Generated by MacOS .DS_Store @@ -20,6 +23,9 @@ build/ # Generated by Windows Thumbs.db +# Virtual environment +.venv + # Applications *.app *.exe diff --git a/clearml_serving/__main__.py b/clearml_serving/__main__.py index 4ac78e6..fe61bc6 100644 --- a/clearml_serving/__main__.py +++ b/clearml_serving/__main__.py @@ -6,15 +6,22 @@ from pathlib import Path from clearml.model import Framework -from clearml_serving.serving.model_request_processor import ModelRequestProcessor, CanaryEP from clearml_serving.serving.endpoints import ModelMonitoring, ModelEndpoint, EndpointMetricLogging +from clearml_serving.serving.model_request_processor import ModelRequestProcessor, CanaryEP +from clearml_serving.version import __version__ + +# noinspection PyBroadException +try: + from clearml.backend_api import Session + Session.add_client(__package__.partition(".")[0].replace("_", "-"), __version__) # noqa +except Exception: + pass verbosity = False answer_yes = False def verify_session_version(request_processor): - from clearml_serving.version import __version__ current_v = float('.'.join(str(__version__).split(".")[:2])) stored_v = float('.'.join(str(request_processor.get_version()).split(".")[:2])) if stored_v != current_v: diff --git a/clearml_serving/engines/triton/triton_helper.py b/clearml_serving/engines/triton/triton_helper.py index ff606cb..c765627 100644 --- a/clearml_serving/engines/triton/triton_helper.py +++ b/clearml_serving/engines/triton/triton_helper.py @@ -359,6 +359,22 @@ class TritonHelper(object): for i, s in enumerate(endpoint.output_name or []): config_dict.put("output.{}.name".format(i), "\"{}\"".format(s)) + # check if we have platform in the auxiliary config pbtxt + if platform and final_config_pbtxt: + # noinspection PyBroadException + try: + final_config_pbtxt_dict = ConfigFactory.parse_string(final_config_pbtxt) + # if we found it, null the requested platform and use the auxiliary config pbtxt platform `value` + if final_config_pbtxt_dict.get("platform", None): + print( + "WARNING: ignoring auto-detecetd `platform={}` " + "and using auxiliary pbtxt `platform={}`".format( + str(platform).lower(), final_config_pbtxt_dict.get("platform"))) + platform = None + except Exception: + # we failed parsing the auxiliary pbtxt + pass + if platform and not config_dict.get("platform", None) and not config_dict.get("backend", None): platform = str(platform).lower() if platform.startswith("tensorflow") or platform.startswith("keras"):