Search in sources :

Example 1 with ListSolutionsResult

use of com.amazonaws.services.personalize.model.ListSolutionsResult 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();
}
Also used : NodeSettingsRO(org.knime.core.node.NodeSettingsRO) AmazonConnectionInformationPortObject(org.knime.cloud.aws.util.AmazonConnectionInformationPortObject) DataTableSpec(org.knime.core.data.DataTableSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) GetSolutionMetricsRequest(com.amazonaws.services.personalize.model.GetSolutionMetricsRequest) ExecutionContext(org.knime.core.node.ExecutionContext) CloudConnectionInformation(org.knime.cloud.core.util.port.CloudConnectionInformation) AmazonPersonalizeUtils(org.knime.cloud.aws.mlservices.utils.personalize.AmazonPersonalizeUtils) Status(org.knime.cloud.aws.mlservices.utils.personalize.AmazonPersonalizeUtils.Status) AutoMLConfig(com.amazonaws.services.personalize.model.AutoMLConfig) DataColumnSpec(org.knime.core.data.DataColumnSpec) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) Map(java.util.Map) DescribeSolutionRequest(com.amazonaws.services.personalize.model.DescribeSolutionRequest) AmazonPersonalizeConnection(org.knime.cloud.aws.mlservices.nodes.personalize.AmazonPersonalizeConnection) DataCell(org.knime.core.data.DataCell) DescribeRecipeRequest(com.amazonaws.services.personalize.model.DescribeRecipeRequest) ListSolutionsRequest(com.amazonaws.services.personalize.model.ListSolutionsRequest) PortType(org.knime.core.node.port.PortType) DescribeSolutionVersionResult(com.amazonaws.services.personalize.model.DescribeSolutionVersionResult) DefaultRow(org.knime.core.data.def.DefaultRow) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) NameArnPair(org.knime.cloud.aws.mlservices.utils.personalize.NameArnPair) StringCellFactory(org.knime.core.data.def.StringCell.StringCellFactory) DescribeSolutionResult(com.amazonaws.services.personalize.model.DescribeSolutionResult) DescribeSolutionVersionRequest(com.amazonaws.services.personalize.model.DescribeSolutionVersionRequest) ListSolutionsResult(com.amazonaws.services.personalize.model.ListSolutionsResult) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) IOException(java.io.IOException) DoubleCell(org.knime.core.data.def.DoubleCell) AmazonPersonalize(com.amazonaws.services.personalize.AmazonPersonalize) BufferedDataContainer(org.knime.core.node.BufferedDataContainer) NodeModel(org.knime.core.node.NodeModel) CreateSolutionVersionRequest(com.amazonaws.services.personalize.model.CreateSolutionVersionRequest) File(java.io.File) DoubleCellFactory(org.knime.core.data.def.DoubleCell.DoubleCellFactory) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) SolutionConfig(com.amazonaws.services.personalize.model.SolutionConfig) BufferedDataTable(org.knime.core.node.BufferedDataTable) CreateSolutionRequest(com.amazonaws.services.personalize.model.CreateSolutionRequest) Optional(java.util.Optional) StringCell(org.knime.core.data.def.StringCell) PortObject(org.knime.core.node.port.PortObject) NameArnPair(org.knime.cloud.aws.mlservices.utils.personalize.NameArnPair) CreateSolutionRequest(com.amazonaws.services.personalize.model.CreateSolutionRequest) SolutionConfig(com.amazonaws.services.personalize.model.SolutionConfig) ListSolutionsRequest(com.amazonaws.services.personalize.model.ListSolutionsRequest) AutoMLConfig(com.amazonaws.services.personalize.model.AutoMLConfig) ListSolutionsResult(com.amazonaws.services.personalize.model.ListSolutionsResult)

Example 2 with ListSolutionsResult

use of com.amazonaws.services.personalize.model.ListSolutionsResult 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;
}
Also used : ListSolutionsRequest(com.amazonaws.services.personalize.model.ListSolutionsRequest) ListSolutionsResult(com.amazonaws.services.personalize.model.ListSolutionsResult) SolutionSummary(com.amazonaws.services.personalize.model.SolutionSummary)

Aggregations

ListSolutionsRequest (com.amazonaws.services.personalize.model.ListSolutionsRequest)2 ListSolutionsResult (com.amazonaws.services.personalize.model.ListSolutionsResult)2 AmazonPersonalize (com.amazonaws.services.personalize.AmazonPersonalize)1 AutoMLConfig (com.amazonaws.services.personalize.model.AutoMLConfig)1 CreateSolutionRequest (com.amazonaws.services.personalize.model.CreateSolutionRequest)1 CreateSolutionVersionRequest (com.amazonaws.services.personalize.model.CreateSolutionVersionRequest)1 DescribeRecipeRequest (com.amazonaws.services.personalize.model.DescribeRecipeRequest)1 DescribeSolutionRequest (com.amazonaws.services.personalize.model.DescribeSolutionRequest)1 DescribeSolutionResult (com.amazonaws.services.personalize.model.DescribeSolutionResult)1 DescribeSolutionVersionRequest (com.amazonaws.services.personalize.model.DescribeSolutionVersionRequest)1 DescribeSolutionVersionResult (com.amazonaws.services.personalize.model.DescribeSolutionVersionResult)1 GetSolutionMetricsRequest (com.amazonaws.services.personalize.model.GetSolutionMetricsRequest)1 SolutionConfig (com.amazonaws.services.personalize.model.SolutionConfig)1 SolutionSummary (com.amazonaws.services.personalize.model.SolutionSummary)1 File (java.io.File)1 IOException (java.io.IOException)1 Map (java.util.Map)1 Optional (java.util.Optional)1 AmazonPersonalizeConnection (org.knime.cloud.aws.mlservices.nodes.personalize.AmazonPersonalizeConnection)1 AmazonPersonalizeUtils (org.knime.cloud.aws.mlservices.utils.personalize.AmazonPersonalizeUtils)1