-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first commit for ml common integration
- Loading branch information
Showing
6 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
21
opensearch_py_ml/ml_commons_integration/ml_common_client.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
""" | ||
Copyright OpenSearch Contributors | ||
SPDX-License-Identifier: Apache-2.0 | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
""" | ||
Copyright OpenSearch Contributors | ||
SPDX-License-Identifier: Apache-2.0 | ||
""" |
18 changes: 18 additions & 0 deletions
18
opensearch_py_ml/ml_commons_integration/upload/ml_common_upload_client.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |