Skip to content

Commit

Permalink
Address PR comments; Added CHANGELOG
Browse files Browse the repository at this point in the history
Signed-off-by: Tanqiu Liu <liutanqiu@gmail.com>
  • Loading branch information
tanqiuliu committed Nov 8, 2023
1 parent 8ab54c4 commit 371a9dd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Features
### Enhancements
### Bug Fixes
- Fixed flaky integration tests caused by model_state transition latency.
### Infrastructure
### Documentation
### Maintenance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ protected void loadModel(String modelId) throws Exception {
isComplete = checkComplete(taskQueryResult);
Thread.sleep(DEFAULT_TASK_RESULT_QUERY_INTERVAL_IN_MILLISECOND);
}
// wait for model state update to DEPLOYED
pollForModelState(modelId, Set.of(MLModelState.DEPLOYED), 3000, 5);
}

/**
Expand Down Expand Up @@ -612,7 +614,7 @@ protected void deleteModel(String modelId) {
);

// wait for model undeploy to complete
pollForModelState(modelId, MLModelState.UNDEPLOYED, 3000, 5);
pollForModelState(modelId, Set.of(MLModelState.UNDEPLOYED, MLModelState.DEPLOY_FAILED), 3000, 5);

makeRequest(
client(),
Expand All @@ -624,14 +626,26 @@ protected void deleteModel(String modelId) {
);
}

@SneakyThrows
protected void pollForModelState(String modelId, MLModelState expectedModelState, int intervalMs, int maxAttempts) {
protected void pollForModelState(String modelId, Set<MLModelState> exitModelStates, int intervalMs, int maxAttempts)
throws InterruptedException {
MLModelState currentState = null;
for (int i = 0; i < maxAttempts; i++) {
Thread.sleep(intervalMs);
if (expectedModelState.equals(getModelState(modelId))) {
currentState = getModelState(modelId);
if (exitModelStates.contains(currentState)) {
return;
}
}
fail(
String.format(
LOCALE,
"Model state does not reached exit states %s after %d attempts with interval of %d ms, latest model state: %s.",
StringUtils.join(exitModelStates, ","),
maxAttempts,
intervalMs,
currentState
)
);
}

public boolean isUpdateClusterSettings() {
Expand Down Expand Up @@ -747,7 +761,7 @@ protected Set<String> findDeployedModels() {
.filter(
hitsMap -> !Objects.isNull(hitsMap)
&& hitsMap.containsKey("model_id")
&& MLModelState.DEPLOYED.equals(getModelState(hitsMap.get("model_id").toString()))
&& getModelState(hitsMap.get("model_id").toString()) == MLModelState.DEPLOYED
)
.map(hitsMap -> (String) hitsMap.get("model_id"))
.collect(Collectors.toSet());
Expand Down

0 comments on commit 371a9dd

Please sign in to comment.