use of com.amazonaws.services.personalize.model.ListSolutionsRequest 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();
}
use of com.amazonaws.services.personalize.model.ListSolutionsRequest in project knime-cloud by knime.
the class AmazonPersonalizeUtils method listAllSolutions.
/**
* @param personalize the amazon personalize client
* @return all solutions
*/
public static List<SolutionSummary> listAllSolutions(final AmazonPersonalize personalize) {
final ListSolutionsRequest request = new ListSolutionsRequest().withMaxResults(100);
ListSolutionsResult result = personalize.listSolutions(request);
List<SolutionSummary> list = result.getSolutions();
String nextToken;
while ((nextToken = result.getNextToken()) != null) {
result = personalize.listSolutions(request.withNextToken(nextToken));
list.addAll(result.getSolutions());
}
return list;
}
Aggregations