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");
}
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;
});
}
Aggregations