Skip to content

Commit

Permalink
first commit for ml common integration
Browse files Browse the repository at this point in the history
  • Loading branch information
LEFTA98 committed Aug 11, 2022
1 parent e4881d8 commit 410ad0e
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 0 deletions.
7 changes: 7 additions & 0 deletions opensearch_py_ml/ml_commons_integration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
Copyright OpenSearch Contributors
SPDX-License-Identifier: Apache-2.0
"""
from ml_common_client import MLCommonClient

__all__ = ["MLCommonClient"]
4 changes: 4 additions & 0 deletions opensearch_py_ml/ml_commons_integration/load/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""
Copyright OpenSearch Contributors
SPDX-License-Identifier: Apache-2.0
"""
21 changes: 21 additions & 0 deletions opensearch_py_ml/ml_commons_integration/ml_common_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
Copyright OpenSearch Contributors
SPDX-License-Identifier: Apache-2.0
"""

from opensearchpy import OpenSearch
from upload.ml_common_upload_client import MLCommonUploadClient, DEFAULT_ML_COMMON_UPLOAD_CHUNK_SIZE


class MLCommonClient:
"""
A client that communicates to the ml-common plugin for OpenSearch. This client allows for uploading of trained
machine learning models to an OpenSearch index.
"""

def __init__(self, os_client: OpenSearch):
self._client = os_client
self._upload_client = MLCommonUploadClient(os_client)

def put_model(self, model_path: str, chunk_size: int = DEFAULT_ML_COMMON_UPLOAD_CHUNK_SIZE):
self._upload_client.put_model(model_path, chunk_size)
4 changes: 4 additions & 0 deletions opensearch_py_ml/ml_commons_integration/predict/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""
Copyright OpenSearch Contributors
SPDX-License-Identifier: Apache-2.0
"""
4 changes: 4 additions & 0 deletions opensearch_py_ml/ml_commons_integration/upload/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""
Copyright OpenSearch Contributors
SPDX-License-Identifier: Apache-2.0
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
Copyright OpenSearch Contributors
SPDX-License-Identifier: Apache-2.0
"""

DEFAULT_ML_COMMON_UPLOAD_CHUNK_SIZE = 4 * 1024 * 1024

from opensearchpy import OpenSearch

class MLCommonUploadClient:
"""
Client for performing model upload tasks to ml-commons plugin for OpenSearch.
"""
def __init__(self, os_client: OpenSearch):
self._client = os_client

def put_model(self, model_path: str, chunk_size: int = DEFAULT_ML_COMMON_UPLOAD_CHUNK_SIZE):
pass

0 comments on commit 410ad0e

Please sign in to comment.