Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
Signed-off-by: kalyanr <[email protected]>
  • Loading branch information
rawwar committed Dec 6, 2023
1 parent 2031705 commit 6692fe2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions opensearch_py_ml/ml_commons/ml_commons_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from opensearch_py_ml.ml_commons.model_access_control import ModelAccessControl
from opensearch_py_ml.ml_commons.model_execute import ModelExecute
from opensearch_py_ml.ml_commons.model_uploader import ModelUploader
from opensearch_py_ml.ml_commons.model_profile import ModelProfile


class MLCommonClient:
Expand All @@ -37,6 +38,7 @@ def __init__(self, os_client: OpenSearch):
self._model_uploader = ModelUploader(os_client)
self._model_execute = ModelExecute(os_client)
self.model_access_control = ModelAccessControl(os_client)
self.profile = ModelProfile(os_client)

def execute(self, algorithm_name: str, input_json: dict) -> dict:
"""
Expand Down
38 changes: 38 additions & 0 deletions opensearch_py_ml/ml_commons/model_profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-License-Identifier: Apache-2.0
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
# Any modifications Copyright OpenSearch Contributors. See
# GitHub history for details.

from opensearchpy import OpenSearch

from opensearch_py_ml.ml_commons.ml_common_utils import ML_BASE_URI


class ModelProfile:
API_ENDPOINT = "profile"

def __init__(self, os_client: OpenSearch):
self.client = os_client

def get_profile(self, payload: dict):
if not isinstance(payload, dict):
raise ValueError("payload needs to be a dictionary")
return self.client.transport.perform_request(
method="GET", url=f"{ML_BASE_URI}/{self.API_ENDPOINT}", body=payload
)

def get_models_profile(self, payload: dict):
if not isinstance(payload, dict):
raise ValueError("payload needs to be a dictionary")
return self.client.transport.perform_request(
method="GET", url=f"{ML_BASE_URI}/{self.API_ENDPOINT}/models", body=payload
)

def get_tasks_profile(self, payload: dict):
if not isinstance(payload, dict):
raise ValueError("payload needs to be a dictionary")
return self.client.transport.perform_request(
method="GET", url=f"{ML_BASE_URI}/{self.API_ENDPOINT}/tasks", body=payload
)

0 comments on commit 6692fe2

Please sign in to comment.