Skip to content

Commit 047fcf2

Browse files
authored
Upgrade to wdl4s version 0.15
* Setting the bar higher on compiler warnings * Removing unused imports from unit tests
1 parent 8c6f394 commit 047fcf2

31 files changed

+300
-414
lines changed

build.sbt

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,52 @@ resolvers ++= Seq(
1515
)
1616

1717
// Show deprecation warnings
18-
scalacOptions ++= Seq("-unchecked", "-deprecation")
18+
scalacOptions ++= Seq(
19+
"-unchecked",
20+
"-deprecation",
21+
"-feature",
22+
"-explaintypes",
23+
"-encoding", "UTF-8",
24+
25+
/* "-Xfuture",
26+
"-Xlint:adapted-args",
27+
"-Xlint:by-name-right-associative",
28+
"-Xlint:constant", */
29+
"-Xlint:delayedinit-select",
30+
"-Xlint:doc-detached",
31+
"-Xlint:inaccessible",
32+
"-Xlint:infer-any",
33+
"-Xlint:missing-interpolator",
34+
"-Xlint:nullary-override",
35+
"-Xlint:nullary-unit",
36+
"-Xlint:option-implicit",
37+
"-Xlint:package-object-classes",
38+
"-Xlint:poly-implicit-overload",
39+
"-Xlint:private-shadow",
40+
"-Xlint:stars-align",
41+
"-Xlint:type-parameter-shadow",
42+
// "-Xlint:unsound-match",
43+
// "-Yno-adapted-args",
44+
"-Ywarn-dead-code",
45+
// "-Ywarn-numeric-widen",
46+
// "-Ywarn-value-discard",
47+
"-Ywarn-inaccessible",
48+
// "-Ywarn-unused:implicits",
49+
// "-Ywarn-unused:privates"
50+
// "-Ywarn-unused:locals"
51+
// "-Ywarn-unused:patvars"
52+
53+
"-Ywarn-unused:imports", // warns about every unused import on every command.
54+
"-Xfatal-warnings" // makes those warnings fatal.
55+
)
1956

2057
// Assembly settings
2158
assemblyJarName in assembly := "dxWDL.jar"
2259
logLevel in assembly := Level.Info
2360
assemblyOutputPath in assembly := file("applet_resources/resources/dxWDL.jar")
2461

2562
libraryDependencies ++= Seq(
26-
"org.broadinstitute" %% "wdl4s" % "0.13",
63+
"org.broadinstitute" %% "wdl4s-wdl" % "0.15",
2764
"io.spray" %% "spray-json" % "1.3.2",
2865
"net.jcazevedo" %% "moultingyaml" % "0.4.0",
2966
"com.typesafe" % "config" % "1.3.1",

reference_stanza.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
dxWDL {
2-
version = "0.39"
2+
version = "0.40"
33
asset_ids = []
44
}

src/main/scala/dxWDL/CompilerErrorFormatter.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package dxWDL
22

3-
import wdl4s.AstTools
4-
import wdl4s.parser.WdlParser.{Ast, AstNode, Terminal}
5-
import wdl4s._
3+
import wdl4s.wdl.AstTools
4+
import wdl4s.parser.WdlParser.{Ast, Terminal}
5+
import wdl4s.wdl._
66

7-
case class CompilerErrorFormatter(terminalMap: Map[Terminal, WdlSource]) {
7+
case class CompilerErrorFormatter(terminalMap: Map[Terminal, WorkflowSource]) {
88
private def pointToSource(t: Terminal): String = s"${line(t)}\n${" " * (t.getColumn - 1)}^"
99
private def line(t:Terminal): String = terminalMap.get(t).get.split("\n")(t.getLine - 1)
1010

@@ -40,7 +40,7 @@ case class CompilerErrorFormatter(terminalMap: Map[Terminal, WdlSource]) {
4040
|""".stripMargin
4141
}
4242

43-
def illegalCallName(call: Call) : String = {
43+
def illegalCallName(call: WdlCall) : String = {
4444
val name: Terminal = call.ast.getAttribute("name").asInstanceOf[Terminal]
4545
s"""|Illegal call name
4646
|

src/main/scala/dxWDL/CompilerIR.scala

Lines changed: 48 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22
*/
33
package dxWDL
44

5-
import java.nio.file.{Files, Paths, Path}
65
import net.jcazevedo.moultingyaml._
7-
import net.jcazevedo.moultingyaml.DefaultYamlProtocol._
86
import scala.util.{Failure, Success, Try}
9-
import spray.json._
10-
import wdl4s._
11-
import wdl4s.AstTools
12-
import wdl4s.AstTools.EnhancedAstNode
13-
import wdl4s.expression._
14-
import wdl4s.parser.WdlParser.{Ast, AstNode, Terminal}
15-
import wdl4s.types._
16-
import wdl4s.values._
17-
import wdl4s.WdlExpression.AstForExpressions
7+
import wdl4s.wdl._
8+
import wdl4s.wdl.AstTools
9+
import wdl4s.wdl.AstTools.EnhancedAstNode
10+
import wdl4s.wdl.expression._
11+
import wdl4s.parser.WdlParser.{Ast, Terminal}
12+
import wdl4s.wdl.types._
13+
import wdl4s.wdl.values._
14+
import wdl4s.wdl.WdlExpression.AstForExpressions
1815

1916
case class CompilerIR(gWorkflowOutputs: Option[Seq[WorkflowOutput]],
2017
destination: String,
@@ -85,7 +82,7 @@ task Add {
8582
Int result
8683
}
8784
*/
88-
def genAppletStub(applet: IR.Applet, scope: Scope) : Task = {
85+
def genAppletStub(applet: IR.Applet, scope: Scope) : WdlTask = {
8986
val task = WdlRewrite.taskGenEmpty(applet.name, scope)
9087
val inputs = applet.inputs.map{ cVar =>
9188
WdlRewrite.declaration(cVar.wdlType, cVar.name, None)
@@ -113,7 +110,7 @@ task Add {
113110
WdlExpression.fromString(sExpr)
114111
}
115112

116-
def callUniqueName(call : Call) = {
113+
def callUniqueName(call : WdlCall) = {
117114
val nm = call.alias match {
118115
case Some(x) => x
119116
case None => Utils.taskOfCall(call).name
@@ -136,11 +133,11 @@ task Add {
136133
// that, in the general case, could be calculated only at runtime.
137134
// Currently, we support only constants. If a runtime expression is used,
138135
// we convert it to a moderatly high constant.
139-
def calcInstanceType(taskOpt: Option[Task]) : IR.InstanceType = {
136+
def calcInstanceType(taskOpt: Option[WdlTask]) : IR.InstanceType = {
140137
def lookup(varName : String) : WdlValue = {
141138
throw new DynamicInstanceTypesException()
142139
}
143-
def evalAttr(task: Task, attrName: String) : Option[WdlValue] = {
140+
def evalAttr(task: WdlTask, attrName: String) : Option[WdlValue] = {
144141
task.runtimeAttributes.attrs.get(attrName) match {
145142
case None => None
146143
case Some(expr) =>
@@ -244,11 +241,6 @@ task Add {
244241
case a: Ast if a.isMemberAccess =>
245242
// This is a case of accessing something like A.B.C
246243
// The RHS is C, and the LHS is A.B
247-
val rhs : Terminal = a.getAttribute("rhs") match {
248-
case rhs:Terminal if rhs.getTerminalStr == "identifier" => rhs
249-
case _ => throw new Exception(cef.rightSideMustBeIdentifer(a))
250-
}
251-
252244
// The FQN is "A.B.C"
253245
val fqn = WdlExpression.toString(a)
254246
env.get(fqn) match {
@@ -264,8 +256,8 @@ task Add {
264256
// This is an expression like A.B.C
265257
varRef => WdlExpression.toString(varRef)
266258
)
267-
val variables = AstTools.findVariableReferences(a).map{ case t:Terminal =>
268-
WdlExpression.toString(t)
259+
val variables = AstTools.findVariableReferences(a).map{
260+
varRef => varRef.terminal.getSourceString
269261
}
270262
val allDeps = (memberAccesses ++ variables).map{ fqn =>
271263
env.get(fqn) match {
@@ -297,7 +289,7 @@ task Add {
297289
// Print a WDL workflow that evaluates expressions
298290
def genEvalWorkflowFromDeclarations(name: String,
299291
declarations_i: Seq[Declaration],
300-
outputs: Vector[IR.CVar]) : Workflow = {
292+
outputs: Vector[IR.CVar]) : WdlWorkflow = {
301293
val declarations =
302294
if (declarations_i.isEmpty) {
303295
// Corner case: there are no inputs and no
@@ -359,9 +351,9 @@ task Add {
359351
val outputVars: Vector[IR.CVar] = declarations.map{ decl =>
360352
IR.CVar(decl.unqualifiedName, decl.wdlType, DeclAttrs.empty, decl.ast)
361353
}.toVector
362-
val code:Workflow = genEvalWorkflowFromDeclarations(appletName,
363-
declarations,
364-
outputVars)
354+
val code:WdlWorkflow = genEvalWorkflowFromDeclarations(appletName,
355+
declarations,
356+
outputVars)
365357

366358
// We need minimal compute resources, use the default instance type
367359
val applet = IR.Applet(appletName,
@@ -432,7 +424,7 @@ workflow w {
432424
case None => decl
433425
}
434426
}.toVector
435-
val code:Workflow = genEvalWorkflowFromDeclarations(appletName,
427+
val code:WdlWorkflow = genEvalWorkflowFromDeclarations(appletName,
436428
inputDecls ++ outputDeclarations,
437429
outputVars)
438430

@@ -513,7 +505,7 @@ workflow w {
513505
val (outputs, outputVars) = outputPairs.unzip
514506

515507
// Create a workflow with no calls.
516-
val code:Workflow = WdlRewrite.workflowGenEmpty("w")
508+
val code:WdlWorkflow = WdlRewrite.workflowGenEmpty("w")
517509
code.children = inputDecls ++ outputs
518510

519511
// Should we reorganize the output folder?
@@ -540,7 +532,7 @@ workflow w {
540532
}
541533

542534
// Compile a WDL task into an applet
543-
def compileTask(task : Task) : (IR.Applet, Vector[IR.CVar]) = {
535+
def compileTask(task : WdlTask) : (IR.Applet, Vector[IR.CVar]) = {
544536
Utils.trace(verbose.on, s"Compiling task ${task.name}")
545537

546538
// The task inputs are those that do not have expressions
@@ -574,19 +566,19 @@ workflow w {
574566
(applet, outputVars)
575567
}
576568

577-
def taskOfCall(call:Call): Task = {
569+
def taskOfCall(call:WdlCall): WdlTask = {
578570
call match {
579-
case x:TaskCall => x.task
580-
case x:WorkflowCall =>
571+
case x:WdlTaskCall => x.task
572+
case x:WdlWorkflowCall =>
581573
throw new Exception(cef.notCurrentlySupported(call.ast, s"calling a workflow"))
582574
}
583575
}
584576

585-
def findInputByName(call: Call, cVar: IR.CVar) : Option[(String,WdlExpression)] = {
577+
def findInputByName(call: WdlCall, cVar: IR.CVar) : Option[(String,WdlExpression)] = {
586578
call.inputMappings.find{ case (k,v) => k == cVar.name }
587579
}
588580

589-
def compileCall(call: Call,
581+
def compileCall(call: WdlCall,
590582
taskApplets: Map[String, (IR.Applet, Vector[IR.CVar])],
591583
env : CallEnv) : IR.Stage = {
592584
// Find the right applet
@@ -643,10 +635,10 @@ workflow w {
643635

644636
// Split a block (Scatter, If, ..) into the top declarations,
645637
// the and the bottom calls.
646-
def blockSplit(children: Vector[Scope]) : (Vector[Declaration], Vector[Call]) = {
638+
def blockSplit(children: Vector[Scope]) : (Vector[Declaration], Vector[WdlCall]) = {
647639
val (topDecls, rest) = Utils.splitBlockDeclarations(children.toList)
648-
val calls : Seq[Call] = rest.map {
649-
case call: Call => call
640+
val calls : Seq[WdlCall] = rest.map {
641+
case call: WdlCall => call
650642
case decl:Declaration =>
651643
throw new Exception(cef.notCurrentlySupported(decl.ast,
652644
"declaration in the middle of a block"))
@@ -667,7 +659,7 @@ workflow w {
667659
def blockInputs(preDecls: Vector[Declaration],
668660
topBlockExpr: WdlExpression,
669661
topDecls: Vector[Declaration],
670-
calls: Vector[Call],
662+
calls: Vector[WdlCall],
671663
env : CallEnv) : (Map[String, LinkedVar], Vector[IR.CVar]) = {
672664
var closure = Map.empty[String, LinkedVar]
673665
preDecls.foreach { decl =>
@@ -713,11 +705,11 @@ workflow w {
713705
// A variable generated by the compiler. It might be used only
714706
// locally.
715707
// find all dependent nodes
716-
val dNodes:Set[GraphNode] = decl.downstream
708+
val dNodes:Set[WdlGraphNode] = decl.downstream
717709
val declParent:Scope = decl.parent.get
718710

719711
// figure out if these downstream nodes are in the same scope.
720-
val dnScopes:Set[GraphNode] = dNodes.filter{ node =>
712+
val dnScopes:Set[WdlGraphNode] = dNodes.filter{ node =>
721713
node.parent.get.fullyQualifiedName != declParent.fullyQualifiedName
722714
}
723715
dnScopes.isEmpty
@@ -755,7 +747,7 @@ workflow w {
755747
.map( decl => IR.CVar(decl.unqualifiedName, decl.wdlType, DeclAttrs.empty, decl.ast) )
756748
.toVector
757749
val outputVars : Vector[IR.CVar] = children.map {
758-
case call:TaskCall =>
750+
case call:WdlTaskCall =>
759751
val task = taskOfCall(call)
760752
task.outputs.map { tso =>
761753
val varName = callUniqueName(call) ++ "." ++ tso.unqualifiedName
@@ -777,7 +769,7 @@ workflow w {
777769
// Check for each task input, if it is unbound. Make a list, and
778770
// prefix each variable with the call name. This makes it unique
779771
// as a scatter input.
780-
def unspecifiedInputs(call: Call,
772+
def unspecifiedInputs(call: WdlCall,
781773
taskApplets: Map[String, (IR.Applet, Vector[IR.CVar])])
782774
: Vector[IR.CVar] = {
783775
val task = taskOfCall(call)
@@ -823,7 +815,7 @@ workflow w {
823815
// transform the expressions in a scatter
824816
def transformChild(scope: Scope): Scope = {
825817
scope match {
826-
case tc:TaskCall =>
818+
case tc:WdlTaskCall =>
827819
val inputs = tc.inputMappings.map{ case (k,expr) => (k, transform(expr)) }.toMap
828820
WdlRewrite.taskCall(tc, inputs)
829821
case d:Declaration =>
@@ -858,12 +850,12 @@ workflow w {
858850
// calls. However, a scatter calls tasks, that are missing from
859851
// the WDL file we generate. To ameliorate this, we add stubs
860852
// for called tasks.
861-
val calls: Vector[Call] = scope.calls.toVector
862-
val taskStubs: Map[String, Task] =
863-
calls.foldLeft(Map.empty[String,Task]) { case (accu, call) =>
853+
val calls: Vector[WdlCall] = scope.calls.toVector
854+
val taskStubs: Map[String, WdlTask] =
855+
calls.foldLeft(Map.empty[String,WdlTask]) { case (accu, call) =>
864856
val name = call match {
865-
case x:TaskCall => x.task.name
866-
case x:WorkflowCall =>
857+
case x:WdlTaskCall => x.task.name
858+
case x:WdlWorkflowCall =>
867859
throw new Exception(cef.notCurrentlySupported(x.ast, "calling workflows"))
868860
}
869861
val (irApplet,_) = taskApplets.get(name) match {
@@ -986,7 +978,7 @@ workflow w {
986978
}
987979

988980
// Compile a workflow, having compiled the independent tasks.
989-
def compileWorkflow(wf: Workflow,
981+
def compileWorkflow(wf: WdlWorkflow,
990982
taskApplets: Map[String, (IR.Applet, Vector[IR.CVar])]) : IR.Workflow = {
991983
Utils.trace(verbose.on, "IR: compiling workflow")
992984

@@ -1033,7 +1025,7 @@ workflow w {
10331025
val (stage, applet) = compileScatter(wf.unqualifiedName, scatterName, preDecls,
10341026
scatter, taskApplets, env)
10351027
(stage, Some(applet))
1036-
case BlockScope(call: Call) =>
1028+
case BlockScope(call: WdlCall) =>
10371029
val stage = compileCall(call, taskApplets, env)
10381030
(stage, None)
10391031
case BlockScope(x) =>
@@ -1047,7 +1039,7 @@ workflow w {
10471039
case BlockDecl(decls) => cVar.name
10481040
case BlockIf(_, _) => cVar.name
10491041
case BlockScatter(_, _) => cVar.name
1050-
case BlockScope(call : Call) => stage.name ++ "." ++ cVar.name
1042+
case BlockScope(call : WdlCall) => stage.name ++ "." ++ cVar.name
10511043
case _ => throw new Exception("Sanity")
10521044
}
10531045
env = env + (fqVarName ->
@@ -1075,13 +1067,13 @@ workflow w {
10751067
}
10761068

10771069
// Load imported tasks
1078-
def loadImportedTasks(ns: WdlNamespace) : Set[Task] = {
1070+
def loadImportedTasks(ns: WdlNamespace) : Set[WdlTask] = {
10791071
// Make a pass, and figure out what we access
10801072
//
1081-
ns.taskCalls.map{ call:TaskCall =>
1073+
ns.taskCalls.map{ call:WdlTaskCall =>
10821074
val taskFqn = call.task.fullyQualifiedName
10831075
ns.resolve(taskFqn) match {
1084-
case Some(task:Task) => task
1076+
case Some(task:WdlTask) => task
10851077
case x => throw new Exception(s"Resolved call to ${taskFqn} and got (${x})")
10861078
}
10871079
}.toSet
@@ -1092,13 +1084,13 @@ workflow w {
10921084
Utils.trace(verbose.on, "IR pass")
10931085

10941086
// Load all accessed applets, local or imported
1095-
val accessedTasks: Set[Task] = loadImportedTasks(ns)
1087+
val accessedTasks: Set[WdlTask] = loadImportedTasks(ns)
10961088
val accessedTaskNames = accessedTasks.map(task => task.name)
10971089
Utils.trace(verbose.on, s"Accessed tasks = ${accessedTaskNames}")
10981090

10991091
// Make sure all local tasks are included; we want to compile
11001092
// them even if they are not accessed.
1101-
val allTasks:Set[Task] = accessedTasks ++ ns.tasks.toSet
1093+
val allTasks:Set[WdlTask] = accessedTasks ++ ns.tasks.toSet
11021094

11031095
// compile all the tasks into applets
11041096
Utils.trace(verbose.on, "compiling tasks into dx:applets")

0 commit comments

Comments
 (0)