Search in sources :

Example 21 with Stage

use of pipelite.stage.Stage in project pipelite by enasequence.

the class RetryServiceTest method retryFailedProcess.

@Test
public void retryFailedProcess() {
    String processId = PipeliteIdCreator.processId();
    RegisteredPipeline registeredPipeline = registeredPipelineService.getRegisteredPipeline(PIPELINE_NAME);
    Process process = ProcessFactory.create(processId, registeredPipeline);
    // Failed process
    process.setProcessEntity(processService.createExecution(PIPELINE_NAME, processId, 1));
    processService.startExecution(process.getProcessEntity());
    ProcessEntity processEntity = processService.endExecution(process, ProcessState.FAILED);
    // Failed stage
    Stage stage = process.getStage(STAGE_NAME).get();
    stageService.createExecution(PIPELINE_NAME, processId, stage);
    stageService.startExecution(stage);
    stageService.endExecution(stage, StageExecutorResult.error());
    StageEntity stageEntity = stage.getStageEntity();
    assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.FAILED);
    assertThat(stageEntity.getStageState()).isEqualTo(StageState.ERROR);
    // Retry
    retryService.retry(PIPELINE_NAME, processId);
    // Check process state
    processEntity = processService.getSavedProcess(PIPELINE_NAME, processId).get();
    assertThat(processEntity.getPipelineName()).isEqualTo(PIPELINE_NAME);
    assertThat(processEntity.getProcessId()).isEqualTo(processId);
    assertThat(processEntity.getStartTime()).isNotNull();
    assertThat(processEntity.getEndTime()).isNull();
    assertThat(processEntity.getProcessState()).isEqualTo(ProcessState.ACTIVE);
    // Check stage state
    stageEntity = stageService.getSavedStage(PIPELINE_NAME, processId, STAGE_NAME).get();
    assertThat(stageEntity.getPipelineName()).isEqualTo(PIPELINE_NAME);
    assertThat(stageEntity.getProcessId()).isEqualTo(processId);
    assertThat(stageEntity.getStageName()).isEqualTo(STAGE_NAME);
    assertThat(stageEntity.getStageState()).isEqualTo(StageState.PENDING);
    assertThat(stageEntity.getStartTime()).isNull();
    assertThat(stageEntity.getEndTime()).isNull();
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity) Stage(pipelite.stage.Stage) Process(pipelite.process.Process) StageEntity(pipelite.entity.StageEntity) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 22 with Stage

use of pipelite.stage.Stage in project pipelite by enasequence.

the class LocalCmdExecutorTest method test.

@Test
public void test() {
    String stageName = PipeliteIdCreator.stageName();
    CmdExecutor<CmdExecutorParameters> executor = StageExecutor.createCmdExecutor("echo test");
    executor.setExecutorParams(CmdExecutorParameters.builder().build());
    Stage stage = Stage.builder().stageName(stageName).executor(executor).build();
    stage.execute(PIPELINE_NAME, PROCESS_ID, (result) -> {
        assertThat(result.isSuccess()).isTrue();
        assertThat(result.getAttribute(StageExecutorResultAttribute.COMMAND)).isEqualTo("echo test");
        assertThat(result.getAttribute(StageExecutorResultAttribute.EXIT_CODE)).isEqualTo("0");
        assertThat(result.getStageLog()).contains("test\n");
    });
}
Also used : Stage(pipelite.stage.Stage) CmdExecutorParameters(pipelite.stage.parameters.CmdExecutorParameters) Test(org.junit.jupiter.api.Test)

Example 23 with Stage

use of pipelite.stage.Stage in project pipelite by enasequence.

the class LsfExecutorSubmitCmdTest method test.

@Test
public void test() throws IOException {
    LsfExecutor executor = new LsfExecutor();
    executor.setCmd("test");
    LsfExecutorParameters params = LsfExecutorParameters.builder().logDir(Files.createTempDirectory("TEMP").toString()).definition("pipelite/executor/lsf.yaml").format(LsfExecutorParameters.Format.YAML).build();
    executor.setExecutorParams(params);
    Stage stage = Stage.builder().stageName(STAGE_NAME).executor(executor).build();
    StageExecutorRequest request = StageExecutorRequest.builder().pipelineName(PIPELINE_NAME).processId(PROCESS_ID).stage(stage).build();
    String definitionFile = params.resolveDefinitionFile(request, LsfFilePathResolver.Format.WITHOUT_LSF_PATTERN);
    String logDir = "\"" + params.resolveLogDir(request, LsfFilePathResolver.Format.WITH_LSF_PATTERN) + "\"";
    String logFileName = params.resolveLogFileName(request);
    executor.setOutFile(params.resolveLogDir(request, LsfFilePathResolver.Format.WITHOUT_LSF_PATTERN));
    executor.setDefinitionFile(definitionFile);
    String submitCmd = executor.getSubmitCmd(request);
    assertThat(submitCmd).isEqualTo("bsub" + " -outdir " + logDir + " -cwd " + logDir + " -oo " + logFileName + " -yaml " + definitionFile + " test");
}
Also used : StageExecutorRequest(pipelite.stage.executor.StageExecutorRequest) LsfExecutorParameters(pipelite.stage.parameters.LsfExecutorParameters) Stage(pipelite.stage.Stage) Test(org.junit.jupiter.api.Test)

Example 24 with Stage

use of pipelite.stage.Stage in project pipelite by enasequence.

the class SimpleLsfExecutorSubmitCmdTest method cmdMemUnitsM.

@Test
public void cmdMemUnitsM() throws IOException {
    SimpleLsfExecutor executor = new SimpleLsfExecutor();
    executor.setCmd("test");
    SimpleLsfExecutorParameters params = SimpleLsfExecutorParameters.builder().logDir(Files.createTempDirectory("TEMP").toString()).cpu(2).memory(1).memoryUnits("M").memoryTimeout(Duration.ofMinutes(1)).queue("TEST").timeout(Duration.ofMinutes(1)).build();
    executor.setExecutorParams(params);
    Stage stage = Stage.builder().stageName(STAGE_NAME).executor(executor).build();
    StageExecutorRequest request = StageExecutorRequest.builder().pipelineName(PIPELINE_NAME).processId(PROCESS_ID).stage(stage).build();
    String logDir = "\"" + params.resolveLogDir(request, LsfFilePathResolver.Format.WITH_LSF_PATTERN) + "\"";
    String logFileName = params.resolveLogFileName(request);
    executor.setOutFile(params.resolveLogDir(request, LsfFilePathResolver.Format.WITHOUT_LSF_PATTERN));
    String submitCmd = executor.getSubmitCmd(request);
    assertThat(submitCmd).isEqualTo("bsub" + " -outdir " + logDir + " -cwd " + logDir + " -oo " + logFileName + " -n 2 -M 1M -R \"rusage[mem=1M:duration=1]\" -W 1 -q TEST test");
}
Also used : StageExecutorRequest(pipelite.stage.executor.StageExecutorRequest) Stage(pipelite.stage.Stage) SimpleLsfExecutorParameters(pipelite.stage.parameters.SimpleLsfExecutorParameters) Test(org.junit.jupiter.api.Test)

Example 25 with Stage

use of pipelite.stage.Stage in project pipelite by enasequence.

the class DependencyResolver method getDependsOnStages.

private static void getDependsOnStages(Process process, Stage stage, Set<Stage> dependsOnStages) {
    process.getStageGraph().edgesOf(stage).forEach(e -> {
        Stage edgeSource = process.getStageGraph().getEdgeSource(e);
        Stage edgeTarget = process.getStageGraph().getEdgeTarget(e);
        if (edgeTarget.equals(stage)) {
            dependsOnStages.add(edgeSource);
            getDependsOnStages(process, edgeSource, dependsOnStages);
        }
    });
}
Also used : Stage(pipelite.stage.Stage)

Aggregations

Stage (pipelite.stage.Stage)62 Test (org.junit.jupiter.api.Test)49 Process (pipelite.process.Process)28 ProcessBuilder (pipelite.process.builder.ProcessBuilder)21 StageEntity (pipelite.entity.StageEntity)15 StageState (pipelite.stage.StageState)15 StageExecutorRequest (pipelite.stage.executor.StageExecutorRequest)13 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 ProcessEntity (pipelite.entity.ProcessEntity)9 SimpleLsfExecutorParameters (pipelite.stage.parameters.SimpleLsfExecutorParameters)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 StageExecutorResult (pipelite.stage.executor.StageExecutorResult)6 StageLogEntity (pipelite.entity.StageLogEntity)5 ExecutorParameters (pipelite.stage.parameters.ExecutorParameters)3 ZonedDateTime (java.time.ZonedDateTime)2 Flogger (lombok.extern.flogger.Flogger)2 InternalErrorHandler (pipelite.error.InternalErrorHandler)2 SimpleLsfExecutor (pipelite.executor.SimpleLsfExecutor)2 SyncTestExecutor (pipelite.executor.SyncTestExecutor)2 ProcessState (pipelite.process.ProcessState)2