From bd82bf1ebb7393981f973b0d301c3c264ca6e042 Mon Sep 17 00:00:00 2001 From: kalyanr Date: Thu, 7 Dec 2023 07:17:08 +0530 Subject: [PATCH] reuse validate input Signed-off-by: kalyanr --- opensearch_py_ml/ml_commons/model_profile.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/opensearch_py_ml/ml_commons/model_profile.py b/opensearch_py_ml/ml_commons/model_profile.py index fecdddab..d1b38549 100644 --- a/opensearch_py_ml/ml_commons/model_profile.py +++ b/opensearch_py_ml/ml_commons/model_profile.py @@ -20,14 +20,13 @@ def __init__(self, os_client: OpenSearch): def _validate_input(self, path_parameter, payload): if path_parameter is not None and not isinstance(path_parameter, str): - raise ValueError("payload needs to be a dictionary or None") - - if payload is not None and not isinstance(payload, dict): raise ValueError("path_parameter needs to be a string or None") - def get_profile(self, payload: Optional[dict] = None): if payload is not None and not isinstance(payload, dict): raise ValueError("payload needs to be a dictionary or None") + + def get_profile(self, payload: Optional[dict] = None): + self._validate_input(None, payload) return self.client.transport.perform_request( method="GET", url=f"{ML_BASE_URI}/{self.API_ENDPOINT}", body=payload )