Search in sources :

Example 6 with StageExecutorRequest

use of pipelite.stage.executor.StageExecutorRequest 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 7 with StageExecutorRequest

use of pipelite.stage.executor.StageExecutorRequest 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 8 with StageExecutorRequest

use of pipelite.stage.executor.StageExecutorRequest in project pipelite by enasequence.

the class AsyncExecutorTestHelper method testExecute.

public static void testExecute(AbstractAsyncExecutor<?, ?> executor, PipeliteExecutorService pipeliteExecutorService, DescribeJobsCacheService describeJobsCacheService, PipeliteMetrics pipeliteMetrics, StageExecutorResultCallback assertAfterSubmit, StageExecutorResultCallback assertAfterPoll) {
    String pipelineName = PipeliteIdCreator.pipelineName();
    String processId = PipeliteIdCreator.processId();
    String stageName = PipeliteIdCreator.stageName();
    Stage stage = Stage.builder().stageName(stageName).executor(executor).build();
    StageExecutorRequest request = StageExecutorRequest.builder().pipelineName(pipelineName).processId(processId).stage(stage).build();
    executor.setSubmitExecutorService(pipeliteExecutorService.submitStage());
    executor.setDescribeJobsService(describeJobsCacheService);
    executor.setStageMetrics(pipeliteMetrics.pipeline(pipelineName).stage());
    AtomicReference<StageExecutorResult> result = new AtomicReference<>();
    executor.execute(request, (r) -> result.set(r));
    while (result.get() == null) {
        Time.wait(Duration.ofSeconds(1));
    }
    assertThat(result.get().isSubmitted()).isTrue();
    assertAfterSubmit.accept(result.get());
    while (!result.get().isSuccess() && !result.get().isError()) {
        executor.execute(request, (r) -> result.set(r));
        Time.wait(Duration.ofSeconds(1));
    }
    // Ignore timeout errors.
    if (result.get().isErrorType(ErrorType.TIMEOUT_ERROR)) {
        return;
    }
    assertAfterPoll.accept(result.get());
}
Also used : StageExecutorResult(pipelite.stage.executor.StageExecutorResult) StageExecutorRequest(pipelite.stage.executor.StageExecutorRequest) Stage(pipelite.stage.Stage) AtomicReference(java.util.concurrent.atomic.AtomicReference)

Example 9 with StageExecutorRequest

use of pipelite.stage.executor.StageExecutorRequest in project pipelite by enasequence.

the class LsfExecutorSerializeTest method test.

@Test
public void test() {
    String cmd = "echo test";
    LsfExecutor executor = StageExecutor.createLsfExecutor(cmd);
    Stage stage = Stage.builder().stageName("STAGE_NAME").executor(executor).build();
    StageExecutorRequest request = StageExecutorRequest.builder().pipelineName("PIPELINE_NAME").processId("PROCESS_ID").stage(stage).build();
    LsfExecutorParameters params = LsfExecutorParameters.builder().user("user").logDir("logDir").definitionDir("definitionDir").build();
    LsfFilePathResolver.Format format = LsfFilePathResolver.Format.WITHOUT_LSF_PATTERN;
    executor.setJobId("test");
    executor.setOutFile(new LsfLogFilePathResolver(request, params).getFile(format));
    executor.setDefinitionFile(new LsfDefinitionFilePathResolver(request, params).getFile(format));
    String json = Json.serialize(executor);
    assertThat(json).isEqualTo("{\n" + "  \"jobId\" : \"test\",\n" + "  \"cmd\" : \"echo test\",\n" + "  \"outFile\" : \"logDir/user/PIPELINE_NAME/PROCESS_ID/STAGE_NAME.out\",\n" + "  \"definitionFile\" : \"definitionDir/user/PIPELINE_NAME/PROCESS_ID/STAGE_NAME.job\"\n" + "}");
    LsfExecutor deserializedLsfExecutor = Json.deserialize(json, LsfExecutor.class);
    assertThat(deserializedLsfExecutor.getCmd()).isEqualTo(cmd);
    assertThat(deserializedLsfExecutor.getJobId()).isEqualTo("test");
    assertThat(deserializedLsfExecutor.getOutFile()).isEqualTo("logDir/user/PIPELINE_NAME/PROCESS_ID/STAGE_NAME.out");
    assertThat(deserializedLsfExecutor.getDefinitionFile()).isEqualTo("definitionDir/user/PIPELINE_NAME/PROCESS_ID/STAGE_NAME.job");
}
Also used : LsfDefinitionFilePathResolver(pipelite.stage.path.LsfDefinitionFilePathResolver) StageExecutorRequest(pipelite.stage.executor.StageExecutorRequest) LsfLogFilePathResolver(pipelite.stage.path.LsfLogFilePathResolver) LsfExecutorParameters(pipelite.stage.parameters.LsfExecutorParameters) LsfFilePathResolver(pipelite.stage.path.LsfFilePathResolver) Stage(pipelite.stage.Stage) Test(org.junit.jupiter.api.Test)

Example 10 with StageExecutorRequest

use of pipelite.stage.executor.StageExecutorRequest in project pipelite by enasequence.

the class SimpleLsfExecutorSerializeTest method test.

@Test
public void test() {
    String cmd = "echo test";
    SimpleLsfExecutor executor = StageExecutor.createSimpleLsfExecutor(cmd);
    Stage stage = Stage.builder().stageName("STAGE_NAME").executor(executor).build();
    StageExecutorRequest request = StageExecutorRequest.builder().pipelineName("PIPELINE_NAME").processId("PROCESS_ID").stage(stage).build();
    SimpleLsfExecutorParameters params = SimpleLsfExecutorParameters.builder().user("user").logDir("logDir").build();
    LsfFilePathResolver.Format format = LsfFilePathResolver.Format.WITHOUT_LSF_PATTERN;
    executor.setJobId("test");
    executor.setOutFile(new LsfLogFilePathResolver(request, params).getFile(format));
    String json = Json.serialize(executor);
    assertThat(json).isEqualTo("{\n" + "  \"jobId\" : \"test\",\n" + "  \"cmd\" : \"echo test\",\n" + "  \"outFile\" : \"logDir/user/PIPELINE_NAME/PROCESS_ID/STAGE_NAME.out\"\n" + "}");
    SimpleLsfExecutor deserializedLsfExecutor = Json.deserialize(json, SimpleLsfExecutor.class);
    assertThat(deserializedLsfExecutor.getCmd()).isEqualTo(cmd);
    assertThat(deserializedLsfExecutor.getJobId()).isEqualTo("test");
    assertThat(deserializedLsfExecutor.getOutFile()).isEqualTo("logDir/user/PIPELINE_NAME/PROCESS_ID/STAGE_NAME.out");
}
Also used : StageExecutorRequest(pipelite.stage.executor.StageExecutorRequest) LsfLogFilePathResolver(pipelite.stage.path.LsfLogFilePathResolver) LsfFilePathResolver(pipelite.stage.path.LsfFilePathResolver) Stage(pipelite.stage.Stage) SimpleLsfExecutorParameters(pipelite.stage.parameters.SimpleLsfExecutorParameters) Test(org.junit.jupiter.api.Test)

Aggregations

StageExecutorRequest (pipelite.stage.executor.StageExecutorRequest)21 Test (org.junit.jupiter.api.Test)18 Stage (pipelite.stage.Stage)13 AbstractLsfExecutorParameters (pipelite.stage.parameters.AbstractLsfExecutorParameters)6 LsfExecutorParameters (pipelite.stage.parameters.LsfExecutorParameters)6 SimpleLsfExecutorParameters (pipelite.stage.parameters.SimpleLsfExecutorParameters)6 LsfFilePathResolver (pipelite.stage.path.LsfFilePathResolver)2 LsfLogFilePathResolver (pipelite.stage.path.LsfLogFilePathResolver)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 StageExecutorResult (pipelite.stage.executor.StageExecutorResult)1 LsfDefinitionFilePathResolver (pipelite.stage.path.LsfDefinitionFilePathResolver)1