From 33aab0291a88c6a168aaf99a9e242854e0a239ae Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan Date: Fri, 20 Dec 2024 11:54:16 -0800 Subject: [PATCH] Added ML Model APIs (upload chunk), moved test for deprecated chunk upload to create_metadata.yaml, updated CHANGELOG. Signed-off-by: Nathalie Jonathan --- CHANGELOG.md | 3 +- spec/namespaces/ml.yaml | 62 +++++++++++++++++-- tests/plugins/ml/models/create_metadata.yaml | 46 +++++++++++++- .../plugins/ml/models/register_metadata.yaml | 14 ++--- 4 files changed, 108 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f143134..d971a52e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,7 +40,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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`, `_register_meta`, `POST /_plugins/_ml/models/{model_id}/_load`, `_predict`, `_unload`, `chunk/{index}`, and `PUT /_plugins/_ml/models/{model_id}` ([#733](https://github.com/opensearch-project/opensearch-api-specification/pull/733)) +- Added `GET /_plugins/_ml/models/{model_id}`, `POST /_plugins/_ml/models/_search`, `POST /_plugins/_ml/models/_unload`, `_undeploy`, `_upload`, `meta`, `_register_meta`, `POST /_plugins/_ml/models/{model_id}/_load`, `_predict`, `_unload`, `chunk/{chunk_number}`, `upload_chunk/{chunk_number}`, 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)) @@ -82,6 +82,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Fixed response schema for `GET /_plugins/_security/api/nodesdn/{cluster_name}` ([#731](https://github.com/opensearch-project/opensearch-api-specification/pull/731)) - Fixed request body for `/_search/scroll/{scroll_id}` ([#732](https://github.com/opensearch-project/opensearch-api-specification/pull/732)) - Fixed type in `_msearch/template` ([#735](https://github.com/opensearch-project/opensearch-api-specification/pull/735)) +- Fixed indices API schemas ([#750](https://github.com/opensearch-project/opensearch-api-specification/pull/750)) ### Changed - Changed `tasks._common:TaskInfo` and `tasks._common:TaskGroup` to be composed of a `tasks._common:TaskInfoBase` ([#683](https://github.com/opensearch-project/opensearch-api-specification/pull/683)) diff --git a/spec/namespaces/ml.yaml b/spec/namespaces/ml.yaml index 8ab6a2a0..b948bb94 100644 --- a/spec/namespaces/ml.yaml +++ b/spec/namespaces/ml.yaml @@ -65,19 +65,34 @@ paths: responses: '200': $ref: '#/components/responses/ml.register_model_meta@200' - /_plugins/_ml/models/{model_id}/chunk/{index}: + /_plugins/_ml/models/{model_id}/chunk/{chunk_number}: post: operationId: ml.chunk_model.0 x-operation-group: ml.chunk_model - description: Chunks model. + deprecated: true + x-deprecation-message: Use `upload_chunk` instead. + description: Uploads model chunk. parameters: - - $ref: '#/components/parameters/ml.chunk_model::path.index' + - $ref: '#/components/parameters/ml.chunk_model::path.chunk_number' - $ref: '#/components/parameters/ml.chunk_model::path.model_id' requestBody: $ref: '#/components/requestBodies/ml.chunk_model' responses: '200': $ref: '#/components/responses/ml.chunk_model@200' + /_plugins/_ml/models/{model_id}/upload_chunk/{chunk_number}: + post: + operationId: ml.upload_chunk.0 + x-operation-group: ml.upload_chunk + description: Uploads model chunk. + parameters: + - $ref: '#/components/parameters/ml.upload_chunk::path.chunk_number' + - $ref: '#/components/parameters/ml.upload_chunk::path.model_id' + requestBody: + $ref: '#/components/requestBodies/ml.upload_chunk' + responses: + '200': + $ref: '#/components/responses/ml.upload_chunk@200' /_plugins/_ml/models/_upload: post: operationId: ml.upload_model.0 @@ -418,6 +433,17 @@ components: description: The model chunk. required: - chunk + ml.upload_chunk: + content: + application/json: + schema: + type: object + properties: + chunk: + type: string + description: The model chunk. + required: + - chunk ml.upload_model: content: application/json: @@ -655,7 +681,18 @@ components: properties: status: type: string - description: The status of the chunking operation. + description: The status of the chunk upload operation. + required: + - status + ml.upload_chunk@200: + content: + application/json: + schema: + type: object + properties: + status: + type: string + description: The status of the chunk upload operation. required: - status ml.upload_model@200: @@ -843,8 +880,8 @@ components: required: true schema: type: string - ml.chunk_model::path.index: - name: index + ml.chunk_model::path.chunk_number: + name: chunk_number in: path required: true schema: @@ -856,6 +893,19 @@ components: required: true schema: type: string + ml.upload_chunk::path.chunk_number: + name: chunk_number + in: path + required: true + schema: + type: integer + format: int64 + ml.upload_chunk::path.model_id: + name: model_id + in: path + required: true + schema: + type: string ml.delete_task::path.task_id: name: task_id in: path diff --git a/tests/plugins/ml/models/create_metadata.yaml b/tests/plugins/ml/models/create_metadata.yaml index 4ad59ccd..a0bb4ea6 100644 --- a/tests/plugins/ml/models/create_metadata.yaml +++ b/tests/plugins/ml/models/create_metadata.yaml @@ -1,11 +1,12 @@ $schema: ../../../../json_schemas/test_story.schema.yaml -description: Test the creation of model metadata using meta API (deprecated). +description: Test deprecated meta and chunk APIs for model creation and chunk upload. distributions: excluded: - amazon-managed - amazon-serverless -version: '>= 2.11' +warnings: + multiple-paths-detected: false prologues: - path: /_cluster/settings method: PUT @@ -39,4 +40,43 @@ chapters: response: status: 200 output: - model_id: payload.model_id \ No newline at end of file + model_id: payload.model_id + - synopsis: Upload chunk 0. + path: /_plugins/_ml/models/{model_id}/chunk/{chunk_number} + method: POST + parameters: + chunk_number: 0 + model_id: ${model_metadata.model_id} + request: + payload: + chunk: chunk0 + response: + status: 200 + payload: + status: Uploaded + - synopsis: Upload chunk 1. + path: /_plugins/_ml/models/{model_id}/chunk/{chunk_number} + method: POST + parameters: + chunk_number: 1 + model_id: ${model_metadata.model_id} + request: + payload: + chunk: chunk1 + response: + status: 200 + payload: + status: Uploaded + - synopsis: Upload chunk 2. + path: /_plugins/_ml/models/{model_id}/chunk/{chunk_number} + method: POST + parameters: + chunk_number: 2 + model_id: ${model_metadata.model_id} + request: + payload: + chunk: chunk2 + response: + status: 200 + payload: + status: Uploaded diff --git a/tests/plugins/ml/models/register_metadata.yaml b/tests/plugins/ml/models/register_metadata.yaml index 30faf08a..d300f6e8 100644 --- a/tests/plugins/ml/models/register_metadata.yaml +++ b/tests/plugins/ml/models/register_metadata.yaml @@ -1,6 +1,6 @@ $schema: ../../../../json_schemas/test_story.schema.yaml -description: Test the creation of model metadata and chunking. +description: Test the creation of model metadata and upload model chunk. distributions: excluded: - amazon-managed @@ -43,10 +43,10 @@ chapters: output: model_id: payload.model_id - synopsis: Upload chunk 0. - path: /_plugins/_ml/models/{model_id}/chunk/{index} + path: /_plugins/_ml/models/{model_id}/upload_chunk/{chunk_number} method: POST parameters: - index: 0 + chunk_number: 0 model_id: ${model_metadata.model_id} request: payload: @@ -56,10 +56,10 @@ chapters: payload: status: Uploaded - synopsis: Upload chunk 1. - path: /_plugins/_ml/models/{model_id}/chunk/{index} + path: /_plugins/_ml/models/{model_id}/upload_chunk/{chunk_number} method: POST parameters: - index: 1 + chunk_number: 1 model_id: ${model_metadata.model_id} request: payload: @@ -69,10 +69,10 @@ chapters: payload: status: Uploaded - synopsis: Upload chunk 2. - path: /_plugins/_ml/models/{model_id}/chunk/{index} + path: /_plugins/_ml/models/{model_id}/upload_chunk/{chunk_number} method: POST parameters: - index: 2 + chunk_number: 2 model_id: ${model_metadata.model_id} request: payload: