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);
}
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);
}
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;
}
Aggregations