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

Fixed an error in DeleleMlModel runner. #537

Merged
merged 14 commits into from
Jul 1, 2024
Merged
Changes from 9 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
16 changes: 14 additions & 2 deletions osbenchmark/worker_coordinator/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2400,6 +2400,11 @@ def __repr__(self, *args, **kwargs):
class DeleteMlModel(Runner):
@time_func
async def __call__(self, opensearch, params):
async def _is_deployed(model_id):
resp = await opensearch.transport.perform_request('GET', '_plugins/_ml/models/' + model_id)
state = resp.get('model_state')
return state in ('PARTIALLY_DEPLOYED', 'DEPLOYED')

body= {
"query": {
"match_phrase": {
Expand All @@ -2422,8 +2427,15 @@ async def __call__(self, opensearch, params):
model_ids.add(id)

for model_id in model_ids:
resp=await opensearch.transport.perform_request('POST', '/_plugins/_ml/models/' + model_id + '/_undeploy')
resp=await opensearch.transport.perform_request('DELETE', '/_plugins/_ml/models/' + model_id)
deployed = await _is_deployed(model_id)
if deployed:
vpehkone marked this conversation as resolved.
Show resolved Hide resolved
await opensearch.transport.perform_request('POST', '/_plugins/_ml/models/' + model_id + '/_undeploy')
while deployed:
vpehkone marked this conversation as resolved.
Show resolved Hide resolved
time.sleep(1)
resp = await opensearch.transport.perform_request('GET', '_plugins/_ml/models/' + model_id)
deployed = await _is_deployed(model_id)

await opensearch.transport.perform_request('DELETE', '/_plugins/_ml/models/' + model_id)

def __repr__(self, *args, **kwargs):
return "delete-ml-model"
Expand Down
Loading