Skip to content

Commit

Permalink
Merge pull request #20 from MesquiteProject/development
Browse files Browse the repository at this point in the history
Zephyr 3.0
  • Loading branch information
DMaddison authored Dec 28, 2018
2 parents c430d06 + 8b2ff62 commit ba44730
Show file tree
Hide file tree
Showing 121 changed files with 7,158 additions and 1,279 deletions.
61 changes: 38 additions & 23 deletions Source/mesquite/zephyr/CIPResRESTRunner/CIPResRESTRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import mesquite.zephyr.lib.*;

public class CIPResRESTRunner extends ExternalProcessRunner implements OutputFileProcessor, ShellScriptWatcher, OutputFilePathModifier {
String rootDir = null;
MesquiteString jobURL = null;
MesquiteString jobID = null;
ExternalProcessRequester processRequester;
Expand All @@ -39,6 +38,7 @@ public boolean startJob(String arguments, Object condition, boolean hiredByName)
MesquiteModule mm = getEmployer();
loadPreferences(xmlPrefs);
xmlPrefsString = xmlPrefs.getValue();
setReadyForReconnectionSave(false);

return true;
}
Expand All @@ -47,6 +47,10 @@ public void endJob(){
super.endJob();
}

public static String getDefaultProgramLocation() {
return "CIPRes";
}

public String getProgramLocation(){
return "CIPRes";
}
Expand Down Expand Up @@ -89,26 +93,34 @@ public boolean isWindows() {
public boolean isLinux() {
return false;
}
public boolean isMacOSX() {
return false;
}

/*.................................................................................................................*/
public String preparePreferencesForXML () {
StringBuffer buffer = new StringBuffer(200);
StringUtil.appendXMLTag(buffer, 2, "runLimit", runLimit);
if (communicator!=null)
buffer.append(communicator.preparePreferencesForXML());
return buffer.toString();
}
/*.................................................................................................................*/
public void processSingleXMLPreference (String tag, String content) {
if ("runLimit".equalsIgnoreCase(tag))
runLimit = MesquiteDouble.fromString(content);
else
if (communicator!=null)
communicator.processSingleXMLPreference(tag, content);
super.processSingleXMLPreference(tag, content);
}


/*.................................................................................................................*/
public Snapshot getSnapshot(MesquiteFile file) {
Snapshot temp = new Snapshot();
if (rootDir != null)
temp.addLine("setRootDir " + ParseUtil.tokenize(rootDir));
if (localRootDir != null)
temp.addLine("setRootDir " + ParseUtil.tokenize(localRootDir));
if (outputFilePaths != null){
String files = " ";
for (int i = 0; i< outputFilePaths.length; i++){
Expand Down Expand Up @@ -141,7 +153,8 @@ public Object doCommand(String commandName, String arguments, CommandChecker che
reportJobURL=true;
communicator.setOutputProcessor(this);
communicator.setWatcher(this);
communicator.setRootDir(rootDir);
communicator.setRootDir(localRootDir);
communicator.setHasBeenReconnected(true);
if (forgetPassword)
communicator.forgetPassword();
forgetPassword = false;
Expand All @@ -166,9 +179,9 @@ else if (checker.compare(this.getClass(), "Sets the job URL", null, commandName,
}
}
else if (checker.compare(this.getClass(), "Sets root directory", null, commandName, "setRootDir")) {
rootDir = parser.getFirstToken(arguments);
localRootDir = parser.getFirstToken(arguments);
if (communicator!=null)
communicator.setRootDir(rootDir);
communicator.setRootDir(localRootDir);
}
else if (checker.compare(this.getClass(), "Sets runLimit", null, commandName, "setRunLimit")) {
runLimit = MesquiteDouble.fromString(parser.getFirstToken(arguments));
Expand All @@ -181,6 +194,7 @@ else if (checker.compare(this.getClass(), "Sets runLimit", null, commandName, "s
// setting the requester, to whom this runner will communicate about the run
public void setProcessRequester(ExternalProcessRequester processRequester){
setExecutableName(processRequester.getProgramName());
setExecutableNumber(processRequester.getProgramNumber());
setRootNameForDirectory(processRequester.getRootNameForDirectory());
this.processRequester = processRequester;
loadPreferences();
Expand All @@ -196,10 +210,11 @@ public void forgetCIPResPassword() {
DoubleField runLimitField;

// given the opportunity to fill in options for user
public void addItemsToDialogPanel(ExtensibleDialog dialog){
public boolean addItemsToDialogPanel(ExtensibleDialog dialog){
dialog.addBoldLabel("CIPRes Options");
ForgetPasswordCheckbox = dialog.addCheckBox("Require new login to CIPRes", false);
runLimitField = dialog.addDoubleField("maximum hours of CIPRes time for run", runLimit, 5, 0, 168);
return true;
}

public void addNoteToBottomOfDialog(ExtensibleDialog dialog){
Expand All @@ -220,14 +235,14 @@ public String getExecutableCommand(){
return processRequester.getExecutableName();
}

String executableCIPResName;
String executableRemoteName;
MultipartEntityBuilder builder;
String[] outputFilePaths;
String[] outputFileNames;
String[] inputFilePaths;
/*.................................................................................................................*/
public String getDirectoryPath(){
return rootDir;
return localRootDir;
}

/*.................................................................................................................*/
Expand All @@ -237,23 +252,22 @@ public String getInputFilePath(int i){ //assumes for now that all input files a
return null;
}


/*.................................................................................................................*/
// the actual data & scripts.
public boolean setProgramArgumentsAndInputFiles(String programCommand, Object arguments, String[] fileContents, String[] fileNames){ //assumes for now that all input files are in the same directory
executableCIPResName= programCommand;
public boolean setProgramArgumentsAndInputFiles(String programCommand, Object arguments, String[] fileContents, String[] fileNames, int runInfoFileNumber){ //assumes for now that all input files are in the same directory
executableRemoteName= programCommand;
if (!(arguments instanceof MultipartEntityBuilder))
return false;
builder = (MultipartEntityBuilder)arguments;
if (rootDir==null)
rootDir = MesquiteFileUtil.createDirectoryForFiles(this, MesquiteFileUtil.BESIDE_HOME_FILE, getExecutableName(), "-Run.");
if (rootDir==null)
if (!setRootDir())
return false;

inputFilePaths = new String[fileNames.length];
for (int i=0; i<fileContents.length && i<fileNames.length; i++) {
if (StringUtil.notEmpty(fileNames[i]) && fileContents[i]!=null) {
MesquiteFile.putFileContents(rootDir+fileNames[i], fileContents[i], true);
inputFilePaths[i]=rootDir+fileNames[i];
MesquiteFile.putFileContents(localRootDir+fileNames[i], fileContents[i], true);
inputFilePaths[i]=localRootDir+fileNames[i];
}
}
processRequester.prepareRunnerObject(builder);
Expand All @@ -263,8 +277,8 @@ public boolean setProgramArgumentsAndInputFiles(String programCommand, Object ar
/*.................................................................................................................*/
// the actual data & scripts.
public boolean setPreflightInputFiles(String script){ //assumes for now that all input files are in the same directory
rootDir = MesquiteFileUtil.createDirectoryForFiles(this, MesquiteFileUtil.BESIDE_HOME_FILE, getExecutableName(), "-Run.");
if (rootDir==null)
localRootDir = MesquiteFileUtil.createDirectoryForFiles(this, MesquiteFileUtil.BESIDE_HOME_FILE, getExecutableName(), "-Run.");
if (localRootDir==null)
return false;

return true;
Expand All @@ -276,15 +290,15 @@ public void setOutputFileNamesToWatch(String[] fileNames){
outputFileNames = new String[fileNames.length];
outputFilePaths = new String[fileNames.length];
for (int i=0; i<fileNames.length; i++){
outputFilePaths[i]=rootDir+fileNames[i];
outputFilePaths[i]=localRootDir+fileNames[i];
outputFileNames[i]=fileNames[i];
}
}
}
/*.................................................................................................................*/
public void setOutputFileNameToWatch(int index, String fileName){
if (outputFileNames!=null && index>=0 && index < outputFileNames.length) {
outputFilePaths[index]=rootDir+fileName;
outputFilePaths[index]=localRootDir+fileName;
outputFileNames[index]=fileName;
}
}
Expand Down Expand Up @@ -317,13 +331,14 @@ public boolean startExecution(){ //do we assume these are disconnectable?
communicator.setRunLimit(runLimit);
communicator.setOutputProcessor(this);
communicator.setWatcher(this);
communicator.setRootDir(rootDir);
communicator.setRootDir(localRootDir);
if (forgetPassword)
communicator.forgetPassword();
forgetPassword = false;

jobURL = new MesquiteString();
return communicator.sendJobToCipres(builder, executableCIPResName, jobURL);
setReadyForReconnectionSave(true);
return communicator.sendJobToCipres(builder, executableRemoteName, jobURL);
}

public boolean monitorExecution(ProgressIndicator progIndicator){
Expand All @@ -341,7 +356,7 @@ public boolean stopExecution(){
return true;
}
public String getPreflightFile(String preflightLogFileName){
String filePath = rootDir + preflightLogFileName;
String filePath = localRootDir + preflightLogFileName;
String fileContents = MesquiteFile.getFileContentsAsString(filePath);
return fileContents;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ public String queryOptionsDialogTitle() {

IntegerField memoryRequestField;
/*.................................................................................................................*/
public void addRunnerOptions(ExtensibleDialog dialog) {
public boolean addRunnerOptions(ExtensibleDialog dialog) {
externalProcRunner.addItemsToDialogPanel(dialog);
memoryRequestField = dialog.addIntegerField("Memory requested for analysis (MB)", memoryRequest, 8, 500, 20000);
return true;
}
/*.................................................................................................................*/
public void processRunnerOptions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,11 @@ public String queryOptionsDialogTitle() {
}

/*.................................................................................................................*/
public void addRunnerOptions(ExtensibleDialog dialog) {
public boolean addRunnerOptions(ExtensibleDialog dialog) {
externalProcRunner.addItemsToDialogPanel(dialog);
availableMemoryField = dialog.addIntegerField("Memory for GARLI (MB)", availMemory, 8, 256, MesquiteInteger.infinite);
numProcessorsField = dialog.addIntegerField("Number of Processors (to use all processors, enter 0)", numProcessors, 8, 0, MesquiteInteger.infinite);
return true;
// dialog.addLabel("(To use all processors, enter 0)");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public Object doCommand(String commandName, String arguments, CommandChecker che
} else
return super.doCommand(commandName, arguments, checker);
}
/*.................................................................................................................*/
public int getProgramNumber() {
return -1;
}

/*.................................................................................................................*
public void processSingleXMLPreference (String tag, String content) {
Expand Down
Loading

0 comments on commit ba44730

Please sign in to comment.