Skip to content

Commit

Permalink
fix error message (#1967)
Browse files Browse the repository at this point in the history
* fix error message

Signed-off-by: xinyual <[email protected]>

* modify error message

Signed-off-by: xinyual <[email protected]>

---------

Signed-off-by: xinyual <[email protected]>
  • Loading branch information
xinyual authored Jan 31, 2024
1 parent 72d494c commit 0fd07f0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,12 @@ public void downloadAndSplit(
DownloadUtils.download(url, modelPath, new ProgressBar());
verifyModelZipFile(modelFormat, modelPath, modelName, functionName);
String hash = calculateFileHash(modelZipFile);
if (hash.equals(modelContentHash)) {
if (modelContentHash == null) {
log.error("Hash code need to be provided when register via url.");
throw (new IllegalArgumentException(
"Model content Hash code need to be provided when register via url. Please calculate sha 256 Hash code."
));
} else if (hash.equals(modelContentHash)) {
List<String> chunkFiles = splitFileIntoChunks(modelZipFile, modelPartsPath, CHUNK_SIZE);
Map<String, Object> result = new HashMap<>();
result.put(CHUNK_FILES, chunkFiles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ public void testDownloadAndSplit() throws URISyntaxException {
assertNotEquals(0, argumentCaptor.getValue().size());
}

@Test
public void testDownloadAndSplit_nullHashCode() throws URISyntaxException {
String modelUrl = getClass().getResource("traced_small_model.zip").toURI().toString();
modelHelper.downloadAndSplit(modelFormat, modelId, "model_name", "1", modelUrl, null, FunctionName.TEXT_EMBEDDING, actionListener);
ArgumentCaptor<Exception> argumentCaptor = ArgumentCaptor.forClass(Exception.class);
verify(actionListener).onFailure(argumentCaptor.capture());
assertEquals(IllegalArgumentException.class, argumentCaptor.getValue().getClass());
}

@Test
public void testDownloadAndSplit_HashFailure() throws URISyntaxException {
String modelUrl = getClass().getResource("traced_small_model.zip").toURI().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ private void deployModel(
"Model already deployed to these nodes: "
+ Arrays.toString(difference.toArray(new String[0]))
+ ", but they are not included in target node ids. Undeploy model from these nodes if don't need them any more."
+ "Undeploy from old nodes before try to deploy model on new nodes. Or include all old nodes on your target nodes."

)
);
return;
Expand Down

0 comments on commit 0fd07f0

Please sign in to comment.