forked from opensearch-project/opensearch-py-ml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: kalyan <[email protected]>
- Loading branch information
Showing
4 changed files
with
134 additions
and
8 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
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
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
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,28 @@ | ||
from opensearchpy import OpenSearch | ||
from opensearchpy.exceptions import RequestError | ||
from .common import OPENSEARCH_TEST_CLIENT, MODEL_GROUP_PREFIX | ||
import time | ||
|
||
|
||
|
||
|
||
def delete_test_model_groups(os: OpenSearch): | ||
model_group_query = {"query": {"match_phrase_prefix": {"name": MODEL_GROUP_PREFIX}}} | ||
|
||
try: | ||
result = os.transport.perform_request( | ||
method="GET", url="/_plugins/_ml/model_groups/_search", body=model_group_query | ||
) | ||
|
||
for each in result["hits"]["hits"]: | ||
try: | ||
os.transport.perform_request( | ||
method="DELETE", url=f"/_plugins/_ml/model_groups/{each['_id']}" | ||
) | ||
time.sleep(0.2) | ||
except Exception as ex: | ||
print(f"Failed to delete model group id: {each['_id']}") | ||
except RequestError as ex: | ||
print(f"Failed due to request error: {ex}") | ||
except Exception as ex: | ||
print(f"Unexpected Model group deletion failure due to: {ex}") |