Skip to content

Commit

Permalink
reuse validate input
Browse files Browse the repository at this point in the history
Signed-off-by: kalyanr <[email protected]>
  • Loading branch information
rawwar committed Dec 7, 2023
1 parent 1b81c84 commit bd82bf1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions opensearch_py_ml/ml_commons/model_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit bd82bf1

Please sign in to comment.