Search in sources :

Example 41 with Stage

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

the class SimpleLsfExecutorSubmitCmdTest method cmdNoMemUnitsNoDuration.

@Test
public void cmdNoMemUnitsNoDuration() throws IOException {
    SimpleLsfExecutor executor = new SimpleLsfExecutor();
    executor.setCmd("test");
    SimpleLsfExecutorParameters params = SimpleLsfExecutorParameters.builder().logDir(Files.createTempDirectory("TEMP").toString()).cpu(2).memory(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 1 -R \"rusage[mem=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 42 with Stage

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

the class SimpleLsfExecutorSubmitCmdTest method cmdJobGroup.

@Test
public void cmdJobGroup() throws IOException {
    SimpleLsfExecutor executor = new SimpleLsfExecutor();
    executor.setCmd("test");
    SimpleLsfExecutorParameters params = SimpleLsfExecutorParameters.builder().logDir(Files.createTempDirectory("TEMP").toString()).cpu(2).jobGroup("testGroup").timeout(Duration.ofMinutes(1)).queue("TEST").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 -W 1 -g testGroup -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 43 with Stage

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

the class SshCmdExecutorTest method test.

@Test
@EnabledIfEnvironmentVariable(named = "PIPELITE_TEST_SSH_HOST", matches = ".+")
public void test() {
    String stageName = PipeliteIdCreator.stageName();
    CmdExecutor<CmdExecutorParameters> executor = StageExecutor.createCmdExecutor("echo test");
    executor.setExecutorParams(CmdExecutorParameters.builder().host(sshTestConfiguration.getHost()).user(sshTestConfiguration.getUser()).timeout(Duration.ofSeconds(30)).build());
    Stage stage = Stage.builder().stageName(stageName).executor(executor).build();
    stage.execute(PIPELINE_NAME, PROCESS_ID, (result) -> {
        // Ignore timeout errors.
        if (result.isErrorType(ErrorType.TIMEOUT_ERROR)) {
            return;
        }
        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) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) EnabledIfEnvironmentVariable(org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable)

Example 44 with Stage

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

the class DependencyResolver method getDependentStages.

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

Example 45 with Stage

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

the class DependencyResolver method getDependsOnStagesDirectly.

/**
 * Returns the list of stages that the stage depends on directly.
 *
 * @param process the process
 * @param stage the stage of interest
 * @return the list of stages that the stage depends on directly
 */
public static Set<Stage> getDependsOnStagesDirectly(Process process, Stage stage) {
    Set<Stage> dependsOnStages = new HashSet<>();
    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);
        }
    });
    return 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