From f5f1213272765720c0e1af575741bd3480d05ced Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan Date: Wed, 13 Nov 2024 17:05:24 -0800 Subject: [PATCH 1/9] Add missing tests for ML APIs (search and delete) Signed-off-by: Nathalie Jonathan --- spec/schemas/ml._common.yaml | 111 +++++++++++++++++++++++++++++--- tests/plugins/ml/ml/models.yaml | 17 +++++ tests/plugins/ml/ml/tasks.yaml | 32 +++++++++ 3 files changed, 151 insertions(+), 9 deletions(-) create mode 100644 tests/plugins/ml/ml/tasks.yaml diff --git a/spec/schemas/ml._common.yaml b/spec/schemas/ml._common.yaml index 46cffc9f3..b142e40ff 100644 --- a/spec/schemas/ml._common.yaml +++ b/spec/schemas/ml._common.yaml @@ -19,13 +19,48 @@ components: required: - query - size + BaseResponse: + type: object + properties: + _version: + type: integer + description: The version. + _seq_no: + type: integer + description: The sequence number. + _primary_term: + type: integer + description: The primary term. 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: '#/components/schemas/SearchModelsShardsResponse' hits: $ref: '#/components/schemas/SearchModelsHits' required: - hits + SearchModelsShardsResponse: + type: object + properties: + total: + type: integer + description: The total number of shards. + successful: + type: integer + description: The number of successful shards. + skipped: + type: integer + description: The number of skipped shards. + failed: + type: integer + description: The number of failed shards. SearchModelsHits: type: object properties: @@ -35,6 +70,9 @@ components: type: array items: $ref: '#/components/schemas/SearchModelsHitsHit' + max_score: + type: number + description: The maximum score. required: - hits - total @@ -51,20 +89,75 @@ components: - relation - value SearchModelsHitsHit: + allOf: + - $ref: '#/components/schemas/BaseResponse' + - type: object + properties: + _index: + type: string + description: The index. + _id: + type: string + description: The hit ID. + _score: + type: number + description: The score. + _source: + $ref: '#/components/schemas/Source' + model_id: + type: string + description: The model ID. + required: + - _score + Source: type: object properties: - _index: + last_deployed_time: + type: number + description: The last deployed time. + model_version: type: string - description: The index. - _id: + description: The model version. + created_time: + type: number + 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 hit ID. - model_id: + description: The model description. + model_state: type: string - description: The model ID. - required: - - _id - - model_id + description: The model state. + planning_worker_node_count: + type: number + description: The planning worker node count. + last_updated_time: + type: number + 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. ModelGroupRegistration: type: object properties: diff --git a/tests/plugins/ml/ml/models.yaml b/tests/plugins/ml/ml/models.yaml index ce087654f..a8b8fc30d 100644 --- a/tests/plugins/ml/ml/models.yaml +++ b/tests/plugins/ml/ml/models.yaml @@ -22,6 +22,23 @@ chapters: status: 200 output: task_id: payload.task_id + - synopsis: Search model. + id: search_model + 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} diff --git a/tests/plugins/ml/ml/tasks.yaml b/tests/plugins/ml/ml/tasks.yaml new file mode 100644 index 000000000..7a1720493 --- /dev/null +++ b/tests/plugins/ml/ml/tasks.yaml @@ -0,0 +1,32 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test the creation of tasks. +distributions: + excluded: + - amazon-managed + - amazon-serverless +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 \ No newline at end of file From aebb25dacb49768575050d78cb39889502bcbc7c Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan Date: Thu, 14 Nov 2024 12:54:21 -0800 Subject: [PATCH 2/9] Update schema and CHANGELOG Signed-off-by: Nathalie Jonathan --- CHANGELOG.md | 1 + spec/schemas/ml._common.yaml | 127 +++++++++++++++++++++-------------- 2 files changed, 77 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b912b2fe..b75fd5605 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -136,6 +136,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added a spec style checker [#620](https://github.com/opensearch-project/opensearch-api-specification/pull/620). - Added `remote_store` to node `Stats` ([#643](https://github.com/opensearch-project/opensearch-api-specification/pull/643)) - 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 `GET /_plugins/_ml/models/_search` and `DELETE /_plugins/_ml/tasks/{task_id}` ([#672] (https://github.com/opensearch-project/opensearch-api-specification/pull/672)) ### Changed diff --git a/spec/schemas/ml._common.yaml b/spec/schemas/ml._common.yaml index b142e40ff..4d6291612 100644 --- a/spec/schemas/ml._common.yaml +++ b/spec/schemas/ml._common.yaml @@ -19,18 +19,6 @@ components: required: - query - size - BaseResponse: - type: object - properties: - _version: - type: integer - description: The version. - _seq_no: - type: integer - description: The sequence number. - _primary_term: - type: integer - description: The primary term. SearchModelsResponse: type: object properties: @@ -41,26 +29,31 @@ components: type: boolean description: Whether the search timed out. _shards: - $ref: '#/components/schemas/SearchModelsShardsResponse' + # $ref: '#/components/schemas/SearchModelsShardsResponse' + $ref: '_common.yaml#/components/schemas/ShardStatistics' hits: $ref: '#/components/schemas/SearchModelsHits' required: - hits - SearchModelsShardsResponse: - type: object - properties: - total: - type: integer - description: The total number of shards. - successful: - type: integer - description: The number of successful shards. - skipped: - type: integer - description: The number of skipped shards. - failed: - type: integer - description: The number of failed shards. + # SearchModelsShardsResponse: + # type: object + # properties: + # total: + # type: integer + # format: int64 + # description: The total number of shards. + # successful: + # type: integer + # format: int64 + # description: The number of successful shards. + # skipped: + # type: integer + # format: int64 + # description: The number of skipped shards. + # failed: + # type: integer + # format: int64 + # description: The number of failed shards. SearchModelsHits: type: object properties: @@ -72,6 +65,7 @@ components: $ref: '#/components/schemas/SearchModelsHitsHit' max_score: type: number + format: float description: The maximum score. required: - hits @@ -81,6 +75,7 @@ components: properties: value: type: integer + format: int64 description: The total number of hits. relation: type: string @@ -89,37 +84,42 @@ components: - relation - value SearchModelsHitsHit: - allOf: - - $ref: '#/components/schemas/BaseResponse' - - type: object - properties: - _index: - type: string - description: The index. - _id: - type: string - description: The hit ID. - _score: - type: number - description: The score. - _source: - $ref: '#/components/schemas/Source' - model_id: - type: string - description: The model ID. - required: - - _score + type: object + properties: + _version: + $ref: '_common.yaml#/components/schemas/VersionNumber' + _seq_no: + $ref: '_common.yaml#/components/schemas/SequenceNumber' + _primary_term: + type: integer + description: The primary term. + _index: + $ref: '_common.yaml#/components/schemas/IndexName' + _id: + $ref: '_common.yaml#/components/schemas/Id' + _score: + type: number + format: float + description: The score. + _source: + $ref: '#/components/schemas/Source' + model_id: + $ref: '_common.yaml#/components/schemas/Name' + required: + - _score Source: type: object properties: last_deployed_time: - type: number + type: integer + format: int64 description: The last deployed time. model_version: type: string description: The model version. created_time: - type: number + type: integer + format: int64 description: The created time. deploy_to_all_nodes: type: boolean @@ -133,11 +133,20 @@ components: model_state: type: string description: The model state. + enum: + - DEPLOY_FAILED + - REGISTERING 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: - type: number + type: integer + format: int64 description: The last updated time. name: type: string @@ -158,6 +167,22 @@ components: 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: From cb9390c9d25e0db84a7c7655da830000d4bcc1bc Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan Date: Thu, 14 Nov 2024 13:51:58 -0800 Subject: [PATCH 3/9] Removed comments Signed-off-by: Nathalie Jonathan --- spec/schemas/ml._common.yaml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/spec/schemas/ml._common.yaml b/spec/schemas/ml._common.yaml index 4d6291612..39c8cb97e 100644 --- a/spec/schemas/ml._common.yaml +++ b/spec/schemas/ml._common.yaml @@ -29,31 +29,11 @@ components: type: boolean description: Whether the search timed out. _shards: - # $ref: '#/components/schemas/SearchModelsShardsResponse' $ref: '_common.yaml#/components/schemas/ShardStatistics' hits: $ref: '#/components/schemas/SearchModelsHits' required: - hits - # SearchModelsShardsResponse: - # type: object - # properties: - # total: - # type: integer - # format: int64 - # description: The total number of shards. - # successful: - # type: integer - # format: int64 - # description: The number of successful shards. - # skipped: - # type: integer - # format: int64 - # description: The number of skipped shards. - # failed: - # type: integer - # format: int64 - # description: The number of failed shards. SearchModelsHits: type: object properties: From 5e926c294ba6b859cdc25b09025b168e963c58f3 Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan Date: Thu, 14 Nov 2024 16:23:20 -0800 Subject: [PATCH 4/9] Added missing model states Signed-off-by: Nathalie Jonathan --- spec/schemas/ml._common.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/schemas/ml._common.yaml b/spec/schemas/ml._common.yaml index 39c8cb97e..2eb2536c2 100644 --- a/spec/schemas/ml._common.yaml +++ b/spec/schemas/ml._common.yaml @@ -114,8 +114,13 @@ components: type: string description: The model state. enum: - - DEPLOY_FAILED - REGISTERING + - REGISTERED + - DEPLOYING + - DEPLOYED + - PARTIALLY_DEPLOYED + - UNDEPLOYED + - DEPLOY_FAILED planning_worker_node_count: type: number description: The planning worker node count. From 5561114e944da4124efcedd39243b1b241cefc5d Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan Date: Fri, 15 Nov 2024 09:09:44 -0800 Subject: [PATCH 5/9] Fixed lint errors and modified distributions Signed-off-by: Nathalie Jonathan --- spec/schemas/ml._common.yaml | 9 ++++----- tests/plugins/ml/ml/tasks.yaml | 4 ---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/spec/schemas/ml._common.yaml b/spec/schemas/ml._common.yaml index 2eb2536c2..865c9f2b1 100644 --- a/spec/schemas/ml._common.yaml +++ b/spec/schemas/ml._common.yaml @@ -114,13 +114,12 @@ components: type: string description: The model state. enum: - - REGISTERING - - REGISTERED - - DEPLOYING - DEPLOYED - - PARTIALLY_DEPLOYED - - UNDEPLOYED + - DEPLOYING - DEPLOY_FAILED + - PARTIALLY_DEPLOYED + - REGISTERED + - REGISTERING planning_worker_node_count: type: number description: The planning worker node count. diff --git a/tests/plugins/ml/ml/tasks.yaml b/tests/plugins/ml/ml/tasks.yaml index 7a1720493..542ea3468 100644 --- a/tests/plugins/ml/ml/tasks.yaml +++ b/tests/plugins/ml/ml/tasks.yaml @@ -1,10 +1,6 @@ $schema: ../../../../json_schemas/test_story.schema.yaml description: Test the creation of tasks. -distributions: - excluded: - - amazon-managed - - amazon-serverless version: '>= 2.11' warnings: multiple-paths-detected: false From bdb8728e6e841adee60a2069596696adfb0bcf18 Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan Date: Fri, 15 Nov 2024 11:16:11 -0800 Subject: [PATCH 6/9] Added refresh and updated response schema Signed-off-by: Nathalie Jonathan --- spec/schemas/ml._common.yaml | 10 ++++++++++ tests/plugins/ml/ml/models.yaml | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/spec/schemas/ml._common.yaml b/spec/schemas/ml._common.yaml index 865c9f2b1..336feb6b1 100644 --- a/spec/schemas/ml._common.yaml +++ b/spec/schemas/ml._common.yaml @@ -101,12 +101,18 @@ components: type: integer format: int64 description: The created time. + chunk_number: + type: integer + format: int64 + description: The chunk number. deploy_to_all_nodes: type: boolean description: Whether to deploy to all nodes. is_hidden: type: boolean description: Whether the model is hidden. + model_id: + $ref: '_common.yaml#/components/schemas/Name' description: type: string description: The model description. @@ -148,6 +154,10 @@ components: type: array items: $ref: '_common.yaml#/components/schemas/NodeIds' + total_chunks: + type: integer + format: int64 + description: The total chunks. algorithm: type: string description: The algorithm. diff --git a/tests/plugins/ml/ml/models.yaml b/tests/plugins/ml/ml/models.yaml index a8b8fc30d..87c010a69 100644 --- a/tests/plugins/ml/ml/models.yaml +++ b/tests/plugins/ml/ml/models.yaml @@ -22,6 +22,11 @@ chapters: status: 200 output: task_id: payload.task_id + - synopsis: Refresh the index. + path: /{index}/_refresh + method: POST + parameters: + index: .plugins-ml-model - synopsis: Search model. id: search_model path: /_plugins/_ml/models/_search From 3e3d64a69f145c80f3d85e6e39816ddd002d7074 Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan Date: Fri, 15 Nov 2024 11:38:05 -0800 Subject: [PATCH 7/9] Modified refresh Signed-off-by: Nathalie Jonathan --- tests/plugins/ml/ml/models.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/plugins/ml/ml/models.yaml b/tests/plugins/ml/ml/models.yaml index 87c010a69..7b138d88b 100644 --- a/tests/plugins/ml/ml/models.yaml +++ b/tests/plugins/ml/ml/models.yaml @@ -23,10 +23,8 @@ chapters: output: task_id: payload.task_id - synopsis: Refresh the index. - path: /{index}/_refresh + path: /_refresh method: POST - parameters: - index: .plugins-ml-model - synopsis: Search model. id: search_model path: /_plugins/_ml/models/_search From 343a4722b1e35697db87863ccba1c262292bbc07 Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan Date: Fri, 15 Nov 2024 15:18:19 -0800 Subject: [PATCH 8/9] Updated CHANGELOG and modified search model Signed-off-by: Nathalie Jonathan --- CHANGELOG.md | 2 +- tests/plugins/ml/ml/models.yaml | 34 ++++++++++++++------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe7b2d5f6..045729721 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,6 @@ 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)) ### 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)) @@ -33,6 +32,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Removed invalid `required` from `ppl` responses ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) - Added schema for security API error responses ([#646](https://github.com/opensearch-project/opensearch-api-specification/pull/646)) - Fixed `/{index}/_create/{id}` returning `201` ([#669](https://github.com/opensearch-project/opensearch-api-specification/pull/669)) +- Fixed `ml._common.yaml#SearchModelsResponse` and `SearchModelsHitsHit` ([#672](https://github.com/opensearch-project/opensearch-api-specification/pull/672)) ## [0.1.0] - 2024-10-25 diff --git a/tests/plugins/ml/ml/models.yaml b/tests/plugins/ml/ml/models.yaml index 7b138d88b..92cac3ca3 100644 --- a/tests/plugins/ml/ml/models.yaml +++ b/tests/plugins/ml/ml/models.yaml @@ -22,26 +22,6 @@ chapters: status: 200 output: task_id: payload.task_id - - synopsis: Refresh the index. - path: /_refresh - method: POST - - synopsis: Search model. - id: search_model - 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} @@ -57,6 +37,20 @@ chapters: retry: count: 5 wait: 30000 + - synopsis: Search model. + path: /_plugins/_ml/models/_search + method: GET + request: + payload: + query: + match_all: {} + size: 1000 + response: + status: 200 + payload: + hits: + hits: + - _score: 1 - synopsis: Delete model. path: /_plugins/_ml/models/{model_id} parameters: From c7569acc76a35dd1e657064611fa9e7900432955 Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan Date: Fri, 15 Nov 2024 16:07:36 -0800 Subject: [PATCH 9/9] Added more missing fields Signed-off-by: Nathalie Jonathan --- spec/schemas/ml._common.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spec/schemas/ml._common.yaml b/spec/schemas/ml._common.yaml index 336feb6b1..36f6c4954 100644 --- a/spec/schemas/ml._common.yaml +++ b/spec/schemas/ml._common.yaml @@ -97,6 +97,8 @@ components: model_version: type: string description: The model version. + version: + $ref: '_common.yaml#/components/schemas/VersionString' created_time: type: integer format: int64 @@ -126,6 +128,13 @@ components: - PARTIALLY_DEPLOYED - REGISTERED - REGISTERING + model_content_size_in_bytes: + type: integer + format: int64 + description: The model content size in bytes. + model_content_hash_value: + type: string + description: The model content hash value. planning_worker_node_count: type: number description: The planning worker node count. @@ -134,10 +143,21 @@ components: model_format: type: string description: The model format. + model_task_type: + type: string + description: The model task type. last_updated_time: type: integer format: int64 description: The last updated time. + last_registered_time: + type: integer + format: int64 + description: The last registered time. + auto_redeploy_retry_times: + type: integer + format: int64 + description: The auto redeploy retry times. name: type: string description: The model name. @@ -161,6 +181,9 @@ components: algorithm: type: string description: The algorithm. + url: + type: string + description: The model URL. ModelConfig: type: object properties: