Search in sources :

Example 11 with NodeSettingsRO

use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.

the class RandomForestClassificationLearnerNodeModel method loadInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    File file = new File(nodeInternDir, INTERNAL_TREES_FILE);
    if (file.exists()) {
        getLogger().info("Node was executed with KNIME version <2.10 - keep using old model type, re-execute node to update");
        // workflow is older than 2.10
        InputStream in = new GZIPInputStream(new FileInputStream(file));
        m_oldStyleEnsembleModel_deprecated = TreeEnsembleModel.load(in, exec);
        in.close();
    }
    file = new File(nodeInternDir, INTERNAL_DATASAMPLE_FILE);
    if (file.exists()) {
        m_hiliteRowSample = DataContainer.readFromZip(file);
    }
    file = new File(nodeInternDir, INTERNAL_INFO_FILE);
    if (file.exists()) {
        NodeSettingsRO sets = NodeSettings.loadFromXML(new FileInputStream(file));
        m_viewMessage = sets.getString("view_warning", null);
    }
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) GZIPInputStream(java.util.zip.GZIPInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 12 with NodeSettingsRO

use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.

the class RandomForestRegressionLearnerNodeModel method loadInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    File file = new File(nodeInternDir, INTERNAL_TREES_FILE);
    if (file.exists()) {
        getLogger().info("Node was executed with KNIME version <2.10 - keep using old model type, re-execute node to update");
        InputStream in = new GZIPInputStream(new FileInputStream(file));
        m_oldStyleEnsembleModel_deprecated = TreeEnsembleModel.load(in, exec);
        in.close();
    }
    file = new File(nodeInternDir, INTERNAL_DATASAMPLE_FILE);
    if (file.exists()) {
        m_hiliteRowSample = DataContainer.readFromZip(file);
    }
    file = new File(nodeInternDir, INTERNAL_INFO_FILE);
    if (file.exists()) {
        NodeSettingsRO sets = NodeSettings.loadFromXML(new FileInputStream(file));
        m_viewMessage = sets.getString("view_warning", null);
    }
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) GZIPInputStream(java.util.zip.GZIPInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 13 with NodeSettingsRO

use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.

the class RegressionTreeLearnerNodeModel method loadInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    File file = new File(nodeInternDir, INTERNAL_DATASAMPLE_FILE);
    if (file.exists()) {
        m_hiliteRowSample = DataContainer.readFromZip(file);
    }
    file = new File(nodeInternDir, INTERNAL_INFO_FILE);
    if (file.exists()) {
        NodeSettingsRO sets = NodeSettings.loadFromXML(new FileInputStream(file));
        m_viewMessage = sets.getString("view_warning", null);
    }
}
Also used : NodeSettingsRO(org.knime.core.node.NodeSettingsRO) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 14 with NodeSettingsRO

use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.

the class TreeEnsembleClassificationLearnerNodeModel method loadInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    File file = new File(nodeInternDir, INTERNAL_TREES_FILE);
    if (file.exists()) {
        getLogger().info("Node was executed with KNIME version <2.10 - keep using old model type, re-execute node to update");
        // workflow is older than 2.10
        InputStream in = new GZIPInputStream(new FileInputStream(file));
        m_oldStyleEnsembleModel_deprecated = TreeEnsembleModel.load(in, exec);
        in.close();
    }
    file = new File(nodeInternDir, INTERNAL_DATASAMPLE_FILE);
    if (file.exists()) {
        m_hiliteRowSample = DataContainer.readFromZip(file);
    }
    file = new File(nodeInternDir, INTERNAL_INFO_FILE);
    if (file.exists()) {
        NodeSettingsRO sets = NodeSettings.loadFromXML(new FileInputStream(file));
        m_viewMessage = sets.getString("view_warning", null);
    }
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) GZIPInputStream(java.util.zip.GZIPInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 15 with NodeSettingsRO

use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.

the class MissingValueHandling2ColSetting method loadIndividualColSettings.

/**
 * Helper that load individual settings from a config object, used in
 * NodeModel.
 *
 * @param settings to load from
 * @return individual settings
 * @throws InvalidSettingsException if errors occur
 */
protected static MissingValueHandling2ColSetting[] loadIndividualColSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    NodeSettingsRO subConfig = settings.getNodeSettings(CFG_INDIVIDUAL);
    Map<String, MissingValueHandling2ColSetting> map = loadSubConfigs(subConfig);
    return map.values().toArray(new MissingValueHandling2ColSetting[0]);
}
Also used : NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Aggregations

NodeSettingsRO (org.knime.core.node.NodeSettingsRO)208 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)125 File (java.io.File)49 FileInputStream (java.io.FileInputStream)47 IOException (java.io.IOException)43 InputStream (java.io.InputStream)22 LinkedHashMap (java.util.LinkedHashMap)20 NodeSettings (org.knime.core.node.NodeSettings)20 BufferedInputStream (java.io.BufferedInputStream)19 ArrayList (java.util.ArrayList)16 GZIPInputStream (java.util.zip.GZIPInputStream)15 DataTableSpec (org.knime.core.data.DataTableSpec)14 Map (java.util.Map)11 ReferencedFile (org.knime.core.internal.ReferencedFile)11 BufferedDataTable (org.knime.core.node.BufferedDataTable)10 HashMap (java.util.HashMap)9 DataColumnSpec (org.knime.core.data.DataColumnSpec)9 RowKey (org.knime.core.data.RowKey)9 DataType (org.knime.core.data.DataType)8 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)8