// get server address from left over arguments
Server server = getServer(line.getArgs());
// create run
Run run = server.createRun(workflow);
System.out.println("Created run with uuid: " + run.getUUID());
System.out.println("Created at " + run.getCreateTime());
// set inputs
if (baclavaIn != null) {
try {
run.uploadBaclavaFile(baclavaIn);
} catch (IOException e) {
System.out.println(e);
}
} else {
if (inputs != null) {
for (String port : inputs.keySet()) {
String value = inputs.get(port);
run.setInput(port, value);
System.out.format("Set input '%s' to %s\n", port, value);
}
}
if (files != null) {
for (String port : files.keySet()) {
File file = files.get(port);
try {
run.uploadInputFile(port, file);
System.out.format(
"Set input '%s' to use file '%s' as input\n",
port, file.getName());
} catch (IOException e) {
System.err.format("Could not set input '%s': %s\n",
port, e.getMessage());
System.exit(1);
}
}
}
}
// output baclava?
if (baclavaOut != null) {
run.setBaclavaOutput(baclavaOut.getName());
}
// Start run and wait until it is finished
run.start();
System.out.println("Started at " + run.getStartTime());
System.out.print("Running");
while (run.getStatus() == RunStatus.RUNNING) {
try {
Thread.sleep(1000);
System.out.print(".");
} catch (InterruptedException e) {
}
}
System.out.println("\nFinished at " + run.getFinishTime());
// get outputs
String stdout = run.getConsoleOutput();
String stderr = run.getConsoleError();
int exitcode = run.getExitCode();
System.out.println("Exitcode: " + exitcode);
if (stdout != "") {
System.out.println("Stdout:\n" + stdout);
}
if (stderr != "") {
System.out.println("Stderr:\n" + stderr);
}
if (exitcode == 0) {
if (baclavaOut != null) {
try {
FileUtils.writeStringToFile(baclavaOut,
run.getBaclavaOutput());
System.out.format("Baclava file written to '%s'\n",
baclavaOut);
} catch (IOException e) {
System.out.format("Could not write baclava file '%s'\n",
baclavaOut.getAbsoluteFile());
}
} else {
System.out.println("Outputs:");
for (String port : run.getOutputPorts()) {
System.out.format(" %s -> %s\n", port,
run.getOutput(port, outputRefs));
}
}
}
// delete run?
if (deleteRun) {
run.delete();
System.out.println("Run deleted");
}
}