use of ml.shifu.shifu.message.AkkaActorInputMessage in project shifu by ShifuML.
the class NormalizeDataActor method onReceive.
/*
* (non-Javadoc)
*
* @see akka.actor.UntypedActor#onReceive(java.lang.Object)
*/
@Override
public void onReceive(Object message) throws Exception {
if (message instanceof AkkaActorInputMessage) {
resultCnt = 0;
AkkaActorInputMessage msg = (AkkaActorInputMessage) message;
List<Scanner> scanners = msg.getScanners();
for (Scanner scanner : scanners) {
dataLoadRef.tell(new ScanNormInputDataMessage(scanners.size(), scanner), getSelf());
}
} else if (message instanceof NormResultDataMessage) {
NormResultDataMessage msg = (NormResultDataMessage) message;
int targetMsgCnt = msg.getTargetMsgCnt();
writeDataIntoFile(msg.getNormalizedDataList());
writeSelectDataIntoFile(msg.getSelectDataList());
resultCnt++;
if (resultCnt == targetMsgCnt) {
log.info("Received " + resultCnt + " messages. Finished normalizing train data.");
normDataWriter.close();
selectDataWriter.close();
getContext().system().shutdown();
}
} else if (message instanceof ExceptionMessage) {
// since some children actors meet some exception, shutdown the system
ExceptionMessage msg = (ExceptionMessage) message;
getContext().system().shutdown();
// and wrapper the exception into Return status
addExceptionIntoCondition(msg.getException());
} else {
unhandled(message);
}
}
use of ml.shifu.shifu.message.AkkaActorInputMessage in project shifu by ShifuML.
the class AkkaSystemExecutor method submitPostTrainJob.
/**
* Submit job to post-train the model
*
* @param modelConfig
* - configuration for model
* @param columnConfigList
* - configurations for columns
* @param scanners
* - scanners of select data that are normalized
*/
public void submitPostTrainJob(final ModelConfig modelConfig, final List<ColumnConfig> columnConfigList, List<Scanner> scanners) {
actorSystem = ActorSystem.create("ShifuActorSystem");
final AkkaExecStatus akkaStatus = new AkkaExecStatus(true);
log.info("Create Akka system to post-train model");
ActorRef postTrainerRef = actorSystem.actorOf(new Props(new UntypedActorFactory() {
private static final long serialVersionUID = -1437127862571741369L;
public UntypedActor create() {
return new PostTrainActor(modelConfig, columnConfigList, akkaStatus);
}
}), "model-posttrainer");
postTrainerRef.tell(new AkkaActorInputMessage(scanners), postTrainerRef);
// wait for termination
actorSystem.awaitTermination();
checkAkkaStatus(akkaStatus);
}
use of ml.shifu.shifu.message.AkkaActorInputMessage in project shifu by ShifuML.
the class AkkaSystemExecutor method submitModelTrainJob.
/**
* Submit job to training model
*
* @param modelConfig
* - configuration for model
* @param columnConfigList
* - configurations for columns
* @param scanners
* - scanners of normalized training data
* @param trainers
* - model trainer
*/
public void submitModelTrainJob(final ModelConfig modelConfig, final List<ColumnConfig> columnConfigList, List<Scanner> scanners, final List<AbstractTrainer> trainers) {
actorSystem = ActorSystem.create("ShifuActorSystem");
final AkkaExecStatus akkaStatus = new AkkaExecStatus(true);
log.info("Create Akka system to train model");
ActorRef modelTrainerRef = actorSystem.actorOf(new Props(new UntypedActorFactory() {
private static final long serialVersionUID = -1437127862571741369L;
public UntypedActor create() {
return new TrainModelActor(modelConfig, columnConfigList, akkaStatus, trainers);
}
}), "model-trainer");
modelTrainerRef.tell(new AkkaActorInputMessage(scanners), modelTrainerRef);
// wait for termination
actorSystem.awaitTermination();
checkAkkaStatus(akkaStatus);
}
use of ml.shifu.shifu.message.AkkaActorInputMessage in project shifu by ShifuML.
the class AkkaSystemExecutor method submitModelEvalJob.
/**
* Submit job to run model evaluation
*
* @param modelConfig
* - configuration for model
* @param columnConfigList
* - configurations for columns
* @param evalConfig
* the eval config instance
* @param scanners
* - scanners of evaluation data
*/
public void submitModelEvalJob(final ModelConfig modelConfig, final List<ColumnConfig> columnConfigList, final EvalConfig evalConfig, List<Scanner> scanners) {
actorSystem = ActorSystem.create("ShifuActorSystem");
final AkkaExecStatus akkaStatus = new AkkaExecStatus(true);
log.info("Create Akka system to evaluate model");
ActorRef modelEvalRef = actorSystem.actorOf(new Props(new UntypedActorFactory() {
private static final long serialVersionUID = -1437127862571741369L;
public UntypedActor create() {
return new EvalModelActor(modelConfig, columnConfigList, akkaStatus, evalConfig);
}
}), "model-evaluator");
modelEvalRef.tell(new AkkaActorInputMessage(scanners), modelEvalRef);
// wait for termination
actorSystem.awaitTermination();
checkAkkaStatus(akkaStatus);
}
use of ml.shifu.shifu.message.AkkaActorInputMessage in project shifu by ShifuML.
the class AkkaSystemExecutor method submitNormalizeJob.
/**
* Submit job to normalize training data
*
* @param modelConfig
* - configuration for model
* @param columnConfigList
* - configurations for columns
* @param scanners
* - scanners of training data
*/
public void submitNormalizeJob(final ModelConfig modelConfig, final List<ColumnConfig> columnConfigList, List<Scanner> scanners) {
actorSystem = ActorSystem.create("ShifuActorSystem");
final AkkaExecStatus akkaStatus = new AkkaExecStatus(true);
log.info("Create Akka system to normalize data");
ActorRef dataNormalizeRef = actorSystem.actorOf(new Props(new UntypedActorFactory() {
private static final long serialVersionUID = -2123098236012879296L;
public UntypedActor create() throws IOException {
return new NormalizeDataActor(modelConfig, columnConfigList, akkaStatus);
}
}), "data-normalizer");
dataNormalizeRef.tell(new AkkaActorInputMessage(scanners), dataNormalizeRef);
// wait for termination
actorSystem.awaitTermination();
checkAkkaStatus(akkaStatus);
}
Aggregations