Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: refactor validators in ml_commons client #385

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- use try-except-else block for handling unexpected exceptions during integration tests by @rawwar([#370](https://github.com/opensearch-project/opensearch-py-ml/pull/370))
- Removed pandas version pin in nox tests by @rawwar ([#368](https://github.com/opensearch-project/opensearch-py-ml/pull/368))
- Switch AL2 to AL2023 agent and DockerHub to ECR images in ml-models.JenkinsFile ([#377](https://github.com/opensearch-project/opensearch-py-ml/pull/377))
- Refactored validators in ML Commons' client([#385](https://github.com/opensearch-project/opensearch-py-ml/pull/385))

### Fixed
- Enable make_model_config_json to add model description to model config file by @thanawan-atc in ([#203](https://github.com/opensearch-project/opensearch-py-ml/pull/203))
Expand Down
2 changes: 1 addition & 1 deletion opensearch_py_ml/ml_commons/ml_commons_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from opensearch_py_ml.ml_commons.model_connector import Connector
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.validators.profile import validate_profile_input
from opensearch_py_ml.ml_commons.validators import validate_profile_input


class MLCommonClient:
Expand Down
2 changes: 1 addition & 1 deletion opensearch_py_ml/ml_commons/model_access_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from opensearchpy.exceptions import NotFoundError

from opensearch_py_ml.ml_commons.ml_common_utils import ML_BASE_URI
from opensearch_py_ml.ml_commons.validators.model_access_control import (
from opensearch_py_ml.ml_commons.validators import (
validate_create_model_group_parameters,
validate_delete_model_group_parameters,
validate_search_model_group_parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,11 @@ def validate_delete_model_group_parameters(model_group_id: str):

def validate_search_model_group_parameters(query: dict):
_validate_model_group_query(query)


def validate_profile_input(path_parameter, payload):
if path_parameter is not None and not isinstance(path_parameter, str):
raise ValueError("path_parameter needs to be a string or None")

if payload is not None and not isinstance(payload, dict):
raise ValueError("payload needs to be a dictionary or None")
6 changes: 0 additions & 6 deletions opensearch_py_ml/ml_commons/validators/__init__.py

This file was deleted.

16 changes: 0 additions & 16 deletions opensearch_py_ml/ml_commons/validators/profile.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest

from opensearch_py_ml.ml_commons.validators.model_access_control import (
from opensearch_py_ml.ml_commons.validators import (
_validate_model_group_access_mode,
_validate_model_group_add_all_backend_roles,
_validate_model_group_backend_roles,
Expand Down
2 changes: 1 addition & 1 deletion tests/ml_models/test_sentencetransformermodel_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def test_overwrite_description():
def test_long_description():
model_id = "sentence-transformers/gtr-t5-base"
model_format = "TORCH_SCRIPT"
expected_model_description = "This is a sentence-transformers model: It maps sentences & paragraphs to a 768 dimensional dense vector space. The model was specifically trained for the task of sematic search."
expected_model_description = "This is a sentence-transformers model: It maps sentences & paragraphs to a 768 dimensional dense vector space. The model was specifically trained for the task of semantic search."

clean_test_folder(TEST_FOLDER)
test_model12 = SentenceTransformerModel(
Expand Down
Loading