From 789ab69f863de6234772913882c368095f536803 Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan Date: Thu, 19 Dec 2024 13:26:15 -0800 Subject: [PATCH] Fixed lint errors in predict.yaml, moved setup to prologues and teardown 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 --- CHANGELOG.md | 4 +- spec/namespaces/ml.yaml | 34 ++++++----------- spec/schemas/_common.yaml | 7 +++- spec/schemas/ml._common.yaml | 9 +---- tests/plugins/ml/models/load.yaml | 37 +++++++----------- tests/plugins/ml/models/predict.yaml | 56 +++++++++++----------------- 6 files changed, 58 insertions(+), 89 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff37c55b..0d1ec8ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/spec/namespaces/ml.yaml b/spec/namespaces/ml.yaml index ec8790a6..6304c893 100644 --- a/spec/namespaces/ml.yaml +++ b/spec/namespaces/ml.yaml @@ -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: @@ -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 @@ -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. @@ -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. @@ -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 diff --git a/spec/schemas/_common.yaml b/spec/schemas/_common.yaml index f5ab3b89..7057e173 100644 --- a/spec/schemas/_common.yaml +++ b/spec/schemas/_common.yaml @@ -2380,4 +2380,9 @@ components: type: number required: - active_threads - - thread_executions \ No newline at end of file + - thread_executions + ModelFormat: + type: string + enum: + - ONNX + - TORCH_SCRIPT \ No newline at end of file diff --git a/spec/schemas/ml._common.yaml b/spec/schemas/ml._common.yaml index faa0da0c..08a78180 100644 --- a/spec/schemas/ml._common.yaml +++ b/spec/schemas/ml._common.yaml @@ -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. @@ -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. diff --git a/tests/plugins/ml/models/load.yaml b/tests/plugins/ml/models/load.yaml index c560e906..8f2b69b8 100644 --- a/tests/plugins/ml/models/load.yaml +++ b/tests/plugins/ml/models/load.yaml @@ -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 @@ -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 @@ -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 diff --git a/tests/plugins/ml/models/predict.yaml b/tests/plugins/ml/models/predict.yaml index d42080f7..f2674e0c 100644 --- a/tests/plugins/ml/models/predict.yaml +++ b/tests/plugins/ml/models/predict.yaml @@ -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 @@ -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} @@ -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 \ No newline at end of file