use of com.amazonaws.services.personalize.model.SolutionConfig in project knime-cloud by knime.
the class AmazonPersonalizeCreateSolutionVersionNodeModel method createSolution.
private String createSolution(final AmazonPersonalize personalizeClient) {
final NameArnPair datasetGroup = m_settings.getDatasetGroup();
final RecipeSelection recipeSelection = m_settings.getRecipeSelection();
final boolean isHPO = m_settings.isHyperparameterOpt();
// Create the request
final CreateSolutionRequest createSolutionRequest = new CreateSolutionRequest().withDatasetGroupArn(datasetGroup.getARN()).withPerformHPO(isHPO);
if (recipeSelection == RecipeSelection.PREDEFINED) {
createSolutionRequest.setPerformAutoML(false);
createSolutionRequest.setRecipeArn(m_settings.getPredefinedRecipe().getARN());
} else if (recipeSelection == RecipeSelection.USER_DEFINED) {
createSolutionRequest.setPerformAutoML(false);
createSolutionRequest.setRecipeArn(m_settings.getUserDefinedRecipeArn());
} else if (recipeSelection == RecipeSelection.AUTOML) {
createSolutionRequest.setPerformAutoML(true);
final SolutionConfig solutionConfig = new SolutionConfig();
solutionConfig.setAutoMLConfig(new AutoMLConfig().withRecipeList(AUTOML_RECIPES));
createSolutionRequest.setSolutionConfig(solutionConfig);
} else {
throw new IllegalStateException("Unexpected recipe selection: " + recipeSelection.name());
}
final ListSolutionsResult solutions = personalizeClient.listSolutions(new ListSolutionsRequest().withDatasetGroupArn(datasetGroup.getARN()));
final String solutionName = m_settings.getSolutionName();
final Optional<String> optionalSolutionArn = solutions.getSolutions().stream().filter(e -> e.getName().equals(solutionName)).map(e -> e.getSolutionArn()).findFirst();
if (optionalSolutionArn.isPresent()) {
throw new IllegalStateException("A solution with the name '" + solutionName + "' already exists.");
}
createSolutionRequest.setName(solutionName);
return personalizeClient.createSolution(createSolutionRequest).getSolutionArn();
}
Aggregations