Skip to content

Commit

Permalink
integrated Tracer through CLIRecordable for test observability
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Nov 21, 2024
1 parent e775967 commit 6cec020
Show file tree
Hide file tree
Showing 49 changed files with 332 additions and 116 deletions.
6 changes: 3 additions & 3 deletions vcell-cli/src/main/java/org/vcell/cli/CLIRecordable.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

public interface CLIRecordable {

public void writeDetailedErrorList(String message) throws IOException;
public void writeDetailedErrorList(Exception e, String message) throws IOException;

public void writeFullSuccessList(String message) throws IOException;

public void writeErrorList(String message) throws IOException;
public void writeErrorList(Exception e, String message) throws IOException;

public void writeDetailedResultList(String message) throws IOException;

// we make a list with the omex files that contain (some) spatial simulations (FVSolverStandalone solver)
public void writeSpatialList(String message) throws IOException;

public void writeImportErrorList(String message) throws IOException;
public void writeImportErrorList(Exception e, String message) throws IOException;
}
11 changes: 8 additions & 3 deletions vcell-cli/src/main/java/org/vcell/cli/CLIRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ private void writeToFileLog(TextFileRecord log, String message) throws IOExcepti
*
* @param message string to write to file
*/
public void writeDetailedErrorList(String message) throws IOException {
@Override
public void writeDetailedErrorList(Exception _e, String message) throws IOException {
this.writeToFileLog(this.detailedErrorLog, message);
}

Expand All @@ -130,6 +131,7 @@ public void writeDetailedErrorList(String message) throws IOException {
*
* @param message string to write to file
*/
@Override
public void writeFullSuccessList(String message) throws IOException {
this.writeToFileLog(this.fullSuccessLog, message);
}
Expand All @@ -139,7 +141,8 @@ public void writeFullSuccessList(String message) throws IOException {
*
* @param message string to write to file
*/
public void writeErrorList(String message) throws IOException {
@Override
public void writeErrorList(Exception _e, String message) throws IOException {
this.writeToFileLog(this.errorLog, message);
}

Expand All @@ -148,6 +151,7 @@ public void writeErrorList(String message) throws IOException {
*
* @param message string to write to file
*/
@Override
public void writeDetailedResultList(String message) throws IOException {
this.writeToFileLog(this.detailedResultsLog, message);
}
Expand All @@ -168,7 +172,8 @@ public void writeSpatialList(String message) throws IOException {
*
* @param message string to write to file
*/
public void writeImportErrorList(String message) throws IOException {
@Override
public void writeImportErrorList(Exception _e, String message) throws IOException {
this.writeToFileLog(this.importErrorLog, message);
}

Expand Down
6 changes: 3 additions & 3 deletions vcell-cli/src/main/java/org/vcell/cli/run/ExecutionJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ public void preprocessArchive() throws PythonStreamException, IOException {
this.sedmlLocations = this.omexHandler.getSedmlLocationsAbsolute();
} catch (IOException e){
String error = e.getMessage() + ", error for OmexHandler with " + this.inputFilePath;
this.cliRecorder.writeErrorList(this.bioModelBaseName);
this.cliRecorder.writeErrorList(e, this.bioModelBaseName);
this.cliRecorder.writeDetailedResultList(this.bioModelBaseName + ", " + "IO error with OmexHandler");
logger.error(error);
throw new RuntimeException(error, e);
} catch (Exception e) {
String error = e.getMessage() + ", error for archive " + this.inputFilePath;
logger.error(error);
if (this.omexHandler != null) this.omexHandler.deleteExtractedOmex();
this.cliRecorder.writeErrorList(this.bioModelBaseName);
this.cliRecorder.writeErrorList(e, this.bioModelBaseName);
this.cliRecorder.writeDetailedResultList(this.bioModelBaseName + ", " + "unknown error with the archive file");

throw new RuntimeException(error, e);
Expand Down Expand Up @@ -183,7 +183,7 @@ public void postProcessessArchive() throws InterruptedException, PythonStreamExc
PythonCalls.updateOmexStatusYml(Status.FAILED, outputDir, duration + "");
logger.error(error);
logOmexMessage.append(error);
cliRecorder.writeErrorList(bioModelBaseName);
cliRecorder.writeErrorList(new Exception("exception not recorded"), bioModelBaseName);
} else {
PythonCalls.updateOmexStatusYml(Status.SUCCEEDED, outputDir, duration + "");
cliRecorder.writeFullSuccessList(bioModelBaseName);
Expand Down
8 changes: 5 additions & 3 deletions vcell-cli/src/main/java/org/vcell/cli/run/SedmlJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ public boolean preProcessDoc() throws PythonStreamException, InterruptedExceptio
this.plotFile = new File(this.PLOTS_DIRECTORY, "simulation_" + this.sedmlName);
Path path = Paths.get(this.plotFile.getAbsolutePath());
if (!Files.exists(path)) {
String message = "Failed to create file " + this.plotFile.getAbsolutePath();
String message = "Failed to create plot file " + this.plotFile.getAbsolutePath();
this.CLI_RECORDER.writeDetailedResultList(this.BIOMODEL_BASE_NAME + "," + this.sedmlName + "," + message);
throw new RuntimeException(message);
RuntimeException exception = new RuntimeException(message);
Tracer.failure(exception, this.BIOMODEL_BASE_NAME + "," + this.sedmlName + "," + message);
throw exception;
}

// Converting pseudo SED-ML to biomodel
Expand Down Expand Up @@ -462,7 +464,7 @@ private void reportProblem(Exception e) throws PythonStreamException, Interrupte
String type = e.getClass().getSimpleName();
PythonCalls.setOutputMessage(this.SEDML_LOCATION, this.sedmlName, this.RESULTS_DIRECTORY_PATH, "sedml", this.logDocumentMessage);
PythonCalls.setExceptionMessage(this.SEDML_LOCATION, this.sedmlName, this.RESULTS_DIRECTORY_PATH, "sedml", type, this.logDocumentError);
this.CLI_RECORDER.writeDetailedErrorList(this.BIOMODEL_BASE_NAME + ", doc: " + type + ": " + this.logDocumentError);
this.CLI_RECORDER.writeDetailedErrorList(e, this.BIOMODEL_BASE_NAME + ", doc: " + type + ": " + this.logDocumentError);
PythonCalls.updateSedmlDocStatusYml(this.SEDML_LOCATION, Status.FAILED, this.RESULTS_DIRECTORY_PATH);
}

Expand Down
4 changes: 2 additions & 2 deletions vcell-cli/src/main/java/org/vcell/cli/run/SolverHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,11 @@ public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRe
if (!bTimeoutFound) { // don't repeat this for each task
String str = logTaskError.substring(0, logTaskError.indexOf("Process timed out"));
str += "Process timed out"; // truncate the rest of the spam
cliLogger.writeDetailedErrorList(bioModelBaseName + ", solver: " + sdl + ": " + type + ": " + str);
cliLogger.writeDetailedErrorList(e, bioModelBaseName + ", solver: " + sdl + ": " + type + ": " + str);
bTimeoutFound = true;
}
} else {
cliLogger.writeDetailedErrorList(bioModelBaseName + ", solver: " + sdl + ": " + type + ": " + logTaskError);
cliLogger.writeDetailedErrorList(e,bioModelBaseName + ", solver: " + sdl + ": " + type + ": " + logTaskError);
}
RunUtils.drawBreakLine("-", 100);
} finally {
Expand Down
Loading

0 comments on commit 6cec020

Please sign in to comment.