Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support outputs on tests #324

Merged
merged 20 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
329 changes: 329 additions & 0 deletions spec/namespaces/ml.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,329 @@
openapi: 3.1.0
info:
title: OpenSearch ML API
description: OpenSearch ML API
version: 1.0.0
paths:
/_plugins/_ml/model_groups/_register:
post:
operationId: ml.register_model_group.0
description: Registers a model group.
requestBody:
$ref: '#/components/requestBodies/ml.register_model_group'
responses:
'200':
$ref: '#/components/responses/ml.register_model_group@200'
/_plugins/_ml/model_groups/{model_group_id}:
get:
operationId: ml.get_model_group.0
description: Retrieves a model group.
parameters:
- name: model_group_id
in: path
required: true
schema:
type: string
responses:
'200':
$ref: '#/components/responses/ml.get_model_group@200'
'404':
description: The model group was not found.
delete:
operationId: ml.delete_model_group.0
description: Deletes a model group.
parameters:
- name: model_group_id
in: path
required: true
schema:
type: string
responses:
'200':
description: The model group was deleted.
'404':
description: The model group was not found.
/_plugins/_ml/models/_register:
post:
operationId: ml.register_model.0
description: Registers a model.
requestBody:
$ref: '#/components/requestBodies/ml.register_model'
responses:
'200':
$ref: '#/components/responses/ml.register_model@200'
/_plugins/_ml/models/{model_id}:
delete:
operationId: ml.delete_model.0
description: Deletes a model.
parameters:
- name: model_id
in: path
required: true
schema:
type: string
responses:
'200':
description: The model was deleted.
'404':
description: The model was not found.
/_plugins/_ml/tasks/{task_id}:
get:
operationId: ml.get_task.0
description: Retrieves a task.
parameters:
- name: task_id
in: path
required: true
schema:
type: string
responses:
'200':
$ref: '#/components/responses/ml.get_task@200'
/_plugins/_ml/models/_search:
get:
operationId: ml.search_models.0
description: Searches for models.
requestBody:
$ref: '#/components/requestBodies/ml.search_models'
responses:
'200':
$ref: '#/components/responses/ml.search_models@200'
components:
requestBodies:
ml.register_model_group:
content:
application/json:
schema:
type: object
properties:
name:
type: string
description: The model group name.
description:
type: string
description: The model group description.
access_mode:
type: string
description: The model group access mode.
enum: [private, public, restricted]
backend_roles:
type: array
items:
type: string
description: The backend roles.
add_all_backend_roles:
type: boolean
description: The add all backend roles.
required:
- name
ml.register_model:
content:
application/json:
schema:
type: object
properties:
name:
type: string
description: The model name.
version:
type: string
description: The model version.
model_format:
type: string
description: The portable format of the model file.
enum: [TORCH_SCRIPT, ONNX]
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.
required:
- name
- version
- model_format
ml.search_models:
content:
application/json:
schema:
type: object
properties:
query:
type: object
# TODO: Define the query schema
description: The query.
size:
type: integer
description: The number of models to return.
required:
- query
- size
responses:
ml.register_model_group@200:
content:
application/json:
schema:
type: object
properties:
model_group_id:
type: string
description: The model group ID.
status:
type: string
description: The status.
required:
- model_group_id
- status
ml.get_model_group@200:
content:
application/json:
schema:
type: object
properties:
name:
type: string
description: The model group name.
latest_version:
type: number
description: The latest version.
description:
type: string
description: The model group description.
access:
type: string
description: The model group access.
required:
- name
- latest_version
- description
- access
ml.search_model_group@200:
content:
application/json:
schema:
type: object
properties:
hits:
$ref: '#/components/schemas/ml.search_model_group.hits'
required:
- hits
ml.register_model@200:
content:
application/json:
schema:
type: object
properties:
task_id:
type: string
description: The task ID.
model_id:
type: string
description: The model ID.
status:
type: string
description: The status.
required:
# model_id doesn't seem to be required in the response
# it can be eventually retrieved through the task_id
- task_id
- status
ml.get_task@200:
content:
application/json:
schema:
type: object
properties:
model_id:
type: string
description: The model ID.
state:
type: string
description: The state.
enum:
- CREATED
- RUNNING
- COMPLETED
- FAILED
- CANCELLED
- COMPLETED_WITH_ERROR
required:
- state
ml.search_models@200:
content:
application/json:
schema:
type: object
properties:
hits:
$ref: '#/components/schemas/ml.search_models.hits'
required:
- hits
schemas:
ml.search_model_group.hits:
type: object
properties:
total:
type: object
properties:
value:
type: integer
description: The total number of hits.
relation:
type: string
description: The relation.
required:
- value
- relation
hits:
type: array
items:
$ref: '#/components/schemas/ml.search_model_group.hits.hit'
required:
- total
- hits
ml.search_model_group.hits.hit:
type: object
properties:
_id:
type: string
description: The hit ID.
required:
- _id
ml.search_models.hits:
type: object
properties:
total:
type: object
properties:
value:
type: integer
description: The total number of hits.
relation:
type: string
description: The relation.
required:
- value
- relation
hits:
type: array
items:
$ref: '#/components/schemas/ml.search_models.hits.hit'
required:
- total
- hits
ml.search_models.hits.hit:
type: object
properties:
_index:
type: string
description: The index.
_id:
type: string
description: The hit ID.
model_id:
type: string
description: The model ID.
required:
- _id
- model_id

38 changes: 38 additions & 0 deletions tests/ml/model_lifecycle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
$schema: ../json_schemas/test_story.schema.yaml

skip: false
description: |
This test story checks that we can create a model group
epilogues:
- path: /_plugins/_ml/model_groups/{model_group_id}
method: DELETE
status: [200, 404]
parameters:
model_group_id: ${create_model_group.test_model_group_id}
chapters:
- synopsis: Configure cluster
path: /_cluster/settings
method: PUT
request_body:
payload:
persistent:
plugins:
ml_commons:
only_run_on_ml_node: false
- synopsis: Create model group
id: create_model_group
path: /_plugins/_ml/model_groups/_register
method: POST
request_body:
payload:
name: "NLP_Group"
description: "Model group for NLP models"
output:
test_model_group_id: "payload.model_group_id"
- synopsis: Query model group
path: /_plugins/_ml/model_groups/{model_group_id}
method: GET
parameters:
model_group_id: ${create_model_group.test_model_group_id}
response:
status: 200
Loading