Skip to content

Commit

Permalink
fix issue #37
Browse files Browse the repository at this point in the history
  • Loading branch information
liuwei committed Nov 8, 2018
1 parent a4b2ac0 commit a61fe0d
Showing 1 changed file with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,42 @@ public static void buildScatterCommand(CWLCommandInstance instance) throws CWLEx
InlineJavascriptRequirement jsReq = CWLExecUtil.findRequirement(instance, InlineJavascriptRequirement.class);
Map<String, String> runtime = instance.getRuntime();
InputsEvaluator.eval(jsReq, runtime, totalInputs);
CommandStdIOEvaluator.eval(jsReq, runtime, totalInputs, commandLineTool.getStdin());
CommandStdIOEvaluator.eval(jsReq, runtime, totalInputs, commandLineTool.getStderr());
CommandStdIOEvaluator.eval(jsReq, runtime, totalInputs, commandLineTool.getStdout());
// refer to issue #36 and #37
if (!needToPutOff(totalInputs)) {
CommandStdIOEvaluator.eval(jsReq, runtime, totalInputs, commandLineTool.getStdin());
CommandStdIOEvaluator.eval(jsReq, runtime, totalInputs, commandLineTool.getStderr());
CommandStdIOEvaluator.eval(jsReq, runtime, totalInputs, commandLineTool.getStdout());
}
scatterHolder.setScatterIndex(i + 1);
scatterHolder.setInputs(totalInputs);
scatterHolder.setCommand(buildCommand(instance, totalInputs, scatterHolder.getScatterIndex()));
instance.getScatterHolders().add(scatterHolder);
}
}

private static boolean needToPutOff(List<CommandInputParameter> totalInputs) {
for (CommandInputParameter input : totalInputs) {
if (input.getDelayedValueFromExpr() != null) {
return true;
}
}
return false;
}

private static List<CommandInputParameter> copyInputs(List<CommandInputParameter> inputs, Object value) {
List<CommandInputParameter> copied = new ArrayList<>();
for (CommandInputParameter input : inputs) {
if (input.getDelayedValueFromExpr() != null) {
CommandInputParameter copiedInput = new CommandInputParameter(input.getId());
copiedInput.setValue(value);
copied.add(copiedInput);
} else {
copied.add(input);
}
}
return copied;
}

private static List<String> buildCommand(CWLCommandInstance instance,
List<CommandInputParameter> inputs,
int scatterIndex) throws CWLException {
Expand Down Expand Up @@ -668,14 +694,18 @@ private static void attachInputArgument(List<String> args,
if (inputValue instanceof String && inputType.getSymbol() != CWLTypeSymbol.STRING) {
inputType = new StringType();
}
// refer to issue #36
// refer to issue #36 and #37
if (input.getDelayedValueFromExpr() != null) {
inputValue = StepInValueFromEvaluator.evalExpr(jsReq,
runtime,
inputs,
input.getSelf(),
input.getDelayedValueFromExpr());
((List<Object>) input.getValue()).add(inputValue);
CommandLineTool commandLineTool = (CommandLineTool) instance.getProcess();
CommandStdIOEvaluator.eval(jsReq, runtime, copyInputs(inputs, inputValue), commandLineTool.getStdin());
CommandStdIOEvaluator.eval(jsReq, runtime, copyInputs(inputs, inputValue), commandLineTool.getStderr());
CommandStdIOEvaluator.eval(jsReq, runtime, copyInputs(inputs, inputValue), commandLineTool.getStdout());
}
if (inputValue != null && inputValue != NullValue.NULL) {
logger.debug("The input (id={}, type={}, value={}) of step {}",
Expand Down

0 comments on commit a61fe0d

Please sign in to comment.