use of cbit.vcell.solvers.AbstractSolver in project vcell by virtualcell.
the class VCMongoMessage method addObject.
private static void addObject(Document dbObject, SolverEvent solverEvent) {
AbstractSolver solver = (AbstractSolver) solverEvent.getSource();
dbObject.put(MongoMessage_simProgress, solverEvent.getProgress());
dbObject.put(MongoMessage_simTime, solverEvent.getTimePoint());
addObject(dbObject, solverEvent.getSimulationMessage());
dbObject.put(MongoMessage_solverEventType, solverEvent.getType());
SimulationJob simJob = solver.getSimulationJob();
dbObject.put(MongoMessage_simId, simJob.getVCDataIdentifier().getSimulationKey().toString());
dbObject.put(MongoMessage_jobIndex, solver.getJobIndex());
dbObject.put(MongoMessage_serverId, VCellServerID.getSystemServerID().toString());
}
use of cbit.vcell.solvers.AbstractSolver in project vcell by virtualcell.
the class HtcSimulationWorker method submit2PBS.
private HtcJobID submit2PBS(SimulationTask simTask, HtcProxy clonedHtcProxy, PostProcessingChores chores) throws XmlParseException, IOException, SolverException, ExecutableException {
HtcJobID jobid = null;
String htcLogDirExternalString = new File(PropertyLoader.getRequiredProperty(PropertyLoader.htcLogDirExternal)).getAbsolutePath();
if (!htcLogDirExternalString.endsWith("/")) {
htcLogDirExternalString = htcLogDirExternalString + "/";
}
String htcLogDirInternalString = new File(PropertyLoader.getRequiredProperty(PropertyLoader.htcLogDirInternal)).getAbsolutePath();
if (!htcLogDirInternalString.endsWith("/")) {
htcLogDirInternalString = htcLogDirInternalString + "/";
}
// "S_" + simTask.getSimKey() + "_" + simTask.getSimulationJob().getJobIndex()+ "_" + simTask.getTaskID();
String jobname = HtcProxy.createHtcSimJobName(new HtcProxy.SimTaskInfo(simTask.getSimKey(), simTask.getSimulationJob().getJobIndex(), simTask.getTaskID()));
String subFileExternal = htcLogDirExternalString + jobname + clonedHtcProxy.getSubmissionFileExtension();
String subFileInternal = htcLogDirInternalString + jobname + clonedHtcProxy.getSubmissionFileExtension();
File parallelDirInternal = new File(chores.runDirectoryInternal);
File parallelDirExternal = new File(chores.runDirectoryExternal);
File primaryUserDirInternal = new File(chores.finalDataDirectoryInternal);
File primaryUserDirExternal = new File(chores.finalDataDirectoryExternal);
Solver realSolver = (AbstractSolver) SolverFactory.createSolver(primaryUserDirInternal, parallelDirInternal, simTask, true);
realSolver.setUnixMode();
String simTaskXmlText = XmlHelper.simTaskToXML(simTask);
String simTaskFilePathInternal = ResourceUtil.forceUnixPath(new File(primaryUserDirInternal, simTask.getSimulationJobID() + "_" + simTask.getTaskID() + ".simtask.xml").toString());
String simTaskFilePathExternal = ResourceUtil.forceUnixPath(new File(primaryUserDirExternal, simTask.getSimulationJobID() + "_" + simTask.getTaskID() + ".simtask.xml").toString());
if (!primaryUserDirInternal.exists()) {
FileUtils.forceMkdir(primaryUserDirInternal);
//
// directory create from container (possibly) as root, make this user directory accessible from user "vcell"
//
primaryUserDirInternal.setWritable(true, false);
primaryUserDirInternal.setExecutable(true, false);
primaryUserDirInternal.setReadable(true, false);
}
XmlUtil.writeXMLStringToFile(simTaskXmlText, simTaskFilePathInternal, true);
final String SOLVER_EXIT_CODE_REPLACE_STRING = "SOLVER_EXIT_CODE_REPLACE_STRING";
KeyValue simKey = simTask.getSimKey();
User simOwner = simTask.getSimulation().getVersion().getOwner();
final int jobId = simTask.getSimulationJob().getJobIndex();
ExecutableCommand.Container commandContainer = new ExecutableCommand.Container();
// the post processor command itself is neither messaging nor parallel; it's independent of the previous solver call
ExecutableCommand postprocessorCmd = new ExecutableCommand(null, false, false, PropertyLoader.getRequiredProperty(PropertyLoader.simulationPostprocessor), simKey.toString(), simOwner.getName(), simOwner.getID().toString(), Integer.toString(jobId), Integer.toString(simTask.getTaskID()), SOLVER_EXIT_CODE_REPLACE_STRING, subFileExternal);
postprocessorCmd.setExitCodeToken(SOLVER_EXIT_CODE_REPLACE_STRING);
commandContainer.add(postprocessorCmd);
// CBN?
int ncpus = simTask.getSimulation().getSolverTaskDescription().getNumProcessors();
Collection<PortableCommand> postProcessingCommands = new ArrayList<PortableCommand>();
if (realSolver instanceof AbstractCompiledSolver) {
AbstractCompiledSolver compiledSolver = (AbstractCompiledSolver) realSolver;
List<String> args = new ArrayList<>(4);
args.add(PropertyLoader.getRequiredProperty(PropertyLoader.simulationPreprocessor));
args.add(simTaskFilePathExternal);
args.add(primaryUserDirExternal.getAbsolutePath());
if (chores.isParallel()) {
args.add(chores.runDirectoryExternal);
}
// compiled solver ...used to be only single executable, now we pass 2 commands to PBSUtils.submitJob that invokes SolverPreprocessor.main() and then the native executable
// the pre-processor command itself is neither messaging nor parallel; it's independent of the subsequent solver call
ExecutableCommand preprocessorCmd = new ExecutableCommand(null, false, false, args);
commandContainer.add(preprocessorCmd);
for (ExecutableCommand ec : compiledSolver.getCommands()) {
if (ec.isMessaging()) {
ec.addArgument("-tid");
ec.addArgument(simTask.getTaskID());
}
commandContainer.add(ec);
}
if (chores.isCopyNeeded()) {
String logName = chores.finalDataDirectoryInternal + '/' + SimulationData.createCanonicalSimLogFileName(simKey, jobId, false);
CopySimFiles csf = new CopySimFiles(simTask.getSimulationJobID(), chores.runDirectoryInternal, chores.finalDataDirectoryInternal, logName);
postProcessingCommands.add(csf);
}
if (chores.isVtkUser()) {
VtkMeshGenerator vmg = new VtkMeshGenerator(simOwner, simKey, jobId);
postProcessingCommands.add(vmg);
}
} else {
ExecutableCommand ec = new ExecutableCommand(null, false, false, PropertyLoader.getRequiredProperty(PropertyLoader.javaSimulationExecutable), simTaskFilePathExternal, ResourceUtil.forceUnixPath(parallelDirExternal.getAbsolutePath()));
commandContainer.add(ec);
}
jobid = clonedHtcProxy.submitJob(jobname, subFileInternal, subFileExternal, commandContainer, ncpus, simTask.getEstimatedMemorySizeMB(), postProcessingCommands);
if (jobid == null) {
throw new RuntimeException("Failed. (error message: submitting to job scheduler failed).");
}
return jobid;
}
Aggregations