Search in sources :

Example 1 with ModelProcessor

use of com.hortonworks.streamline.streams.layout.component.impl.model.ModelProcessor in project streamline by hortonworks.

the class StreamlineJPMMLModelRunnerFactory method newModelRunner.

@Override
public ModelRunner newModelRunner() {
    final ModelProcessor modelProcessor = Utils.createObjectFromJson(modelProcessorJson, ModelProcessor.class);
    PMML pmmlModel;
    try {
        pmmlModel = JpmmlFactory.newPmml(new ByteArrayInputStream(modelProcessor.getPmml().getBytes()));
    } catch (Exception e) {
        throw new RuntimeException("Exception occurred while creating PMML model object", e);
    }
    return new StreamlineJPMMLModelRunner(modelProcessor.getOutputStreams(), modelProcessor.getId(), JpmmlFactory.newEvaluator(pmmlModel), modelOutputs);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ModelProcessor(com.hortonworks.streamline.streams.layout.component.impl.model.ModelProcessor) PMML(org.dmg.pmml.PMML)

Example 2 with ModelProcessor

use of com.hortonworks.streamline.streams.layout.component.impl.model.ModelProcessor in project streamline by hortonworks.

the class TopologyComponentFactory method modelProcessorProvider.

private Map.Entry<String, Provider<StreamlineProcessor>> modelProcessorProvider() {
    Provider<StreamlineProcessor> provider = new Provider<StreamlineProcessor>() {

        @Override
        public StreamlineProcessor create(TopologyComponent component) {
            String modelName = component.getConfig().getString(ModelProcessor.CONFIG_MODEL_NAME, StringUtils.EMPTY);
            ModelProcessor modelProcessor = new ModelProcessor();
            if (!modelName.equals(StringUtils.EMPTY)) {
                modelProcessor.setPmml(modelRegistryClient.getMLModelContents(modelName));
            }
            return modelProcessor;
        }
    };
    return new SimpleImmutableEntry<>(PMML, provider);
}
Also used : TopologyComponent(com.hortonworks.streamline.streams.catalog.TopologyComponent) StreamlineProcessor(com.hortonworks.streamline.streams.layout.component.StreamlineProcessor) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) ModelProcessor(com.hortonworks.streamline.streams.layout.component.impl.model.ModelProcessor)

Example 3 with ModelProcessor

use of com.hortonworks.streamline.streams.layout.component.impl.model.ModelProcessor in project streamline by hortonworks.

the class MLModelEvaluationFluxComponent method modelProcessorJson.

private String modelProcessorJson() {
    final ModelProcessor modelProcessorUI = (ModelProcessor) conf.get(StormTopologyLayoutConstants.STREAMLINE_COMPONENT_CONF_KEY);
    ObjectMapper mapper = new ObjectMapper();
    String modelProcessorJson;
    try {
        modelProcessorJson = mapper.writeValueAsString(modelProcessorUI);
    } catch (JsonProcessingException e) {
        throw new RuntimeException("Error creating JSON config string for ML ModelProcessor", e);
    }
    LOG.debug("Created ML ModelProcessor JSON config [{}]", modelProcessorJson);
    return modelProcessorJson;
}
Also used : ModelProcessor(com.hortonworks.streamline.streams.layout.component.impl.model.ModelProcessor) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ModelProcessor (com.hortonworks.streamline.streams.layout.component.impl.model.ModelProcessor)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 TopologyComponent (com.hortonworks.streamline.streams.catalog.TopologyComponent)1 StreamlineProcessor (com.hortonworks.streamline.streams.layout.component.StreamlineProcessor)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 SimpleImmutableEntry (java.util.AbstractMap.SimpleImmutableEntry)1 PMML (org.dmg.pmml.PMML)1