Search in sources :

Example 1 with UntypedActorFactory

use of akka.actor.UntypedActorFactory in project shifu by ShifuML.

the class CalculateStatsActorTest method testActor.

// @Test
public void testActor() throws IOException, InterruptedException {
    ActorRef statsCalRef = actorSystem.actorOf(new Props(new UntypedActorFactory() {

        private static final long serialVersionUID = 6777309320338075269L;

        public UntypedActor create() {
            return new CalculateStatsActor(modelConfig, columnConfigList, new AkkaExecStatus(true));
        }
    }), "stats-calculator");
    List<Scanner> scanners = ShifuFileUtils.getDataScanners("src/test/resources/example/cancer-judgement/DataStore/DataSet1", SourceType.LOCAL);
    statsCalRef.tell(new AkkaActorInputMessage(scanners), statsCalRef);
    while (!statsCalRef.isTerminated()) {
        Thread.sleep(5000);
    }
    File file = new File("./ColumnConfig.json");
    Assert.assertTrue(file.exists());
}
Also used : Scanner(java.util.Scanner) AkkaActorInputMessage(ml.shifu.shifu.message.AkkaActorInputMessage) UntypedActorFactory(akka.actor.UntypedActorFactory) ActorRef(akka.actor.ActorRef) Props(akka.actor.Props) File(java.io.File)

Example 2 with UntypedActorFactory

use of akka.actor.UntypedActorFactory in project shifu by ShifuML.

the class EvalModelActorTest method testActor.

// @Test
public void testActor() throws IOException, InterruptedException {
    Environment.setProperty(Environment.SHIFU_HOME, ".");
    File tmpModels = new File("models");
    File tmpCommon = new File("common");
    File models = new File("src/test/resources/example/cancer-judgement/ModelStore/ModelSet1/models");
    FileUtils.copyDirectory(models, tmpModels);
    File tmpEvalA = new File("evals");
    FileUtils.forceMkdir(tmpEvalA);
    ActorRef modelEvalRef = actorSystem.actorOf(new Props(new UntypedActorFactory() {

        private static final long serialVersionUID = -1437127862571741369L;

        public UntypedActor create() {
            return new EvalModelActor(modelConfig, columnConfigList, new AkkaExecStatus(true), evalConfig);
        }
    }), "model-evaluator");
    List<Scanner> scanners = ShifuFileUtils.getDataScanners("src/test/resources/example/cancer-judgement/DataStore/EvalSet1", SourceType.LOCAL);
    modelEvalRef.tell(new AkkaActorInputMessage(scanners), modelEvalRef);
    while (!modelEvalRef.isTerminated()) {
        Thread.sleep(5000);
    }
    File outputFile = new File("evals/EvalA/EvalScore");
    Assert.assertTrue(outputFile.exists());
    FileUtils.deleteDirectory(tmpModels);
    FileUtils.deleteDirectory(tmpCommon);
    FileUtils.deleteDirectory(tmpEvalA);
}
Also used : Scanner(java.util.Scanner) AkkaActorInputMessage(ml.shifu.shifu.message.AkkaActorInputMessage) UntypedActorFactory(akka.actor.UntypedActorFactory) ActorRef(akka.actor.ActorRef) Props(akka.actor.Props) File(java.io.File)

Example 3 with UntypedActorFactory

use of akka.actor.UntypedActorFactory in project shifu by ShifuML.

the class PostTrainActorTest method testActor.

// @Test
public void testActor() throws IOException, InterruptedException {
    File tmpModels = new File("models");
    File tmpCommon = new File("common");
    File models = new File("src/test/resources/example/cancer-judgement/ModelStore/ModelSet1/models");
    FileUtils.copyDirectory(models, tmpModels);
    ActorRef postTrainRef = actorSystem.actorOf(new Props(new UntypedActorFactory() {

        private static final long serialVersionUID = 6777309320338075269L;

        public UntypedActor create() {
            return new PostTrainActor(modelConfig, columnConfigList, new AkkaExecStatus(true));
        }
    }), "post-trainer");
    List<Scanner> scanners = ShifuFileUtils.getDataScanners("src/test/resources/example/cancer-judgement/DataStore/DataSet1", SourceType.LOCAL);
    postTrainRef.tell(new AkkaActorInputMessage(scanners), postTrainRef);
    while (!postTrainRef.isTerminated()) {
        Thread.sleep(5000);
    }
    File file = new File("./ColumnConfig.json");
    Assert.assertTrue(file.exists());
    FileUtils.deleteQuietly(file);
    FileUtils.deleteDirectory(tmpModels);
    FileUtils.deleteDirectory(tmpCommon);
}
Also used : Scanner(java.util.Scanner) AkkaActorInputMessage(ml.shifu.shifu.message.AkkaActorInputMessage) UntypedActorFactory(akka.actor.UntypedActorFactory) ActorRef(akka.actor.ActorRef) Props(akka.actor.Props) File(java.io.File)

Aggregations

ActorRef (akka.actor.ActorRef)3 Props (akka.actor.Props)3 UntypedActorFactory (akka.actor.UntypedActorFactory)3 File (java.io.File)3 Scanner (java.util.Scanner)3 AkkaActorInputMessage (ml.shifu.shifu.message.AkkaActorInputMessage)3