forked from broadinstitute/cromwell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Meta section [BA-5797] (broadinstitute#5053)
* WIP * WIP * WIP * WIP * Fixing code review comment, and fixing a failing test for draft3-transforms * Supporting only what is necessary in terms of an io.circe JSON encoder for the meta values * Converting to io.circe JSON values correctly * Fixing code review comments
- Loading branch information
1 parent
5e8157a
commit 1fed0a4
Showing
13 changed files
with
123 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
services/src/main/scala/cromwell/services/womtool/models/MetaValueElementJsonSupport.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cromwell.services.womtool.models | ||
|
||
import io.circe.{Encoder, Json} | ||
|
||
import wom.callable.MetaValueElement | ||
import wom.callable.MetaValueElement._ | ||
|
||
object MetaValueElementJsonSupport { | ||
|
||
// We only implement the encoder, because currently, the decoder is not required. | ||
implicit val metaValueElementEncoder: Encoder[MetaValueElement] = new Encoder[MetaValueElement] { | ||
final def apply(a : MetaValueElement) : Json = { | ||
a match { | ||
case MetaValueElementNull => | ||
Json.Null | ||
|
||
case MetaValueElementBoolean(b) => | ||
Json.fromBoolean(b) | ||
|
||
case MetaValueElementFloat(x) => | ||
Json.fromDouble(x).get | ||
|
||
case MetaValueElementInteger(a) => | ||
Json.fromInt(a) | ||
|
||
case MetaValueElementString(s) => | ||
Json.fromString(s) | ||
|
||
case MetaValueElementArray(vec) => | ||
Json.fromValues(vec.map(apply)) | ||
|
||
case MetaValueElementObject(m) => | ||
Json.fromFields(m.map{ case (key, value) => | ||
key -> apply(value) | ||
}) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,12 @@ task task_with_metas2 { | |
meta { | ||
author: "John Doe" | ||
email: "[email protected]" | ||
b : true | ||
zipcode: 94043 | ||
f : 1.3 | ||
numbers : [1, 2, 3] | ||
extras: { | ||
house : "With porch", | ||
cat : "Lucy" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -385,7 +385,17 @@ object WdlFileToWdlomSpec { | |
runtimeSection = None, | ||
metaSection = Some(MetaSectionElement( | ||
Map("author" -> MetaValueElementString("John Doe"), | ||
"email" -> MetaValueElementString("[email protected]")))), | ||
"email" -> MetaValueElementString("[email protected]"), | ||
"b" -> MetaValueElementBoolean(true), | ||
"zipcode" -> MetaValueElementInteger(94043), | ||
"f" -> MetaValueElementFloat(1.3), | ||
"numbers" -> MetaValueElementArray(Vector(MetaValueElementInteger(1), | ||
MetaValueElementInteger(2), | ||
MetaValueElementInteger(3))), | ||
"extras" -> MetaValueElementObject( | ||
Map( "house" -> MetaValueElementString("With porch"), | ||
"cat" -> MetaValueElementString("Lucy"))) | ||
))), | ||
parameterMetaSection = None, | ||
sourceLocation = Some(SourceFileLocation(3)) | ||
))), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ import wdl.model.draft3.elements.CommandPartElement.StringCommandPartElement | |
import wdl.model.draft3.elements.ExpressionElement.StringLiteral | ||
import wdl.transforms.base.wdlom2wom._ | ||
import wom.callable.Callable.{FixedInputDefinitionWithDefault, OptionalInputDefinition} | ||
import wom.callable.MetaValueElement.{MetaValueElementBoolean, MetaValueElementObject} | ||
import wom.callable.MetaValueElement._ | ||
import wom.callable.{CallableTaskDefinition, WorkflowDefinition} | ||
import wom.executable.WomBundle | ||
import wom.graph.expression.{ExposedExpressionNode, TaskCallInputExpressionNode} | ||
|
@@ -164,7 +164,16 @@ class WdlFileToWomSpec extends FlatSpec with Matchers { | |
private def validateMetaSection(b: WomBundle): Assertion = { | ||
val task = b.primaryCallable.get.asInstanceOf[CallableTaskDefinition] | ||
|
||
task.meta should be (Map("author" -> "John Doe", | ||
"email" -> "[email protected]")) | ||
task.meta should be (Map("author" -> MetaValueElementString("John Doe"), | ||
"email" -> MetaValueElementString("[email protected]"), | ||
"b" -> MetaValueElementBoolean(true), | ||
"zipcode" -> MetaValueElementInteger(94043), | ||
"f" -> MetaValueElementFloat(1.3), | ||
"numbers" -> MetaValueElementArray(Vector(MetaValueElementInteger(1), | ||
MetaValueElementInteger(2), | ||
MetaValueElementInteger(3))), | ||
"extras" -> MetaValueElementObject(Map("house" -> MetaValueElementString("With porch"), | ||
"cat" -> MetaValueElementString("Lucy"))) | ||
)) | ||
} | ||
} |
13 changes: 1 addition & 12 deletions
13
wdl/transforms/new-base/src/main/scala/wdl/transforms/base/wdlom2wom/Util.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,14 @@ | ||
package wdl.transforms.base.wdlom2wom | ||
|
||
import wdl.model.draft3.elements.{MetaSectionElement, ParameterMetaSectionElement} | ||
import wom.callable.MetaValueElement | ||
|
||
trait Util { | ||
|
||
def processMetaSections(meta: Option[MetaSectionElement], parameterMeta: Option[ParameterMetaSectionElement]) = { | ||
|
||
def stringifyMetaValues(meta: Map[String, MetaValueElement]): Map[String, String] = { | ||
meta map { | ||
case (key, MetaValueElement.MetaValueElementString(value)) => | ||
key -> value | ||
case (key, other) => | ||
key -> s"Compound types not yet supported, see #4746. String approximation: ${other.toString}" | ||
} | ||
} | ||
|
||
val metaMap = meta.map(_.meta).getOrElse(Map.empty) | ||
val parameterMetaMap = parameterMeta.map(_.metaAttributes).getOrElse(Map.empty) | ||
|
||
(stringifyMetaValues(metaMap), stringifyMetaValues(parameterMetaMap)) | ||
(metaMap, parameterMetaMap) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,4 @@ workflow three_step { | |
call wc { | ||
input: in_file = ps.procs | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters