diff --git a/src/python_be.cc b/src/python_be.cc index 33b2ec77..1f5a2e34 100644 --- a/src/python_be.cc +++ b/src/python_be.cc @@ -2005,6 +2005,29 @@ ModelState::ValidateModelConfig() return nullptr; } +TRITONSERVER_Error* +ModelState::SetModelConfig() +{ + BackendModel::SetModelConfig(); + // `Update model_transaction_policy` if setting was set + // with `set_model_transaction_policy` + triton::common::TritonJson::Value model_transaction_policy; + bool is_decoupled = false; + if (ModelConfig().Find( + "model_transaction_policy", &model_transaction_policy)) { + triton::common::TritonJson::Value decoupled; + if (model_transaction_policy.Find("decoupled", &decoupled)) { + auto error = decoupled.AsBool(&is_decoupled); + if (error != nullptr) { + throw BackendModelException(error); + } + SetDecoupled(is_decoupled); + } + } + + return nullptr; +} + extern "C" { diff --git a/src/python_be.h b/src/python_be.h index fce1f417..f8ec8cfa 100644 --- a/src/python_be.h +++ b/src/python_be.h @@ -238,6 +238,9 @@ class ModelState : public BackendModel { // Is decoupled API being used. bool IsDecoupled() { return decoupled_; } + // Set decoupled mode + void SetDecoupled(bool decoupled) { decoupled_ = decoupled; } + // Returns the value in the `runtime_modeldir_` field std::string RuntimeModelDir() { return runtime_modeldir_; } @@ -247,6 +250,10 @@ class ModelState : public BackendModel { // Validate Model Configuration TRITONSERVER_Error* ValidateModelConfig(); + // Overrides `BackendModel::SetModelConfig` to also + // set `ModelState::decoupled_` + TRITONSERVER_Error* SetModelConfig(); + // Auto-complete stub std::unique_ptr& Stub() { return auto_complete_stub_; } diff --git a/src/resources/triton_python_backend_utils.py b/src/resources/triton_python_backend_utils.py index 9828ab5b..b4732da6 100644 --- a/src/resources/triton_python_backend_utils.py +++ b/src/resources/triton_python_backend_utils.py @@ -394,7 +394,7 @@ def add_input(self, input): + input["name"] + "' in auto-complete-config function for model '" + self._model_config["name"] - + "' contains property other than 'name', 'data_type' and 'dims'." + + "' contains property other than 'name', 'data_type', 'dims' and 'optional'." ) if "name" not in input: