Skip to content

Commit

Permalink
optional output in cwl.output.json (#3165)
Browse files Browse the repository at this point in the history
  • Loading branch information
Horneth committed Jan 19, 2018
1 parent 48ada7e commit 1dedea1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cwl/src/main/scala/cwl/CommandLineTool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,15 @@ case class CommandLineTool private(
import cats.instances.list._

outputPorts.toList.traverse[ErrorOr, (OutputPort, WomValue)]({ outputPort =>
// If the type is optional, then we can set the value to none if there's nothing in the json
def emptyValue = outputPort.womType match {
case optional: WomOptionalType => Option((outputPort -> optional.none).validNel)
case _ => None
}

json.get(outputPort.name)
.map(_.foldWith(CwlJsonToDelayedCoercionFunction).apply(outputPort.womType).map(outputPort -> _))
.orElse(emptyValue)
.getOrElse(s"Cannot find a value for output ${outputPort.name} in output json $json".invalidNel)
}).toEither
}
Expand Down

0 comments on commit 1dedea1

Please sign in to comment.