Search in sources :

Example 1 with ExceptionMessage

use of ml.shifu.shifu.message.ExceptionMessage in project shifu by ShifuML.

the class EvalModelActor 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();
        log.debug("Num of Scanners: " + scanners.size());
        int streamId = 0;
        for (Scanner scanner : scanners) {
            dataLoadRef.tell(new ScanEvalDataMessage(streamId++, scanners.size(), scanner), getSelf());
        }
    } else if (message instanceof EvalResultMessage) {
        EvalResultMessage msg = (EvalResultMessage) message;
        resultCnt++;
        if (resultCnt == msg.getTotalMsgCnt()) {
            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);
    }
}
Also used : AkkaActorInputMessage(ml.shifu.shifu.message.AkkaActorInputMessage) Scanner(java.util.Scanner) EvalResultMessage(ml.shifu.shifu.message.EvalResultMessage) ExceptionMessage(ml.shifu.shifu.message.ExceptionMessage) ScanEvalDataMessage(ml.shifu.shifu.message.ScanEvalDataMessage)

Example 2 with ExceptionMessage

use of ml.shifu.shifu.message.ExceptionMessage 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();
        log.debug("Num of Scanners: " + scanners.size());
        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);
    }
}
Also used : AkkaActorInputMessage(ml.shifu.shifu.message.AkkaActorInputMessage) Scanner(java.util.Scanner) ExceptionMessage(ml.shifu.shifu.message.ExceptionMessage) NormResultDataMessage(ml.shifu.shifu.message.NormResultDataMessage) ScanNormInputDataMessage(ml.shifu.shifu.message.ScanNormInputDataMessage)

Example 3 with ExceptionMessage

use of ml.shifu.shifu.message.ExceptionMessage in project shifu by ShifuML.

the class PostTrainActor 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();
        log.debug("Num of Scanners: " + scanners.size());
        int streamId = 0;
        for (Scanner scanner : scanners) {
            dataLoadRef.tell(new ScanEvalDataMessage(streamId++, scanners.size(), scanner), getSelf());
        }
    } else if (message instanceof StatsResultMessage) {
        StatsResultMessage statsRstMsg = (StatsResultMessage) message;
        ColumnConfig columnConfig = statsRstMsg.getColumnConfig();
        columnConfigList.set(columnConfig.getColumnNum(), columnConfig);
        resultCnt++;
        log.debug("Received " + resultCnt + " messages, expected message count is:" + expectedResultCnt);
        if (resultCnt == expectedResultCnt) {
            log.info("Finished post-train.");
            PathFinder pathFinder = new PathFinder(modelConfig);
            JSONUtils.writeValue(new File(pathFinder.getColumnConfigPath()), columnConfigList);
            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);
    }
}
Also used : AkkaActorInputMessage(ml.shifu.shifu.message.AkkaActorInputMessage) Scanner(java.util.Scanner) ExceptionMessage(ml.shifu.shifu.message.ExceptionMessage) ColumnConfig(ml.shifu.shifu.container.obj.ColumnConfig) StatsResultMessage(ml.shifu.shifu.message.StatsResultMessage) ScanEvalDataMessage(ml.shifu.shifu.message.ScanEvalDataMessage) PathFinder(ml.shifu.shifu.fs.PathFinder) File(java.io.File)

Example 4 with ExceptionMessage

use of ml.shifu.shifu.message.ExceptionMessage in project shifu by ShifuML.

the class TrainDtModelActor 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();
        log.debug("Num of Scanners: " + scanners.size());
        for (Scanner scanner : scanners) {
            dataLoadRef.tell(new ScanStatsRawDataMessage(scanners.size(), scanner), getSelf());
        }
    } else if (message instanceof TrainResultMessage) {
        resultCnt++;
        if (resultCnt == trainerCnt) {
            log.info("Received " + resultCnt + " finish message. Close System.");
            Encog.getInstance().shutdown();
            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);
    }
}
Also used : AkkaActorInputMessage(ml.shifu.shifu.message.AkkaActorInputMessage) Scanner(java.util.Scanner) ExceptionMessage(ml.shifu.shifu.message.ExceptionMessage) TrainResultMessage(ml.shifu.shifu.message.TrainResultMessage) ScanStatsRawDataMessage(ml.shifu.shifu.message.ScanStatsRawDataMessage)

Example 5 with ExceptionMessage

use of ml.shifu.shifu.message.ExceptionMessage in project shifu by ShifuML.

the class TrainModelActor 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();
        log.debug("Num of Scanners: " + scanners.size());
        for (Scanner scanner : scanners) {
            dataLoadRef.tell(new ScanTrainDataMessage(scanners.size(), isDryRun, scanner), getSelf());
        }
    } else if (message instanceof TrainResultMessage) {
        resultCnt++;
        if (resultCnt == trainerCnt) {
            log.info("Received " + resultCnt + " finish message. Close System.");
            Encog.getInstance().shutdown();
            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);
    }
}
Also used : AkkaActorInputMessage(ml.shifu.shifu.message.AkkaActorInputMessage) Scanner(java.util.Scanner) ExceptionMessage(ml.shifu.shifu.message.ExceptionMessage) ScanTrainDataMessage(ml.shifu.shifu.message.ScanTrainDataMessage) TrainResultMessage(ml.shifu.shifu.message.TrainResultMessage)

Aggregations

Scanner (java.util.Scanner)6 AkkaActorInputMessage (ml.shifu.shifu.message.AkkaActorInputMessage)6 ExceptionMessage (ml.shifu.shifu.message.ExceptionMessage)6 File (java.io.File)2 ColumnConfig (ml.shifu.shifu.container.obj.ColumnConfig)2 PathFinder (ml.shifu.shifu.fs.PathFinder)2 ScanEvalDataMessage (ml.shifu.shifu.message.ScanEvalDataMessage)2 ScanStatsRawDataMessage (ml.shifu.shifu.message.ScanStatsRawDataMessage)2 StatsResultMessage (ml.shifu.shifu.message.StatsResultMessage)2 TrainResultMessage (ml.shifu.shifu.message.TrainResultMessage)2 EvalResultMessage (ml.shifu.shifu.message.EvalResultMessage)1 NormResultDataMessage (ml.shifu.shifu.message.NormResultDataMessage)1 ScanNormInputDataMessage (ml.shifu.shifu.message.ScanNormInputDataMessage)1 ScanTrainDataMessage (ml.shifu.shifu.message.ScanTrainDataMessage)1