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

Add missing tests for ML APIs (search and delete) #672

Merged
merged 10 commits into from
Nov 16, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added `/_cluster/stats/{metric}/nodes/{node_id}` and `/_cluster/stats/{metric}/{index_metric}/nodes/{node_id}` ([#639](https://github.com/opensearch-project/opensearch-api-specification/pull/639))
- Added `PhoneAnalyzer` from `analysis-phonenumber` plugin ([#609](https://github.com/opensearch-project/opensearch-api-specification/pull/609))
- Added `/_list/indices` & `/_list/shards` api specs ([#613](https://github.com/opensearch-project/opensearch-api-specification/pull/613))
- Added `GET /_plugins/_ml/models/_search` and `DELETE /_plugins/_ml/tasks/{task_id}` ([#672](https://github.com/opensearch-project/opensearch-api-specification/pull/672))
nathaliellenaa marked this conversation as resolved.
Show resolved Hide resolved

### Removed
- Removed unsupported `_common.mapping:SourceField`'s `mode` field and associated `_common.mapping:SourceFieldMode` enum ([#652](https://github.com/opensearch-project/opensearch-api-specification/pull/652))
Expand Down
119 changes: 111 additions & 8 deletions spec/schemas/ml._common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
SearchModelsResponse:
type: object
properties:
took:
type: integer
description: The time taken to execute the search.
timed_out:
type: boolean
description: Whether the search timed out.
_shards:
$ref: '_common.yaml#/components/schemas/ShardStatistics'
hits:
$ref: '#/components/schemas/SearchModelsHits'
required:
Expand All @@ -35,6 +43,10 @@
type: array
items:
$ref: '#/components/schemas/SearchModelsHitsHit'
max_score:
dblock marked this conversation as resolved.
Show resolved Hide resolved
type: number
format: float
description: The maximum score.
required:
- hits
- total
Expand All @@ -43,6 +55,7 @@
properties:
value:
type: integer
format: int64
description: The total number of hits.
relation:
type: string
Expand All @@ -53,18 +66,108 @@
SearchModelsHitsHit:
type: object
properties:
_version:
nathaliellenaa marked this conversation as resolved.
Show resolved Hide resolved
$ref: '_common.yaml#/components/schemas/VersionNumber'
_seq_no:
$ref: '_common.yaml#/components/schemas/SequenceNumber'
_primary_term:
type: integer
description: The primary term.
_index:
type: string
description: The index.
$ref: '_common.yaml#/components/schemas/IndexName'
_id:
type: string
description: The hit ID.
$ref: '_common.yaml#/components/schemas/Id'
_score:
type: number
format: float
description: The score.
_source:
$ref: '#/components/schemas/Source'
model_id:
type: string
description: The model ID.
$ref: '_common.yaml#/components/schemas/Name'
required:
- _id
- model_id
- _score
Source:
type: object
properties:
last_deployed_time:
type: integer
format: int64
description: The last deployed time.
model_version:
type: string
description: The model version.
created_time:
dblock marked this conversation as resolved.
Show resolved Hide resolved
type: integer
format: int64
description: The created time.
deploy_to_all_nodes:
type: boolean
description: Whether to deploy to all nodes.
is_hidden:
type: boolean
description: Whether the model is hidden.
description:
type: string
description: The model description.
model_state:
dblock marked this conversation as resolved.
Show resolved Hide resolved
type: string
description: The model state.
enum:
- REGISTERING
- REGISTERED

Check failure on line 118 in spec/schemas/ml._common.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected sequence values to be in ascending order. 'REGISTERED' should be before 'REGISTERING'
- DEPLOYING

Check failure on line 119 in spec/schemas/ml._common.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected sequence values to be in ascending order. 'DEPLOYING' should be before 'REGISTERED'
- DEPLOYED

Check failure on line 120 in spec/schemas/ml._common.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected sequence values to be in ascending order. 'DEPLOYED' should be before 'DEPLOYING'
- PARTIALLY_DEPLOYED
- UNDEPLOYED

Check failure on line 122 in spec/schemas/ml._common.yaml

View workflow job for this annotation

GitHub Actions / lint

Unknown word: "UNDEPLOYED"
- DEPLOY_FAILED

Check failure on line 123 in spec/schemas/ml._common.yaml

View workflow job for this annotation

GitHub Actions / lint

Expected sequence values to be in ascending order. 'DEPLOY_FAILED' should be before 'UNDEPLOYED'
planning_worker_node_count:
type: number
description: The planning worker node count.
model_config:
$ref: '#/components/schemas/ModelConfig'
model_format:
type: string
description: The model format.
last_updated_time:
dblock marked this conversation as resolved.
Show resolved Hide resolved
type: integer
format: int64
description: The last updated time.
name:
type: string
description: The model name.
connector_id:
type: string
description: The connector ID.
current_worker_node_count:
type: number
description: The current worker node count.
model_group_id:
type: string
description: The model group ID.
planning_worker_nodes:
type: array
items:
$ref: '_common.yaml#/components/schemas/NodeIds'
algorithm:
type: string
description: The algorithm.
ModelConfig:
type: object
properties:
all_config:
type: string
description: The all config.
model_type:
type: string
description: The model type.
embedding_dimension:
type: integer
format: int64
description: The embedding dimension.
framework_type:
type: string
description: The framework type.
ModelGroupRegistration:
type: object
properties:
Expand Down
17 changes: 17 additions & 0 deletions tests/plugins/ml/ml/models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ chapters:
status: 200
output:
task_id: payload.task_id
- synopsis: Search model.
id: search_model
nathaliellenaa marked this conversation as resolved.
Show resolved Hide resolved
path: /_plugins/_ml/models/_search
method: GET
request:
payload:
query:
match_all: {}
size: 1000
response:
status: 200
payload:
hits:
hits:
- _score: 1
output:
search_id: payload.hits.hits[0]._id
- synopsis: Wait to get completed task.
id: get_completed_task
path: /_plugins/_ml/tasks/{task_id}
Expand Down
32 changes: 32 additions & 0 deletions tests/plugins/ml/ml/tasks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test the creation of tasks.
distributions:
excluded:
- amazon-managed
- amazon-serverless
nathaliellenaa marked this conversation as resolved.
Show resolved Hide resolved
version: '>= 2.11'
warnings:
multiple-paths-detected: false
chapters:
- synopsis: Register model.
id: register_model
path: /_plugins/_ml/models/_register
method: POST
request:
payload:
name: huggingface/sentence-transformers/msmarco-distilbert-base-tas-b
version: 1.0.1
model_format: TORCH_SCRIPT
response:
status: 200
output:
task_id: payload.task_id
- synopsis: Delete task.
id: delete_task
path: /_plugins/_ml/tasks/{task_id}
method: DELETE
parameters:
task_id: ${register_model.task_id}
response:
status: 200
Loading