diff --git a/opensearch_py_ml/ml_commons/ml_commons_client.py b/opensearch_py_ml/ml_commons/ml_commons_client.py index 72e2e158b..a50a7d4bb 100644 --- a/opensearch_py_ml/ml_commons/ml_commons_client.py +++ b/opensearch_py_ml/ml_commons/ml_commons_client.py @@ -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: @@ -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: """ diff --git a/opensearch_py_ml/ml_commons/model_profile.py b/opensearch_py_ml/ml_commons/model_profile.py new file mode 100644 index 000000000..ae0fc770d --- /dev/null +++ b/opensearch_py_ml/ml_commons/model_profile.py @@ -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 + ) \ No newline at end of file