use of com.amazonaws.services.personalize.model.DatasetSummary in project knime-cloud by knime.
the class AbstractAmazonPersonalizeDataUploadNodeModel method deleteDataset.
private void deleteDataset(final AmazonPersonalize personalizeClient, final String datasetGroupArn, final String datasetARN) throws InterruptedException {
personalizeClient.deleteDataset(new DeleteDatasetRequest().withDatasetArn(datasetARN));
final ListDatasetsRequest listDatasetsRequest = new ListDatasetsRequest().withDatasetGroupArn(datasetGroupArn);
AmazonPersonalizeUtils.waitUntilActive(() -> {
final List<DatasetSummary> datasets = personalizeClient.listDatasets(listDatasetsRequest).getDatasets();
return !datasets.stream().anyMatch(e -> e.getDatasetType().equals(m_datasetType));
}, 500);
}
use of com.amazonaws.services.personalize.model.DatasetSummary in project knime-cloud by knime.
the class AbstractAmazonPersonalizeDataUploadNodeModel method checkAlreadyExistingDataset.
private void checkAlreadyExistingDataset(final AmazonPersonalize personalizeClient, final String datasetGroupArn, final ExecutionContext exec) throws InterruptedException {
exec.setMessage("Checking already existing datasets");
final ListDatasetsResult listDatasets = personalizeClient.listDatasets(new ListDatasetsRequest().withDatasetGroupArn(datasetGroupArn));
final Optional<DatasetSummary> dataset = listDatasets.getDatasets().stream().filter(e -> e.getDatasetType().equals(m_datasetType)).findFirst();
if (dataset.isPresent()) {
if (m_settings.getOverwriteDatasetPolicy().equals(OverwritePolicy.ABORT.toString())) {
// Abort if dataset already exists
throw new IllegalStateException("A dataset of type '" + getDatasetType() + "' already exists. Either choose a different dataset group or select to overwrite the existing " + "dataset.");
} else {
// Delete the existing dataset
exec.setMessage("Deleting existing dataset");
deleteDataset(personalizeClient, datasetGroupArn, dataset.get().getDatasetArn());
}
}
exec.setProgress(1);
}
Aggregations