Search in sources :

Example 1 with LsfDefinitionFilePathResolver

use of pipelite.stage.path.LsfDefinitionFilePathResolver 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 2 with LsfDefinitionFilePathResolver

use of pipelite.stage.path.LsfDefinitionFilePathResolver in project pipelite by enasequence.

the class LsfExecutor method prepareSubmit.

@Override
protected void prepareSubmit(StageExecutorRequest request) {
    LsfDefinitionFilePathResolver resolver = new LsfDefinitionFilePathResolver(request, getExecutorParams());
    LsfFilePathResolver.Format format = LsfFilePathResolver.Format.WITHOUT_LSF_PATTERN;
    if (!getCmdRunner().createDir(Paths.get(resolver.getDir(format)))) {
        throw new PipeliteException("Failed to create LSF definition dir");
    }
    definitionFile = resolver.getFile(format);
    URL definitionUrl = ExecutorParametersValidator.validateUrl(getExecutorParams().getDefinition(), "definition");
    final String definition = applyDefinitionParameters(CmdRunnerUtils.read(definitionUrl), getExecutorParams().getParameters());
    RetryTask.DEFAULT.execute(r -> {
        getCmdRunner().writeFile(definition, Paths.get(definitionFile));
        return null;
    });
}
Also used : LsfDefinitionFilePathResolver(pipelite.stage.path.LsfDefinitionFilePathResolver) LsfFilePathResolver(pipelite.stage.path.LsfFilePathResolver) PipeliteException(pipelite.exception.PipeliteException) URL(java.net.URL)

Aggregations

LsfDefinitionFilePathResolver (pipelite.stage.path.LsfDefinitionFilePathResolver)2 LsfFilePathResolver (pipelite.stage.path.LsfFilePathResolver)2 URL (java.net.URL)1 Test (org.junit.jupiter.api.Test)1 PipeliteException (pipelite.exception.PipeliteException)1 Stage (pipelite.stage.Stage)1 StageExecutorRequest (pipelite.stage.executor.StageExecutorRequest)1 LsfExecutorParameters (pipelite.stage.parameters.LsfExecutorParameters)1 LsfLogFilePathResolver (pipelite.stage.path.LsfLogFilePathResolver)1