use of com.cognizant.devops.automl.task.util.AutoMLExecutor in project Insights by CognizantOneDevOps.
the class AutoMLSubscriber method handleTaskExecution.
@Override
public void handleTaskExecution(byte[] body) throws IOException {
List<JsonObject> failedJobs = new ArrayList<>();
long startTime = System.nanoTime();
try {
String message = new String(body, StandardCharsets.UTF_8);
JsonObject incomingTaskMessage = JsonUtils.parseStringAsJsonObject(message);
String workflowId = incomingTaskMessage.get("workflowId").getAsString();
executionId = incomingTaskMessage.get("executionId").getAsLong();
workflowConfig = workflowDAL.getWorkflowConfigByWorkflowId(workflowId);
autoMlConfig = autoMlDAL.fetchUseCasesByWorkflowId(workflowId);
if (autoMlConfig != null) {
autoMlConfig.setStatus(AutoMLEnum.Status.IN_PROGRESS.name());
autoMlDAL.updateMLConfig(autoMlConfig);
List<Callable<JsonObject>> mlTaskToExecute = new ArrayList<>();
AutoMLExecutor autoMLExecutor = new AutoMLExecutor(autoMlConfig);
mlTaskToExecute.add(autoMLExecutor);
/* segregate entire automl execution list into defined chunks */
List<List<Callable<JsonObject>>> kpiChunkList = WorkflowThreadPool.getChunk(mlTaskToExecute, 1);
log.debug("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", executionId, autoMlConfig.getWorkflowConfig().getWorkflowId(), "-", autoMlConfig.getWorkflowConfig().getWorkflowType(), "-", "-", 0, " ModelId :" + autoMlConfig.getModelId() + " UsecaseName :" + autoMlConfig.getUseCaseName() + " PredictionColumn : " + autoMlConfig.getPredictionColumn() + " PredictionType :" + autoMlConfig.getPredictionType() + " TrainingPercentage : " + autoMlConfig.getTrainingPerc() + " status : " + autoMlConfig.getStatus());
/* submit each chunk to threadpool in a loop */
executeAutoMLChunks(kpiChunkList, failedJobs);
if (!failedJobs.isEmpty()) {
updateFailedTaskStatusLog(failedJobs);
}
}
} catch (InsightsJobFailedException e) {
log.error("Worlflow Detail ==== InsightsJobFailedException ==== ", e);
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", executionId, autoMlConfig.getWorkflowConfig().getWorkflowId(), "-", autoMlConfig.getWorkflowConfig().getWorkflowType(), "-", "-", 0, "ModelId :" + autoMlConfig.getModelId() + " UsecaseName :" + autoMlConfig.getUseCaseName() + " PredictionColumn : " + autoMlConfig.getPredictionColumn() + "predictionType :" + autoMlConfig.getPredictionType() + "trainingPercentage : " + autoMlConfig.getTrainingPerc() + "status : " + autoMlConfig.getStatus() + "Auto ML task failed to execute" + e.getMessage());
throw new InsightsJobFailedException("Auto ML task failed to execute " + e.getMessage());
} catch (Exception e) {
JsonObject response = new JsonObject();
response.addProperty("Status", "Failure");
response.addProperty("errorLog", e.getMessage());
failedJobs.add(response);
updateFailedTaskStatusLog(failedJobs);
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", executionId, autoMlConfig.getWorkflowConfig().getWorkflowId(), "-", autoMlConfig.getWorkflowConfig().getWorkflowType(), "-", "-", 0, "ModelId :" + autoMlConfig.getModelId() + "UsecaseName :" + autoMlConfig.getUseCaseName() + "PredictionColumn : " + autoMlConfig.getPredictionColumn() + "predictionType :" + autoMlConfig.getPredictionType() + "trainingPercentage : " + autoMlConfig.getTrainingPerc() + "status : " + autoMlConfig.getStatus() + e.getMessage());
}
long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
log.debug("Worlflow Detail ==== AutoML task completed successfully.");
log.debug("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", executionId, autoMlConfig.getWorkflowConfig().getWorkflowId(), "-", autoMlConfig.getWorkflowConfig().getWorkflowType(), "-", "-", processingTime, "ModelId :" + autoMlConfig.getModelId() + "UsecaseName :" + autoMlConfig.getUseCaseName() + "PredictionColumn : " + autoMlConfig.getPredictionColumn() + "predictionType :" + autoMlConfig.getPredictionType() + "trainingPercentage : " + autoMlConfig.getTrainingPerc() + "status : " + autoMlConfig.getStatus() + " AutoML task completed successfully.");
}
Aggregations