Search in sources :

Example 1 with ConnectionInformationPortObjectSpec

use of org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec in project knime-cloud by knime.

the class BaseComprehendNodeModel method createStreamableOperator.

@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    final DataTableSpec spec = (DataTableSpec) inSpecs[DATA_PORT_IDX];
    final ConnectionInformationPortObjectSpec cnxSpec = (ConnectionInformationPortObjectSpec) inSpecs[CNX_PORT_IDX];
    final int textColIdx = spec.findColumnIndex(m_textColumnName.getStringValue());
    final CloudConnectionInformation cxnInfo = (CloudConnectionInformation) cnxSpec.getConnectionInformation();
    final ComprehendOperation op = getOperationInstance(cxnInfo, generateOutputTableSpec(((DataTableSpec) inSpecs[DATA_PORT_IDX])), m_textColumnName.getStringValue());
    return new StreamableOperator() {

        @Override
        public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
            final RowInput input = (RowInput) inputs[DATA_PORT_IDX];
            final RowOutput output = (RowOutput) outputs[0];
            final ComprehendConnection connection = new ComprehendConnection(cxnInfo);
            final AmazonComprehend comprehendClient = connection.getClient();
            op.compute(input, output, comprehendClient, textColIdx, exec, 0L);
            input.close();
            output.close();
        }
    };
}
Also used : ConnectionInformationPortObjectSpec(org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec) DataTableSpec(org.knime.core.data.DataTableSpec) RowOutput(org.knime.core.node.streamable.RowOutput) ExecutionContext(org.knime.core.node.ExecutionContext) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) AmazonComprehend(com.amazonaws.services.comprehend.AmazonComprehend) CloudConnectionInformation(org.knime.cloud.core.util.port.CloudConnectionInformation) RowInput(org.knime.core.node.streamable.RowInput)

Example 2 with ConnectionInformationPortObjectSpec

use of org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec in project knime-cloud by knime.

the class TranslateNodeModel method createStreamableOperator.

@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    final DataTableSpec dataSpec = (DataTableSpec) inSpecs[DATA_PORT_IDX];
    final ConnectionInformationPortObjectSpec cnxSpec = (ConnectionInformationPortObjectSpec) inSpecs[CNX_PORT_IDX];
    final CloudConnectionInformation cxnInfo = (CloudConnectionInformation) cnxSpec.getConnectionInformation();
    final TranslateOperation translateOp = new TranslateOperation(cxnInfo, m_textColumnName.getStringValue(), TranslateUtils.getTargetLanguageMap().getOrDefault(m_sourceLanguage.getStringValue(), "auto"), TranslateUtils.getSourceLanguageMap().getOrDefault(m_targetLanguage.getStringValue(), "en"), createNewDataTableSpec(dataSpec));
    return new StreamableOperator() {

        @Override
        public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
            RowInput input = (RowInput) inputs[1];
            RowOutput output = (RowOutput) outputs[0];
            translateOp.compute(input, output, exec, 0L);
            input.close();
            output.close();
        }
    };
}
Also used : ConnectionInformationPortObjectSpec(org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec) DataTableSpec(org.knime.core.data.DataTableSpec) RowOutput(org.knime.core.node.streamable.RowOutput) ExecutionContext(org.knime.core.node.ExecutionContext) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) CloudConnectionInformation(org.knime.cloud.core.util.port.CloudConnectionInformation) RowInput(org.knime.core.node.streamable.RowInput)

Example 3 with ConnectionInformationPortObjectSpec

use of org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec in project knime-cloud by knime.

the class TranslateNodeModel method configure.

@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    if (inSpecs[CNX_PORT_IDX] != null) {
        final ConnectionInformationPortObjectSpec object = (ConnectionInformationPortObjectSpec) inSpecs[CNX_PORT_IDX];
        final ConnectionInformation cxnInfo = object.getConnectionInformation();
        // Check if the port object has connection information
        if (cxnInfo == null) {
            throw new InvalidSettingsException("No connection information available");
        }
        if (!ConnectionUtils.regionSupported(cxnInfo.getHost(), AmazonTranslate.ENDPOINT_PREFIX)) {
            throw new InvalidSettingsException("Unsupported region for the Amazon Translate service: " + cxnInfo.getHost());
        }
    } else {
        throw new InvalidSettingsException("No connection information available");
    }
    TranslateUtils.checkPair(m_sourceLanguage.getStringValue(), m_targetLanguage.getStringValue());
    final DataTableSpec tblSpec = (DataTableSpec) inSpecs[DATA_PORT_IDX];
    checkDataTableSpec(tblSpec);
    return new DataTableSpec[] { createNewDataTableSpec(tblSpec) };
}
Also used : ConnectionInformationPortObjectSpec(org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec) CloudConnectionInformation(org.knime.cloud.core.util.port.CloudConnectionInformation) ConnectionInformation(org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformation) DataTableSpec(org.knime.core.data.DataTableSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Example 4 with ConnectionInformationPortObjectSpec

use of org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec in project knime-cloud by knime.

the class S3FilePickerNodeDialog method checkConnectionInformation.

/**
 * {@inheritDoc}
 */
@Override
protected void checkConnectionInformation(PortObjectSpec spec) throws NotConfigurableException {
    if (spec != null) {
        final ConnectionInformationPortObjectSpec object = (ConnectionInformationPortObjectSpec) spec;
        final ConnectionInformation connectionInformation = object.getConnectionInformation();
        // Check if the port object has connection information
        if (connectionInformation == null || !connectionInformation.getProtocol().equals(AmazonS3.ENDPOINT_PREFIX)) {
            throw new NotConfigurableException("No S3 connection information is available");
        }
        m_connectionInformation = connectionInformation;
    } else {
        throw new NotConfigurableException("No S3 connection information available");
    }
}
Also used : ConnectionInformationPortObjectSpec(org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec) NotConfigurableException(org.knime.core.node.NotConfigurableException) ConnectionInformation(org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformation)

Example 5 with ConnectionInformationPortObjectSpec

use of org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec in project knime-cloud by knime.

the class AbstractFilePickerNodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    if (inSpecs[0] != null) {
        final ConnectionInformationPortObjectSpec object = (ConnectionInformationPortObjectSpec) inSpecs[0];
        m_connectionInformation = object.getConnectionInformation();
        // Check if the port object has connection information
        if (m_connectionInformation == null || !m_connectionInformation.getProtocol().equals(getEndpointPrefix())) {
            throw new InvalidSettingsException("No " + getEndpointPrefix() + " connection information available");
        }
    } else {
        throw new InvalidSettingsException("No " + getEndpointPrefix() + "connection information available");
    }
    /*
		 * Validate the selected file. The file cannot be empty, must start with
		 * "/", cannot end with "/" and must have at least two "/" which
		 * indicates that at least the bucket path is defined
		 */
    if (StringUtils.isBlank(m_fileSelection) || !m_fileSelection.startsWith("/") || m_fileSelection.endsWith("/") || m_fileSelection.indexOf("/", 1) < 0) {
        throw new InvalidSettingsException("The selected file is not valid");
    }
    if (m_expirationModel.getExpirationMode().equals(ExpirationMode.DATE.name()) && m_expirationModel.getDate().before(new Date())) {
        throw new InvalidSettingsException("Expiration time: " + m_expirationModel.getDate().toString() + " is in the past. (" + new Date().toString() + ")");
    }
    getLogger().debug("Current Time Configure: " + new Date());
    return new PortObjectSpec[] { FlowVariablePortObjectSpec.INSTANCE };
}
Also used : ConnectionInformationPortObjectSpec(org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ConnectionInformationPortObjectSpec(org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) FlowVariablePortObjectSpec(org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec) Date(java.util.Date)

Aggregations

ConnectionInformationPortObjectSpec (org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformationPortObjectSpec)11 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)7 CloudConnectionInformation (org.knime.cloud.core.util.port.CloudConnectionInformation)5 DataTableSpec (org.knime.core.data.DataTableSpec)5 NotConfigurableException (org.knime.core.node.NotConfigurableException)4 ConnectionInformation (org.knime.base.filehandling.remote.connectioninformation.port.ConnectionInformation)3 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)3 AmazonPersonalize (com.amazonaws.services.personalize.AmazonPersonalize)2 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2 AmazonPersonalizeConnection (org.knime.cloud.aws.mlservices.nodes.personalize.AmazonPersonalizeConnection)2 ExecutionContext (org.knime.core.node.ExecutionContext)2 RowInput (org.knime.core.node.streamable.RowInput)2 RowOutput (org.knime.core.node.streamable.RowOutput)2 StreamableOperator (org.knime.core.node.streamable.StreamableOperator)2 AmazonComprehend (com.amazonaws.services.comprehend.AmazonComprehend)1 AmazonIdentityManagementException (com.amazonaws.services.identitymanagement.model.AmazonIdentityManagementException)1 DescribeCampaignRequest (com.amazonaws.services.personalize.model.DescribeCampaignRequest)1 DescribeRecipeRequest (com.amazonaws.services.personalize.model.DescribeRecipeRequest)1 DescribeSolutionVersionRequest (com.amazonaws.services.personalize.model.DescribeSolutionVersionRequest)1 GridBagConstraints (java.awt.GridBagConstraints)1