-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Share new base transforms between WDL 1.0 and 1.1 #3852
Conversation
@cjllanwarne Do you need a red review on this ? If so could you elaborate just a little on what
means for me poor mortal and / or point to relevant code that I should look at ? 😄 |
The WDL map might help: This PR splits the top two circles into two parallel paths: The clever part is that the transform function can (but doesn't yet) be customised by replacing specific "AST to WDLOM" transformations with version specific functions (those are the |
c2899fd
to
41cf6f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few ToLs.
I know there's a tech talk next week for this, I don't know if we want to wait for that or not. I won't be there for it so depending on what you decide feel free to ignore my 👍
l.forall(_.isWhitespace) || l.dropWhile(_.isWhitespace).startsWith("#") | ||
} | ||
val start = trimStart.next.dropWhile(_.isWhitespace) | ||
start.startsWith("version 1.1") || start.startsWith("version biscayne") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if there's any project the wdl factories share but if so, looks like this code could be in it since it's almost the same here and in draft 3
@@ -0,0 +1,57 @@ | |||
//package wdl.transforms.base.ast2wdlom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove ?
(implicit astNodeToExpressionElement: CheckedAtoB[GenericAstNode, TypeElement]): Checked[TypeElement] = typeAst.getAttributeAs[String]("name") flatMap { | ||
case "Array" => typeAst.getAttributeAsVector[TypeElement]("subtype") flatMap { | ||
case one if one.size == 1 => ArrayTypeElement(one.head).validNelCheck | ||
case other => s"Arrays must have exactly one type parameter, but got ${other.size}".invalidNelCheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToL: maybe also say what the provided types were in the error message ? (here and below if so)
) | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of room here 😄
cf6d2b2
to
1d61bf0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still looking, some minor comments so far. I'd love to brainstorm a clever Scala-ey way to reduce code duplication.
@@ -205,7 +205,7 @@ object EngineFunctionEvaluators { | |||
read <- readFile(fileToRead, ioFunctionSet, fileSizeLimitationConfig.readBoolLimit) | |||
asBool <- Try(read.trim.toBoolean) | |||
} yield WomBoolean(asBool) | |||
tryResult.map(EvaluatedValue(_, Seq.empty)).toErrorOr.contextualizeErrors(s"""read_boolean("${fileToRead.value}")""") | |||
tryResult.map(EvaluatedValue(_, Seq.empty)).toErrorOr.contextualizeErrors(s"""read_int("${fileToRead.value}")""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentional change? Seems incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah... very good catch! I have no idea what caused this but it's definitely not right...
@@ -0,0 +1,34 @@ | |||
package wdl.transforms.biscayne.ast2wdlom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use type parameters to reduce duplication between this file and Draft3GenericAstNode.scala
? The only difference seems to be the type of the Ast
(wdl.draft3.parser.WdlParser.Ast
vs. wdl.biscayne.parser.WdlParser.Ast
).
Incomplete but illustrates what I'm getting at:
case class BaseGenericAst[T <: GenericAstNode](ast: T) extends GenericAst {
override def getAttribute(attr: String): GenericAstNode = Option(ast.getAttribute(attr)).map(T.apply).orNull
override def getAttributes: Map[String, GenericAstNode] = ast.getAttributes.asScala.toMap collect {
case (key, value) if value != null => key -> T(value)
}
override def getName: String = ast.getName
}
@@ -0,0 +1,62 @@ | |||
package wdl.transforms.biscayne |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency and ease of navigation, it probably makes sense to unify the file name between Biscayne and draft-3:
wdl/transforms/draft3/src/main/scala/wdl/draft3/transforms/ast2wdlom/package.scala
wdl/transforms/biscayne/src/main/scala/wdl/transforms/biscayne/ast2wdlom/ast2wdlom.scala
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thumbing provisional on
- fixing or clarifying the
read_boolean()
toread_int()
change - addressing (or saying why not) the
ast2wdlom.scala
vs.package.scala
comment
1d61bf0
to
894824d
Compare
Allows reading of WDL 1.0 and 1.1
Ast
s through a shared set ofCheckedAtoB
functions, with the flexibility to inject different transform behavior into each usage of the instantiations of the transforms.Note: of the 9013 added lines, 7484 are the new 1.1 WDL parser and presumably about 810 are files which got moved out of draft-3/transforms and into base/transforms