Skip to content

Commit

Permalink
fix: model upload failed with model group level access control (opens…
Browse files Browse the repository at this point in the history
…earch-project#677) (opensearch-project#684)

Signed-off-by: Lin Wang <wonglam@amazon.com>
(cherry picked from commit b159ff0)

Co-authored-by: Lin Wang <wonglam@amazon.com>
Signed-off-by: leanne.laceybyrne@eliatra.com <leanne.laceybyrne@eliatra.com>
  • Loading branch information
2 people authored and leanneeliatra committed Sep 15, 2023
1 parent 4c37ef4 commit 5dfbcc6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
36 changes: 23 additions & 13 deletions cypress/integration/plugins/ml-commons-dashboards/overview_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,32 @@ if (Cypress.env('ML_COMMONS_DASHBOARDS_ENABLED')) {
// Disable only_run_on_ml_node to avoid model upload error in case of cluster no ml nodes
cy.disableOnlyRunOnMLNode();
cy.disableNativeMemoryCircuitBreaker();
cy.enableRegisterModelViaURL();
cy.wait(1000);

cy.uploadModelByUrl({
name: uploadModelName,
version: '1.0.0',
model_format: 'TORCH_SCRIPT',
model_task_type: 'text_embedding',
model_config: {
model_type: 'bert',
embedding_dimension: 768,
framework_type: 'sentence_transformers',
all_config:
'{"architectures":["BertModel"],"max_position_embeddings":512,"model_type":"bert","num_attention_heads":12,"num_hidden_layers":6}',
},
url: 'https://github.com/opensearch-project/ml-commons/blob/2.x/ml-algorithms/src/test/resources/org/opensearch/ml/engine/algorithms/text_embedding/traced_small_model.zip?raw=true',
cy.registerModelGroup({
name: 'model-group',
model_access_mode: 'public',
})
.then(({ model_group_id }) =>
cy.uploadModelByUrl({
name: uploadModelName,
version: '1.0.0',
model_format: 'TORCH_SCRIPT',
model_task_type: 'text_embedding',
model_group_id,
model_content_hash_value:
'e13b74006290a9d0f58c1376f9629d4ebc05a0f9385f40db837452b167ae9021',
model_config: {
model_type: 'bert',
embedding_dimension: 768,
framework_type: 'sentence_transformers',
all_config:
'{"architectures":["BertModel"],"max_position_embeddings":512,"model_type":"bert","num_attention_heads":12,"num_hidden_layers":6}',
},
url: 'https://github.com/opensearch-project/ml-commons/blob/2.x/ml-algorithms/src/test/resources/org/opensearch/ml/engine/algorithms/text_embedding/traced_small_model.zip?raw=true',
})
)
.then(({ task_id: taskId }) =>
cy.cyclingCheckTask({
taskId,
Expand Down
18 changes: 18 additions & 0 deletions cypress/utils/plugins/ml-commons-dashboards/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ Cypress.Commands.add('uploadModelByUrl', (body) =>
.then(({ body }) => body)
);

Cypress.Commands.add('registerModelGroup', (body) =>
cy
.request({
method: 'POST',
url: MLC_API.MODEL_GROUP_REGISTER,
body,
})
.then(({ body }) => body)
);

Cypress.Commands.add('deleteMLCommonsModel', (modelId) =>
cy.request('DELETE', `${MLC_API.MODEL_BASE}/${modelId}`)
);
Expand Down Expand Up @@ -86,3 +96,11 @@ Cypress.Commands.add('disableNativeMemoryCircuitBreaker', () => {
},
});
});

Cypress.Commands.add('enableRegisterModelViaURL', () => {
cy.request('PUT', `${Cypress.env('openSearchUrl')}/_cluster/settings`, {
transient: {
'plugins.ml_commons.allow_registering_model_via_url': true,
},
});
});
1 change: 1 addition & 0 deletions cypress/utils/plugins/ml-commons-dashboards/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const MLC_API_BASE = `${BACKEND_BASE_PATH}/_plugins/_ml`;
export const MLC_API = {
MODEL_BASE: `${MLC_API_BASE}/models`,
MODEL_UPLOAD: `${MLC_API_BASE}/models/_upload`,
MODEL_GROUP_REGISTER: `${MLC_API_BASE}/model_groups/_register`,
TASK_BASE: `${MLC_API_BASE}/tasks`,
};

Expand Down

0 comments on commit 5dfbcc6

Please sign in to comment.