Skip to content

Adds BioSimulators Test Suite originating Omex archives for CLI execution tests #829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions vcell-cli/src/main/java/org/vcell/cli/run/ExecuteImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import cbit.vcell.parser.ExpressionException;
import cbit.vcell.solver.ode.ODESolverResultSet;

import org.vcell.cli.CLIRecorder;
import org.vcell.cli.CLIRecordable;
import org.vcell.cli.PythonStreamException;
import org.vcell.cli.vcml.VCMLHandler;
import org.vcell.util.FileUtils;
Expand All @@ -22,7 +22,7 @@ public class ExecuteImpl {

private final static Logger logger = LogManager.getLogger(ExecuteImpl.class);

public static void batchMode(File dirOfArchivesToProcess, File outputDir, CLIRecorder cliLogger,
public static void batchMode(File dirOfArchivesToProcess, File outputDir, CLIRecordable cliLogger,
boolean bKeepTempFiles, boolean bExactMatchOnly, boolean bSmallMeshOverride) {
FilenameFilter filter = (f, name) -> name.endsWith(".omex") || name.endsWith(".vcml");
File[] inputFiles = dirOfArchivesToProcess.listFiles(filter);
Expand Down Expand Up @@ -67,7 +67,7 @@ public static void batchMode(File dirOfArchivesToProcess, File outputDir, CLIRec
}
}

public static void singleMode(File inputFile, File rootOutputDir, CLIRecorder cliLogger,
public static void singleMode(File inputFile, File rootOutputDir, CLIRecordable cliLogger,
boolean bKeepTempFiles, boolean bExactMatchOnly, boolean bEncapsulateOutput, boolean bSmallMeshOverride) throws Exception {
// Build statuses
String bioModelBaseName = FileUtils.getBaseName(inputFile.getName()); // bioModelBaseName = input file without the path
Expand All @@ -81,7 +81,7 @@ public static void singleMode(File inputFile, File rootOutputDir, CLIRecorder cl
ExecuteImpl.singleExecOmex(inputFile, rootOutputDir, cliLogger, bKeepTempFiles, bExactMatchOnly, bEncapsulateOutput, bSmallMeshOverride);
}

public static void singleMode(File inputFile, File outputDir, CLIRecorder cliLogger) throws Exception {
public static void singleMode(File inputFile, File outputDir, CLIRecordable cliLogger) throws Exception {
final boolean bKeepTempFiles = false;
final boolean bExactMatchOnly = false;
final boolean bEncapsulateOutput = false;
Expand All @@ -91,7 +91,7 @@ public static void singleMode(File inputFile, File outputDir, CLIRecorder cliLog
}

@Deprecated
public static void singleExecVcml(File vcmlFile, File outputDir, CLIRecorder cliLogger) {
public static void singleExecVcml(File vcmlFile, File outputDir, CLIRecordable cliLogger) {
logger.warn("Using deprecated function to execute vcml");
VCMLHandler.outputDir = outputDir.getAbsolutePath();
logger.debug("Executing VCML file " + vcmlFile);
Expand Down Expand Up @@ -143,7 +143,7 @@ public static void singleExecVcml(File vcmlFile, File outputDir, CLIRecorder cli
}
}

private static void singleExecOmex(File inputFile, File rootOutputDir, CLIRecorder cliRecorder,
private static void singleExecOmex(File inputFile, File rootOutputDir, CLIRecordable cliRecorder,
boolean bKeepTempFiles, boolean bExactMatchOnly, boolean bEncapsulateOutput, boolean bSmallMeshOverride)
throws ExecutionException, PythonStreamException, IOException, InterruptedException {
ExecutionJob requestedExecution = new ExecutionJob(inputFile, rootOutputDir, cliRecorder,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package org.vcell.cli.run;

public class ExecutionException extends Exception {
public ExecutionException(){
super();
}

public ExecutionException(String message){
super(message);
}
Expand Down
11 changes: 6 additions & 5 deletions vcell-cli/src/main/java/org/vcell/cli/run/ExecutionJob.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.vcell.cli.run;

import org.vcell.cli.CLIRecorder;
import org.vcell.cli.CLIRecordable;
import org.vcell.cli.PythonStreamException;
import org.vcell.util.FileUtils;

Expand Down Expand Up @@ -32,7 +32,7 @@ public class ExecutionJob {
private Path sedmlPath2d3d;
private File inputFile;

private CLIRecorder cliRecorder;
private CLIRecordable cliRecorder;

/**
* Constructor to provide all necessary info.
Expand All @@ -45,7 +45,7 @@ public class ExecutionJob {
* @param bEncapsulateOutput whether to provide a sub-folder for outputs (needed for batch jobs)
* @param bSmallMeshOverride whether to use small meshes or standard meshes.
*/
public ExecutionJob(File inputFile, File rootOutputDir, CLIRecorder cliRecorder,
public ExecutionJob(File inputFile, File rootOutputDir, CLIRecordable cliRecorder,
boolean bKeepTempFiles, boolean bExactMatchOnly, boolean bEncapsulateOutput, boolean bSmallMeshOverride){
this();
this.inputFile = inputFile;
Expand Down Expand Up @@ -139,8 +139,9 @@ public void executeArchive() throws InterruptedException, PythonStreamException,
logger.error("Python-processing encountered fatal error. Execution is unable to properly continue.", e);
throw e;
} catch(InterruptedException|IOException e){
logger.error("System IO encountered a fatal error");
throw new ExecutionException();
String message = "System IO encountered a fatal error";
logger.error(message, e);
throw new ExecutionException(message, e);
}
}

Expand Down
34 changes: 17 additions & 17 deletions vcell-cli/src/main/java/org/vcell/cli/run/SedmlJob.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package org.vcell.cli.run;

import ncsa.hdf.hdf5lib.exceptions.HDF5Exception;

import cbit.vcell.parser.ExpressionException;
import cbit.vcell.resource.OperatingSystemInfo;
import cbit.vcell.xml.ExternalDocInfo;
import ncsa.hdf.hdf5lib.exceptions.HDF5Exception;

import org.jlibsedml.*;

import org.apache.commons.io.FilenameUtils;
import org.vcell.cli.CLIRecorder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jlibsedml.*;
import org.vcell.cli.CLIRecordable;
import org.vcell.cli.PythonStreamException;
import org.vcell.cli.run.hdf5.Hdf5DatasetWrapper;
import org.vcell.cli.run.hdf5.Hdf5FileWrapper;
Expand All @@ -17,13 +18,10 @@
import org.vcell.util.FileUtils;
import org.vcell.util.GenericExtensionFilter;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;

import java.io.File;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand All @@ -33,13 +31,13 @@

public class SedmlJob {
private boolean somethingFailed, hasScans, hasOverrides, bKeepTempFiles, bExactMatchOnly, bSmallMeshOverride;
private String sedmlLocation, bioModelBaseName, resultsDirPath, logDocumentMessage, logDocumentError, sedmlName;
private String sedmlLocation, bioModelBaseName, resultsDirPath, logDocumentMessage, logDocumentError, sedmlName, problemsOccured;
private StringBuilder logOmexMessage;
private SedmlStatistics docStatistics;
private SedML sedml;
private File masterOmexArchive, rootOutputDir, plotsDirectory, plotFile;
private List<Output> outputs;
private CLIRecorder cliRecorder;
private CLIRecordable cliRecorder;
private File outDirForCurrentSedml;

private final static Logger logger = LogManager.getLogger(SedmlJob.class);
Expand All @@ -60,7 +58,7 @@ public class SedmlJob {
* @param logOmexMessage a string-builder to contain progress updates of omex execution
*/
public SedmlJob(String sedmlLocation, OmexHandler omexHandler, File masterOmexArchive, File rootOutputDir, String resultsDirPath, String sedmlPath2d3dString,
CLIRecorder cliRecorder, boolean bKeepTempFiles, boolean bExactMatchOnly, boolean bSmallMeshOverride, StringBuilder logOmexMessage){
CLIRecordable cliRecorder, boolean bKeepTempFiles, boolean bExactMatchOnly, boolean bSmallMeshOverride, StringBuilder logOmexMessage){
this.somethingFailed = false;
this.masterOmexArchive = masterOmexArchive;
this.sedmlLocation = sedmlLocation;
Expand All @@ -77,6 +75,7 @@ public SedmlJob(String sedmlLocation, OmexHandler omexHandler, File masterOmexAr
this.cliRecorder = cliRecorder;
this.logDocumentMessage = "Initializing SED-ML document... ";
this.logDocumentError = "";
this.problemsOccured = "";

}

Expand Down Expand Up @@ -269,13 +268,13 @@ private void processOutputs(SolverHandler solverHandler) throws PythonStreamExce
logDocumentError += e.getMessage();
this.reportProblem(e);
org.apache.commons.io.FileUtils.deleteDirectory(this.plotsDirectory); // removing temp path generated from python
throw new ExecutionException();
throw new ExecutionException("error while processing outputs: "+e.getMessage(), e);
}
}

private boolean evalulateResults() throws PythonStreamException, InterruptedException, IOException {
if (this.somethingFailed) { // something went wrong but no exception was fired
Exception e = new RuntimeException("Failure executing the sed document. ");
Exception e = new RuntimeException("Failure executing the sed document:\n" + this.problemsOccured);
logDocumentError += e.getMessage();
this.reportProblem(e);
org.apache.commons.io.FileUtils.deleteDirectory(this.plotsDirectory); // removing temp path generated from python
Expand Down Expand Up @@ -384,10 +383,11 @@ private static Path getRelativePath(String[] tokenizedPath){
return null;
}

private static boolean somethingDidFail(){
private boolean somethingDidFail(){
StackTraceElement elem = new Exception().getStackTrace()[1];

logger.debug(String.format("Something failed in %s @ line %d", elem.getClassName(), elem.getLineNumber()));
String failString = String.format("Something failed in %s @ line %d", elem.getClassName(), elem.getLineNumber());
this.problemsOccured += failString + '\n';
logger.debug(failString);
return true;
}

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 @@ -37,7 +37,7 @@
import org.jlibsedml.XPathTarget;
import org.jlibsedml.modelsupport.SBMLSupport;
import org.jmathml.ASTNode;
import org.vcell.cli.CLIRecorder;
import org.vcell.cli.CLIRecordable;
import org.vcell.sbml.vcell.SBMLImportException;
import org.vcell.sbml.vcell.SBMLImporter;
import org.vcell.util.ISize;
Expand Down Expand Up @@ -281,7 +281,7 @@ public void initialize(List<BioModel> bioModelList, SedML sedml) throws Expressi
System.out.println("topTaskToBaseTask: " + topTaskToBaseTask.size());
}

public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRecorder cliLogger,
public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRecordable cliLogger,
File outputDirForSedml, String outDir, String outputBaseDir, String sedmlLocation,
boolean keepTempFiles, boolean exactMatchOnly, boolean bSmallMeshOverride) throws Exception {
// create the VCDocument(s) (bioModel(s) + application(s) + simulation(s)), do sanity checks
Expand Down
Loading