Skip to content

Commit

Permalink
changing code
Browse files Browse the repository at this point in the history
Signed-off-by: Alibi Zhenis <alibizhenis4@gmail.com>
  • Loading branch information
AlibiZhenis committed May 28, 2023
1 parent ec6f1ea commit 25cbdaa
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions opensearch_py_ml/ml_commons/model_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ def _execute(self, algorithm_name: str, input_json: dict) -> dict:
:rtype: dict
"""

if self._is_json(input_json):
return self._client.transport.perform_request(
method="POST",
url=f"{ML_BASE_URI}/_execute/{algorithm_name}",
body=input_json,
)

def _is_json(self, input_json: dict) -> bool:
if not isinstance(input_json, dict):
json.loads(input_json)
return True
input_json = json.loads(input_json)

return self._client.transport.perform_request(
method="POST",
url=f"{ML_BASE_URI}/_execute/{algorithm_name}",
body=input_json,
)

0 comments on commit 25cbdaa

Please sign in to comment.