use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.
the class AbstractAsyncExecutor method poll.
private void poll(StageExecutorRequest request, StageExecutorResultCallback resultCallback) {
try {
StageExecutorResult result = poll(request);
if (result.isSubmitted()) {
result = StageExecutorResult.internalError(new PipeliteException("Unexpected state during asynchronous poll: " + result.getExecutorState().name()));
}
resultCallback.accept(result);
} catch (Exception ex) {
StageExecutorResult result = StageExecutorResult.internalError(ex);
resultCallback.accept(result);
}
}
use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.
the class AbstractLsfExecutor method submit.
@Override
protected SubmitResult submit(StageExecutorRequest request) {
outFile = getExecutorParams().resolveLogFile(request, LsfFilePathResolver.Format.WITHOUT_LSF_PATTERN);
StageExecutorResult result = RetryTask.DEFAULT.execute(r -> getCmdRunner().execute(getSubmitCmd(request)));
String jobId = null;
if (!result.isError()) {
jobId = extractSubmittedJobIdFromBsubOutput(result.getStageLog());
logContext(log.atInfo(), request).log("Submitted LSF job " + jobId);
result.setSubmitted();
}
return new SubmitResult(jobId, result);
}
use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.
the class AbstractLsfExecutor method extractResultFromBjobsOutput.
/**
* Extracts job result from a single line of bjobs output.
*/
public static JobResult extractResultFromBjobsOutput(String str) {
String[] column = str.split("\\|");
if (column.length != 7) {
log.atWarning().log("Unexpected bjobs output line: " + str);
return null;
}
StageExecutorResult result;
if (column[BJOBS_COLUMN_STATUS].equals(BJOBS_STATUS_DONE)) {
result = StageExecutorResult.success();
result.addAttribute(StageExecutorResultAttribute.EXIT_CODE, String.valueOf(0));
} else if (column[BJOBS_COLUMN_STATUS].equals(BJOBS_STATUS_EXIT)) {
result = StageExecutorResult.error();
result.addAttribute(StageExecutorResultAttribute.EXIT_CODE, String.valueOf(column[BJOBS_COLUMN_EXIT_CODE]));
} else {
result = StageExecutorResult.active();
}
String jobId = column[BJOBS_COLUMN_JOB_ID];
result.addAttribute(StageExecutorResultAttribute.JOB_ID, jobId);
if (result.isSuccess() || result.isError()) {
result.addAttribute(StageExecutorResultAttribute.EXEC_HOST, column[BJOBS_COLUMN_HOST]);
result.addAttribute(StageExecutorResultAttribute.CPU_TIME, column[BJOBS_COLUMN_CPU_TIME]);
result.addAttribute(StageExecutorResultAttribute.MAX_MEM, column[BJOBS_COLUMN_MAX_MEM]);
result.addAttribute(StageExecutorResultAttribute.AVG_MEM, column[BJOBS_COLUMN_AVG_MEM]);
}
JobResult jobResult = new JobResult();
jobResult.jobId = jobId;
jobResult.result = result;
return jobResult;
}
use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.
the class AbstractLsfExecutor method bjobs.
private static String bjobs(CmdRunner cmdRunner, List<String> jobIds) {
String str = String.join(" ", jobIds);
log.atFine().log("Checking LSF job results using bjobs: " + str);
// Ignore exit code as bjobs returns 255 if some of the jobs are not found.
StageExecutorResult result = cmdRunner.execute(BJOBS_CMD + str);
return result.getStageLog();
}
use of pipelite.stage.executor.StageExecutorResult in project pipelite by enasequence.
the class AbstractLsfExecutor method extractResultFromBhistOutputOrOutFile.
/**
* Extracts stage execution result from bhist output or out file. Returns null if the result could
* not be extracted.
*/
public static StageExecutorResult extractResultFromBhistOutputOrOutFile(String str) {
if (str == null) {
return null;
}
if (// bhist -f result
str.contains("Done successfully") || // output file result
str.contains("Successfully completed")) {
StageExecutorResult result = StageExecutorResult.success();
result.addAttribute(StageExecutorResultAttribute.EXIT_CODE, "0");
return result;
}
Integer exitCode = extractExitCodeFromBhistOutputOrOutFile(str);
if (exitCode != null) {
StageExecutorResult result = StageExecutorResult.error();
result.addAttribute(StageExecutorResultAttribute.EXIT_CODE, String.valueOf(exitCode));
return result;
}
return null;
}
Aggregations