Skip to content

Commit

Permalink
Fixed lint errors in predict.yaml, moved setup to prologues and teard…
Browse files Browse the repository at this point in the history
…own to epilogues in predict.yaml and load.yaml, updated CHANGELOG format, updated API description, 'model_group_id' ID type, 'version' parameter, and made 'model_format' a type of its own in ml.yaml.

Signed-off-by: Nathalie Jonathan <[email protected]>
  • Loading branch information
nathaliellenaa committed Dec 19, 2024
1 parent c29b8d3 commit 789ab69
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 89 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added response schema for `GET /_plugins/_knn/warmup/{index}` ([#717](https://github.com/opensearch-project/opensearch-api-specification/pull/717))
- Added support for multiple test verbs ([#724](https://github.com/opensearch-project/opensearch-api-specification/pull/724))
- Added support for using a certificate and key in tests ([#731](https://github.com/opensearch-project/opensearch-api-specification/pull/731))
- Added `GET /_plugins/_ml/models/{model_id}`, `POST /_plugins/_ml/models/_search`, `PUT /_plugins/_ml/models/{model_id}`, `POST /_plugins/_ml/models/{model_id}/_unload`, `POST /_plugins/_ml/models/_unload`, `POST /_plugins/_ml/models/_undeploy`, `POST /_plugins/_ml/models/_upload`,`POST /_plugins/_ml/models/{model_id}/_load`, `POST /_plugins/_ml/models/meta`, and `POST /_plugins/_ml/models/{model_id}/_predict` ([#733](https://github.com/opensearch-project/opensearch-api-specification/pull/733))
- Added `_type` to `termvector` and `mtermvector` ([#734](https://github.com/opensearch-project/opensearch-api-specification/pull/734))
- Added missing `cancelled` and `resource_stats` to `/_reindex/{task_id}/_rethrottle` ([#740](https://github.com/opensearch-project/opensearch-api-specification/pull/740))
- Added missing `cancellation_time_millis` to `POST /_tasks/_cancel` ([#747](https://github.com/opensearch-project/opensearch-api-specification/pull/747))
- Added support for combining output variables ([#737](https://github.com/opensearch-project/opensearch-api-specification/pull/737))
- Added 404 response to `/_search/scroll` ([#749](https://github.com/opensearch-project/opensearch-api-specification/pull/749))
- Added `node_failures` to `DELETE /_search/scroll` and `DELETE /_search/scroll/{scroll_id}` ([#749](https://github.com/opensearch-project/opensearch-api-specification/pull/749))
- Added `GET /_plugins/_ml/models/{model_id}`, `POST /_plugins/_ml/models/_search`, `POST /_plugins/_ml/models/_unload`, `_undeploy`, `_upload`, `meta`, `POST /_plugins/_ml/models/{model_id}/_load`, `_predict`, `_unload`, and `PUT /_plugins/_ml/models/{model_id}` ([#733](https://github.com/opensearch-project/opensearch-api-specification/pull/733))

### 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
34 changes: 11 additions & 23 deletions spec/namespaces/ml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ paths:
post:
operationId: ml.create_model_meta.0
x-operation-group: ml.create_model_meta
description: Creates a model metadata.
description: Creates model metadata.
requestBody:
$ref: '#/components/requestBodies/ml.create_model_meta'
responses:
Expand Down Expand Up @@ -297,18 +297,14 @@ components:
type: string
description: The model name.
version:
type: string
description: The model version.
$ref: '../schemas/_common.yaml#/components/schemas/VersionString'
model_format:
type: string
description: The portable format of the model file.
enum: [ONNX, TORCH_SCRIPT]
$ref: '../schemas/_common.yaml#/components/schemas/ModelFormat'
description:
type: string
description: The model description.
model_group_id:
type: string
description: The ID of the model group to which to register the model.
$ref: '../schemas/_common.yaml#/components/schemas/Id'
required:
- name
- version
Expand All @@ -322,15 +318,11 @@ components:
type: string
description: The model name.
version:
type: string
description: The model version.
$ref: '../schemas/_common.yaml#/components/schemas/VersionString'
model_format:
type: string
description: The portable format of the model file.
enum: [ONNX, TORCH_SCRIPT]
$ref: '../schemas/_common.yaml#/components/schemas/ModelFormat'
model_group_id:
type: string
description: The ID of the model group to which to register the model.
$ref: '../schemas/_common.yaml#/components/schemas/Id'
model_content_hash_value:
type: string
description: The model content hash value.
Expand All @@ -339,7 +331,7 @@ components:
total_chunks:
type: integer
format: int64
description: The total chunks.
description: Number of chunks the model is split into.
url:
type: string
description: The model URL.
Expand All @@ -363,18 +355,14 @@ components:
type: string
description: The model name.
version:
type: string
description: The model version.
$ref: '../schemas/_common.yaml#/components/schemas/VersionString'
model_format:
type: string
description: The portable format of the model file.
enum: [ONNX, TORCH_SCRIPT]
$ref: '../schemas/_common.yaml#/components/schemas/ModelFormat'
description:
type: string
description: The model description.
model_group_id:
type: string
description: The ID of the model group to which to register the model.
$ref: '../schemas/_common.yaml#/components/schemas/Id'
required:
- name
- version
Expand Down
7 changes: 6 additions & 1 deletion spec/schemas/_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2380,4 +2380,9 @@ components:
type: number
required:
- active_threads
- thread_executions
- thread_executions
ModelFormat:
type: string
enum:
- ONNX
- TORCH_SCRIPT
9 changes: 2 additions & 7 deletions spec/schemas/ml._common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ components:
model_config:
$ref: '#/components/schemas/ModelConfig'
model_format:
type: string
description: The model format.
$ref: '_common.yaml#/components/schemas/ModelFormat'
model_task_type:
type: string
description: The model task type.
Expand Down Expand Up @@ -242,11 +241,7 @@ components:
type: string
description: The model version.
model_format:
type: string
description: The model format.
enum:
- ONNX
- TORCH_SCRIPT
$ref: '_common.yaml#/components/schemas/ModelFormat'
model_state:
type: string
description: The model state.
Expand Down
37 changes: 14 additions & 23 deletions tests/plugins/ml/models/load.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ prologues:
model_format: TORCH_SCRIPT
output:
task_id: payload.task_id
- path: /_plugins/_ml/tasks/{task_id}
id: get_completed_register_model_task
method: GET
parameters:
task_id: ${register_model.task_id}
retry:
count: 3
wait: 10000
until:
- path: payload.state
equal: COMPLETED
output:
model_id: payload.model_id
epilogues:
- path: /_plugins/_ml/models/{model_id}/_undeploy
method: POST
Expand All @@ -30,21 +43,6 @@ epilogues:
method: DELETE
status: [200, 404]
chapters:
- synopsis: Wait to get completed task.
id: get_completed_register_model_task
path: /_plugins/_ml/tasks/{task_id}
method: GET
parameters:
task_id: ${register_model.task_id}
response:
status: 200
payload:
state: COMPLETED
output:
model_id: payload.model_id
retry:
count: 3
wait: 10000
- synopsis: Deploy a model.
id: load_model
path: /_plugins/_ml/models/{model_id}/_load
Expand All @@ -69,11 +67,4 @@ chapters:
model_id: payload.model_id
retry:
count: 3
wait: 10000
- synopsis: Undeploy a model.
path: /_plugins/_ml/models/{model_id}/_undeploy
method: POST
parameters:
model_id: ${get_completed_register_model_task.model_id}
response:
status: 200
wait: 10000
56 changes: 22 additions & 34 deletions tests/plugins/ml/models/predict.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ prologues:
model_format: TORCH_SCRIPT
output:
task_id: payload.task_id
- path: /_plugins/_ml/tasks/{task_id}
id: get_completed_register_model_task
method: GET
parameters:
task_id: ${register_model.task_id}
retry:
count: 3
wait: 10000
until:
- path: payload.state
equal: COMPLETED
output:
model_id: payload.model_id
- path: /_plugins/_ml/models/{model_id}/_deploy
id: deploy_model
method: POST
parameters:
model_id: ${get_completed_register_model_task.model_id}
output:
task_id: payload.task_id
epilogues:
- path: /_plugins/_ml/models/{model_id}/_undeploy
method: POST
Expand All @@ -52,31 +72,6 @@ epilogues:
parameters:
model_group_id: ${create_model_group.test_model_group_id}
chapters:
- synopsis: Wait to get completed task.
id: get_completed_register_model_task
path: /_plugins/_ml/tasks/{task_id}
method: GET
parameters:
task_id: ${register_model.task_id}
response:
status: 200
payload:
state: COMPLETED
output:
model_id: payload.model_id
retry:
count: 3
wait: 10000
- synopsis: Deploy a model.
id: deploy_model
path: /_plugins/_ml/models/{model_id}/_deploy
method: POST
parameters:
model_id: ${get_completed_register_model_task.model_id}
output:
task_id: payload.task_id
response:
status: 200
- synopsis: Wait to get completed task.
id: get_completed_deploy_model_task
path: /_plugins/_ml/tasks/{task_id}
Expand Down Expand Up @@ -111,14 +106,7 @@ chapters:
payload:
inference_results:
- output:
- data:
- 101
- data:
- 101
output:
prediction_results: payload.inference_results[0].output[0].data
- synopsis: Undeploy a model.
path: /_plugins/_ml/models/{model_id}/_undeploy
method: POST
parameters:
model_id: ${get_completed_register_model_task.model_id}
response:
status: 200

0 comments on commit 789ab69

Please sign in to comment.