Skip to content

Commit bf35601

Browse files
Add missing tests for ML APIs (search and delete) (opensearch-project#672)
* Add missing tests for ML APIs (search and delete) Signed-off-by: Nathalie Jonathan <[email protected]> * Update schema and CHANGELOG Signed-off-by: Nathalie Jonathan <[email protected]> * Removed comments Signed-off-by: Nathalie Jonathan <[email protected]> * Added missing model states Signed-off-by: Nathalie Jonathan <[email protected]> * Fixed lint errors and modified distributions Signed-off-by: Nathalie Jonathan <[email protected]> * Added refresh and updated response schema Signed-off-by: Nathalie Jonathan <[email protected]> * Modified refresh Signed-off-by: Nathalie Jonathan <[email protected]> * Updated CHANGELOG and modified search model Signed-off-by: Nathalie Jonathan <[email protected]> * Added more missing fields Signed-off-by: Nathalie Jonathan <[email protected]> --------- Signed-off-by: Nathalie Jonathan <[email protected]> Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> Co-authored-by: Daniel (dB.) Doubrovkine <[email protected]>
1 parent 398481e commit bf35601

File tree

4 files changed

+185
-7
lines changed

4 files changed

+185
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
3232
- Removed invalid `required` from `ppl` responses ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646))
3333
- Added schema for security API error responses ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646))
3434
- Fixed `/{index}/_create/{id}` returning `201` ([#669](https://github.com/opensearch-project/opensearch-api-specification/pull/669))
35+
- Fixed `ml._common.yaml#SearchModelsResponse` and `SearchModelsHitsHit` ([#672](https://github.com/opensearch-project/opensearch-api-specification/pull/672))
3536

3637
## [0.1.0] - 2024-10-25
3738

spec/schemas/ml._common.yaml

+142-7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ components:
2222
SearchModelsResponse:
2323
type: object
2424
properties:
25+
took:
26+
type: integer
27+
description: The time taken to execute the search.
28+
timed_out:
29+
type: boolean
30+
description: Whether the search timed out.
31+
_shards:
32+
$ref: '_common.yaml#/components/schemas/ShardStatistics'
2533
hits:
2634
$ref: '#/components/schemas/SearchModelsHits'
2735
required:
@@ -35,6 +43,10 @@ components:
3543
type: array
3644
items:
3745
$ref: '#/components/schemas/SearchModelsHitsHit'
46+
max_score:
47+
type: number
48+
format: float
49+
description: The maximum score.
3850
required:
3951
- hits
4052
- total
@@ -43,6 +55,7 @@ components:
4355
properties:
4456
value:
4557
type: integer
58+
format: int64
4659
description: The total number of hits.
4760
relation:
4861
type: string
@@ -53,18 +66,140 @@ components:
5366
SearchModelsHitsHit:
5467
type: object
5568
properties:
69+
_version:
70+
$ref: '_common.yaml#/components/schemas/VersionNumber'
71+
_seq_no:
72+
$ref: '_common.yaml#/components/schemas/SequenceNumber'
73+
_primary_term:
74+
type: integer
75+
description: The primary term.
5676
_index:
57-
type: string
58-
description: The index.
77+
$ref: '_common.yaml#/components/schemas/IndexName'
5978
_id:
79+
$ref: '_common.yaml#/components/schemas/Id'
80+
_score:
81+
type: number
82+
format: float
83+
description: The score.
84+
_source:
85+
$ref: '#/components/schemas/Source'
86+
model_id:
87+
$ref: '_common.yaml#/components/schemas/Name'
88+
required:
89+
- _score
90+
Source:
91+
type: object
92+
properties:
93+
last_deployed_time:
94+
type: integer
95+
format: int64
96+
description: The last deployed time.
97+
model_version:
6098
type: string
61-
description: The hit ID.
99+
description: The model version.
100+
version:
101+
$ref: '_common.yaml#/components/schemas/VersionString'
102+
created_time:
103+
type: integer
104+
format: int64
105+
description: The created time.
106+
chunk_number:
107+
type: integer
108+
format: int64
109+
description: The chunk number.
110+
deploy_to_all_nodes:
111+
type: boolean
112+
description: Whether to deploy to all nodes.
113+
is_hidden:
114+
type: boolean
115+
description: Whether the model is hidden.
62116
model_id:
117+
$ref: '_common.yaml#/components/schemas/Name'
118+
description:
63119
type: string
64-
description: The model ID.
65-
required:
66-
- _id
67-
- model_id
120+
description: The model description.
121+
model_state:
122+
type: string
123+
description: The model state.
124+
enum:
125+
- DEPLOYED
126+
- DEPLOYING
127+
- DEPLOY_FAILED
128+
- PARTIALLY_DEPLOYED
129+
- REGISTERED
130+
- REGISTERING
131+
model_content_size_in_bytes:
132+
type: integer
133+
format: int64
134+
description: The model content size in bytes.
135+
model_content_hash_value:
136+
type: string
137+
description: The model content hash value.
138+
planning_worker_node_count:
139+
type: number
140+
description: The planning worker node count.
141+
model_config:
142+
$ref: '#/components/schemas/ModelConfig'
143+
model_format:
144+
type: string
145+
description: The model format.
146+
model_task_type:
147+
type: string
148+
description: The model task type.
149+
last_updated_time:
150+
type: integer
151+
format: int64
152+
description: The last updated time.
153+
last_registered_time:
154+
type: integer
155+
format: int64
156+
description: The last registered time.
157+
auto_redeploy_retry_times:
158+
type: integer
159+
format: int64
160+
description: The auto redeploy retry times.
161+
name:
162+
type: string
163+
description: The model name.
164+
connector_id:
165+
type: string
166+
description: The connector ID.
167+
current_worker_node_count:
168+
type: number
169+
description: The current worker node count.
170+
model_group_id:
171+
type: string
172+
description: The model group ID.
173+
planning_worker_nodes:
174+
type: array
175+
items:
176+
$ref: '_common.yaml#/components/schemas/NodeIds'
177+
total_chunks:
178+
type: integer
179+
format: int64
180+
description: The total chunks.
181+
algorithm:
182+
type: string
183+
description: The algorithm.
184+
url:
185+
type: string
186+
description: The model URL.
187+
ModelConfig:
188+
type: object
189+
properties:
190+
all_config:
191+
type: string
192+
description: The all config.
193+
model_type:
194+
type: string
195+
description: The model type.
196+
embedding_dimension:
197+
type: integer
198+
format: int64
199+
description: The embedding dimension.
200+
framework_type:
201+
type: string
202+
description: The framework type.
68203
ModelGroupRegistration:
69204
type: object
70205
properties:

tests/plugins/ml/ml/models.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ chapters:
3737
retry:
3838
count: 5
3939
wait: 30000
40+
- synopsis: Search model.
41+
path: /_plugins/_ml/models/_search
42+
method: GET
43+
request:
44+
payload:
45+
query:
46+
match_all: {}
47+
size: 1000
48+
response:
49+
status: 200
50+
payload:
51+
hits:
52+
hits:
53+
- _score: 1
4054
- synopsis: Delete model.
4155
path: /_plugins/_ml/models/{model_id}
4256
parameters:

tests/plugins/ml/ml/tasks.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
$schema: ../../../../json_schemas/test_story.schema.yaml
2+
3+
description: Test the creation of tasks.
4+
version: '>= 2.11'
5+
warnings:
6+
multiple-paths-detected: false
7+
chapters:
8+
- synopsis: Register model.
9+
id: register_model
10+
path: /_plugins/_ml/models/_register
11+
method: POST
12+
request:
13+
payload:
14+
name: huggingface/sentence-transformers/msmarco-distilbert-base-tas-b
15+
version: 1.0.1
16+
model_format: TORCH_SCRIPT
17+
response:
18+
status: 200
19+
output:
20+
task_id: payload.task_id
21+
- synopsis: Delete task.
22+
id: delete_task
23+
path: /_plugins/_ml/tasks/{task_id}
24+
method: DELETE
25+
parameters:
26+
task_id: ${register_model.task_id}
27+
response:
28+
status: 200

0 commit comments

Comments
 (0)