Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Move cross-building to 2.12 and 2.13 (#356)
Browse files Browse the repository at this point in the history
* Moving cross-building to 2.12 and 2.13.
  • Loading branch information
tfenne authored Aug 6, 2019
1 parent 32d96a9 commit e2a634a
Show file tree
Hide file tree
Showing 54 changed files with 219 additions and 231 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sudo: required
dist: trusty
language: scala
scala:
- 2.12.2
Expand Down
15 changes: 8 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ lazy val commonSettings = Seq(
organizationHomepage := Some(url("http://www.fulcrumgenomics.com")),
homepage := Some(url("https://github.com/fulcrumgenomics/dagr")),
startYear := Some(2015),
scalaVersion := "2.12.6",
crossScalaVersions := Seq("2.12.6", "2.11.12"),
scalacOptions += "-target:jvm-1.8",
scalaVersion := "2.13.0",
crossScalaVersions := Seq("2.12.8", "2.13.0"),
scalacOptions ++= Seq("-target:jvm-1.8", "-deprecation"),
scalacOptions in (Compile, doc) ++= docScalacOptions,
scalacOptions in (Test, doc) ++= docScalacOptions,
autoAPIMappings := true,
Expand All @@ -111,7 +111,7 @@ lazy val commonSettings = Seq(
// See https://github.com/sbt/sbt/issues/653
// and https://github.com/travis-ci/travis-ci/issues/3775
javaOptions in Test += "-Xmx1G",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test->*" excludeAll ExclusionRule(organization="org.junit", name="junit"),
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % "test->*" excludeAll ExclusionRule(organization="org.junit", name="junit"),
assemblyJarName in assembly := s"${name.value}-${version.value}.jar"
) ++ Defaults.coreDefaultSettings ++ sonatypeSettings

Expand All @@ -123,14 +123,15 @@ lazy val core = Project(id="dagr-core", base=file("core"))
.settings(description := "Core methods and classes to execute tasks in dagr.")
.settings(
libraryDependencies ++= Seq(
"com.fulcrumgenomics" %% "commons" % "0.6.1",
"com.fulcrumgenomics" %% "sopt" % "0.6.1",
"com.fulcrumgenomics" %% "commons" % "0.8.0-87f4b88-SNAPSHOT",
"com.fulcrumgenomics" %% "sopt" % "0.8.0-6330673-SNAPSHOT",
"com.github.dblock" % "oshi-core" % "3.3",
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"org.reflections" % "reflections" % "0.9.10",
"com.typesafe" % "config" % "1.3.2",
"javax.servlet" % "javax.servlet-api" % "3.1.0"
"javax.servlet" % "javax.servlet-api" % "3.1.0",
"jline" % "jline" % "2.14.2"
)
)
.disablePlugins(sbtassembly.AssemblyPlugin)
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/dagr/core/cmdline/DagrCoreMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class DagrCoreMain extends LazyLogging {

val startTime = System.currentTimeMillis()
val packages = Sopt.find[Pipeline](packageList, includeHidden=includeHidden)
val exit = Sopt.parseCommandAndSubCommand[DagrCoreArgs,Pipeline](name, args, packages) match {
val exit = Sopt.parseCommandAndSubCommand[DagrCoreArgs,Pipeline](name, args.toIndexedSeq, packages) match {
case Sopt.Failure(usage) =>
System.err.print(usage())
1
Expand Down Expand Up @@ -267,7 +267,7 @@ class DagrCoreMain extends LazyLogging {

/** Loads the various dagr scripts and puts them on the classpath. */
private def loadScripts(args: Array[String]): Unit = {
val tokenizer = new ArgTokenizer(args, argFilePrefix=Some("@"))
val tokenizer = new ArgTokenizer(args.toIndexedSeq, argFilePrefix=Some("@"))
val collator = new ArgTokenCollator(tokenizer)
collator.filter(_.isSuccess).foreach {
case Success(ArgOptionAndValues(name: String, values: Seq[String])) if name == "scripts" =>
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/dagr/core/cmdline/DagrScriptManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import java.nio.file.Path

import com.fulcrumgenomics.commons.io.Io
import com.fulcrumgenomics.commons.util.{LazyLogging, LogLevel}
import com.fulcrumgenomics.commons.CommonsDef._
import org.reflections.util.ClasspathHelper

import scala.collection.JavaConversions._
import scala.reflect.internal.util.{FakePos, NoPosition, Position, StringOps}
import scala.tools.nsc.io.PlainFile
import scala.tools.nsc.reporters.AbstractReporter
Expand All @@ -52,7 +52,7 @@ object DagrScriptManager {
* HACK: Uses reflection to modify the class path, and assumes loader is a URLClassLoader.
* @param urls URLs to add to the system class loader classpath.
*/
private def addToClasspath(urls: Traversable[URL]): Unit = {
private def addToClasspath(urls: Iterable[URL]): Unit = {
Thread.currentThread().setContextClassLoader(new URLClassLoader(urls.toArray, Thread.currentThread().getContextClassLoader))
}

Expand Down Expand Up @@ -156,7 +156,7 @@ private[core] class DagrScriptManager extends LazyLogging {
* Compiles and loads the scripts in the files into the current classloader.
* Heavily based on scala/src/compiler/scala/tools/ant/Scalac.scala
*/
def loadScripts(scripts: Traversable[Path], tempDir: Path, quiet: Boolean = true): Unit = {
def loadScripts(scripts: Iterable[Path], tempDir: Path, quiet: Boolean = true): Unit = {
// Make sure the scripts actually exist and we can write to the tempDir
Io.assertReadable(scripts)
Io.assertWritableDirectory(tempDir)
Expand Down
19 changes: 10 additions & 9 deletions core/src/main/scala/dagr/core/config/Configuration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ import java.io.File
import java.nio.file.{Files, Path}
import java.time.Duration

import com.typesafe.config.{ConfigParseOptions, ConfigFactory, Config}
import com.fulcrumgenomics.commons.CommonsDef._
import com.typesafe.config.{Config, ConfigFactory, ConfigParseOptions}
import com.typesafe.config.ConfigException.Generic
import com.fulcrumgenomics.commons.io.PathUtil._
import com.fulcrumgenomics.commons.util.LazyLogging
import dagr.core.execsystem.{Cores, Memory}


import scala.collection.SortedSet
import scala.reflect.runtime.universe.{TypeTag, typeOf}
import collection.JavaConversions._

/**
* Companion object to the Configuration trait that keeps track of all configuration keys
Expand Down Expand Up @@ -115,7 +116,7 @@ private[config] trait ConfigurationLike extends LazyLogging {
case t if t =:= typeOf[Path] => pathTo(config.getString(path)).asInstanceOf[T]
case t if t =:= typeOf[Duration] => config.getDuration(path).asInstanceOf[T]
// TODO: replace this with better handling of List/Seq/Array
case t if t =:= typeOf[List[String]] => config.getStringList(path).toList.asInstanceOf[T]
case t if t =:= typeOf[List[String]] => config.getStringList(path).iterator.toList.asInstanceOf[T]
case t if t =:= typeOf[Cores] => Cores(config.getDouble(path)).asInstanceOf[T]
case t if t =:= typeOf[Memory] => Memory(config.getString(path)).asInstanceOf[T]
case _ => throw new IllegalArgumentException("Don't know how to configure a " + typeOf[T])
Expand All @@ -127,7 +128,7 @@ private[config] trait ConfigurationLike extends LazyLogging {
* a None will be returned, else a Some(T) of the appropriate type.
*/
def optionallyConfigure[T : TypeTag](path: String) : Option[T] = {
Configuration.RequestedKeys += path
Configuration.RequestedKeys.add(path)
if (config.hasPath(path)) Some(configure[T](path))
else None
}
Expand All @@ -138,7 +139,7 @@ private[config] trait ConfigurationLike extends LazyLogging {
* exception is thrown.
*/
def configure[T : TypeTag](path: String) : T = {
Configuration.RequestedKeys += path
Configuration.RequestedKeys.add(path)
try {
asType[T](path)
}
Expand All @@ -154,7 +155,7 @@ private[config] trait ConfigurationLike extends LazyLogging {
*/
def configure[T : TypeTag](path: String, defaultValue: T) : T = {
try {
Configuration.RequestedKeys += path
Configuration.RequestedKeys.add(path)
if (config.hasPath(path)) configure[T](path)
else defaultValue
}
Expand All @@ -175,7 +176,7 @@ private[config] trait ConfigurationLike extends LazyLogging {
* @return An absolute path to the executable to use
*/
def configureExecutable(path: String, executable: String) : Path = {
Configuration.RequestedKeys += path
Configuration.RequestedKeys.add(path)

optionallyConfigure[Path](path) match {
case Some(exec) => exec
Expand All @@ -199,7 +200,7 @@ private[config] trait ConfigurationLike extends LazyLogging {
* @return An absolute path to the executable to use
*/
def configureExecutableFromBinDirectory(binPath: String, executable: String, subDir: Option[Path] = None) : Path = {
Configuration.RequestedKeys += binPath
Configuration.RequestedKeys.add(binPath)

optionallyConfigure[Path](binPath) match {
case Some(exec) =>
Expand All @@ -222,7 +223,7 @@ private[config] trait ConfigurationLike extends LazyLogging {
* Grabs the config key "PATH" which, if not defined in config will default to the environment variable
* PATH, splits it on the path separator and returns it as a Seq[String]
*/
protected def systemPath : Seq[Path] = config.getString(Configuration.Keys.SystemPath).split(File.pathSeparatorChar).view.map(pathTo(_))
protected def systemPath : Seq[Path] = config.getString(Configuration.Keys.SystemPath).split(File.pathSeparatorChar).toSeq.map(pathTo(_))

/** Removes various characters from the simple class name, for scala class names. */
private def sanitizeSimpleClassName(className: String): String = {
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/dagr/core/execsystem/GraphNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import scala.collection.mutable.ListBuffer
* nodes are [[dagr.core.tasksystem.Pipeline]]s.
*/
class GraphNode(var task: Task,
predecessorNodes: Traversable[GraphNode] = Nil,
predecessorNodes: Iterable[GraphNode] = Nil,
var state: GraphNodeState.Value = GraphNodeState.PREDECESSORS_AND_UNEXPANDED,
val enclosingNode: Option[GraphNode] = None) extends BaseGraphNode {

Expand Down Expand Up @@ -89,8 +89,8 @@ class GraphNode(var task: Task,
* @param predecessor the predecessor(s) to add
* @return true if the predecessor was not already added and added successfully, false otherwise
*/
def addPredecessors(predecessor: Traversable[GraphNode]): Boolean = {
addPredecessors(predecessor.toArray:_*)
def addPredecessors(predecessor: Iterable[GraphNode]): Boolean = {
addPredecessors(predecessor.toSeq:_*)
}

/** Get the predecessors
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/dagr/core/execsystem/NaiveScheduler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class NaiveScheduler extends Scheduler {
* Takes the list of tasks that could be scheduled if their resource needs can be met and attempts
* to schedule a single task for execution.
*/
private[execsystem] def scheduleOneTask(readyTasks: Traversable[UnitTask],
private[execsystem] def scheduleOneTask(readyTasks: Iterable[UnitTask],
remainingSystemCores: Cores,
remainingSystemMemory: Memory,
remainingJvmMemory: Memory): Option[(UnitTask, ResourceSet)] = {
Expand Down Expand Up @@ -64,7 +64,7 @@ class NaiveScheduler extends Scheduler {
* @param remainingJvmMemory the set of remaining JVM memory, not including running tasks.
* @return a map of tasks should be scheduled and their allocate resources.
*/
private def scheduleOnce(readyTasks: Traversable[UnitTask],
private def scheduleOnce(readyTasks: Iterable[UnitTask],
remainingSystemCores: Cores,
remainingSystemMemory: Memory,
remainingJvmMemory: Memory): List[(UnitTask, ResourceSet)] = {
Expand Down Expand Up @@ -111,7 +111,7 @@ class NaiveScheduler extends Scheduler {
* @param jvmMemory the JVM memory available.
* @return the map of tasks should be scheduled.
*/
override def schedule(readyTasks: Traversable[UnitTask],
override def schedule(readyTasks: Iterable[UnitTask],
systemCores: Cores,
systemMemory: Memory,
jvmMemory: Memory
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/dagr/core/execsystem/ResourceSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ case class ResourceSet(cores: Cores = Cores.none, memory: Memory = Memory.none)
def subset(minCores: Cores, maxCores: Cores, memory: Memory) : Option[ResourceSet] = {
val min = minCores.value
val max = maxCores.value
val cores = max.to(min, -1).find(cores => subset(Cores(cores), memory).isDefined)
cores.map(c => ResourceSet(Cores(c), memory))
val cores = Range.BigDecimal.inclusive(max, min, -1).find(cores => subset(Cores(cores.doubleValue), memory).isDefined)
cores.map(c => ResourceSet(Cores(c.doubleValue), memory))
}

/**
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/dagr/core/execsystem/Scheduler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ abstract class Scheduler extends LazyLogging {
* @return a map of tasks should be scheduled and their allocate resources.
* */
final def schedule(runningTasks: Map[UnitTask, ResourceSet],
readyTasks: Traversable[UnitTask],
readyTasks: Iterable[UnitTask],
systemCores: Cores,
systemMemory: Memory,
jvmMemory: Memory): Map[UnitTask, ResourceSet] = {
Expand Down Expand Up @@ -77,7 +77,7 @@ abstract class Scheduler extends LazyLogging {
/** All schedulers should implement this method. Returns a map of scheduled tasks to their resources to use
* while running.
*/
protected def schedule(readyTasks: Traversable[UnitTask],
protected def schedule(readyTasks: Iterable[UnitTask],
systemCores: Cores,
systemMemory: Memory,
jvmMemory: Memory): Map[UnitTask, ResourceSet]
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/dagr/core/execsystem/TaskManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ class TaskManager(taskManagerResources: SystemResources = TaskManagerDefaults.de

protected[core] def readyTasksList: List[UnitTask] = graphNodesInStateFor(NO_PREDECESSORS).toList.map(node => node.task.asInstanceOf[UnitTask])

override def stepExecution(): (Traversable[Task], Traversable[Task], Traversable[Task], Traversable[Task]) = {
override def stepExecution(): (Iterable[Task], Iterable[Task], Iterable[Task], Iterable[Task]) = {
logger.debug("runSchedulerOnce: starting one round of execution")

// get newly completed tasks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,5 @@ private[execsystem] trait TaskManagerLike {
* (3) tasks that are running prior to scheduling.
* (4) the tasks that have completed prior to scheduling.
*/
def stepExecution(): (Traversable[Task], Traversable[Task], Traversable[Task], Traversable[Task])
def stepExecution(): (Iterable[Task], Iterable[Task], Iterable[Task], Iterable[Task])
}
8 changes: 4 additions & 4 deletions core/src/main/scala/dagr/core/execsystem/TaskTracker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ trait TaskTracker extends TaskManagerLike with LazyLogging {
* @param ignoreExists true if we just return the task id for already added tasks, false if we are to throw an [[IllegalArgumentException]]
* @return the task identifiers.
*/
protected[execsystem] def addTasks(tasks: Traversable[Task], enclosingNode: Option[GraphNode] = None, ignoreExists: Boolean = false): List[TaskId] = {
protected[execsystem] def addTasks(tasks: Iterable[Task], enclosingNode: Option[GraphNode] = None, ignoreExists: Boolean = false): List[TaskId] = {
tasks.map(task => addTask(task=task, enclosingNode=enclosingNode, ignoreExists=ignoreExists)).toList
}

Expand Down Expand Up @@ -286,11 +286,11 @@ trait TaskTracker extends TaskManagerLike with LazyLogging {
* @return the list of precedessors, or Nil if this task has no predecessors. If there were predecessors that
* are not currently being tracked, None will be returned instead.
*/
protected def predecessorsOf(task: Task): Option[Traversable[GraphNode]] = {
protected def predecessorsOf(task: Task): Option[Iterable[GraphNode]] = {
task.tasksDependedOn match {
case Nil => Some(Nil)
case _ =>
val predecessors: Traversable[Option[GraphNode]] = for (dependency <- task.tasksDependedOn) yield graphNodeFor(dependency)
val predecessors: Iterable[Option[GraphNode]] = for (dependency <- task.tasksDependedOn) yield graphNodeFor(dependency)
if (predecessors.exists(_.isEmpty)) None // we found predecessors that have no associated graph node
else Some(predecessors.map(_.get))
}
Expand All @@ -310,7 +310,7 @@ trait TaskTracker extends TaskManagerLike with LazyLogging {
* @param states the states of the returned graph nodes.
* @return the graph nodes with the given states.
*/
protected def graphNodesInStatesFor(states: Traversable[GraphNodeState.Value]): Iterable[GraphNode] = {
protected def graphNodesInStatesFor(states: Iterable[GraphNodeState.Value]): Iterable[GraphNode] = {
graphNodes.filter(n => states.toList.contains(n.state))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import com.fulcrumgenomics.commons.util.TimeUtil._
import dagr.core.execsystem.GraphNodeState._
import dagr.core.execsystem.TopLikeStatusReporter.{ReportField, StatusRunnable}
import dagr.core.tasksystem.{InJvmTask, ProcessTask, Task, UnitTask}
import jline.{TerminalFactory, Terminal => JLineTerminal}

import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.tools.jline_embedded.{Terminal => JLineTerminal, TerminalFactory}

/** Simple methods for a terminal */
object Terminal {
Expand All @@ -62,13 +62,13 @@ trait Terminal {
* See: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html
*/
object CursorMovement {
def positionCursor(line: Int, column: Int): String = s"\033[$line;${column}H"
def positionCursor(line: Int, column: Int): String = s"\u001b$line;${column}H"
//def moveUp(numLines: Int): String = s"\033[${numLines}A"
//def moveDown(numLines: Int): String = s"\033[${numLines}B"
//def moveRight(numColumns: Int): String = s"\033[${numColumns}C"
//def moveLeft(numColumns: Int): String = s"\033[${numColumns}D"
def clearScreen: String = "\033[2J"
def eraseToEOL: String = "\033[K"
def clearScreen: String = "\u001b[2J"
def eraseToEOL: String = "\u001b[K"
}

object TopLikeStatusReporter {
Expand Down
28 changes: 14 additions & 14 deletions core/src/main/scala/dagr/core/tasksystem/Dependable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ trait Dependable {
}

/** Must be implemented to return all tasks on which new predecessor dependencies should be added. */
def headTasks: Traversable[Task]
def headTasks: Iterable[Task]

/** Must be implemented to return all tasks on which new successor dependencies should be added. */
def tailTasks: Traversable[Task]
def tailTasks: Iterable[Task]

/** Must be implemented to return all tasks represented by the Dependable. */
def allTasks: Traversable[Task]
def allTasks: Iterable[Task]
}

/** An object that can be implicitly converted to from a None when using Option[Dependable]. */
Expand All @@ -80,11 +80,11 @@ object EmptyDependable extends Dependable {
case None => EmptyDependable
}

override def addDependent(dependent: Dependable): Unit = Unit
override def !=>(other: Dependable): Unit = Unit
override def headTasks: Traversable[Task] = Nil
override def tailTasks: Traversable[Task] = Nil
override def allTasks: Traversable[Task] = Nil
override def addDependent(dependent: Dependable): Unit = ()
override def !=>(other: Dependable): Unit = ()
override def headTasks: Iterable[Task] = Nil
override def tailTasks: Iterable[Task] = Nil
override def allTasks: Iterable[Task] = Nil
}

/**
Expand All @@ -98,9 +98,9 @@ case class DependencyChain(from: Dependable, to: Dependable) extends Dependable
override def !=>(other: Dependable): Unit = to !=> other


override def headTasks: Traversable[Task] = from.headTasks
override def tailTasks: Traversable[Task] = to.tailTasks
override def allTasks: Traversable[Task] = from.allTasks ++ to.allTasks
override def headTasks: Iterable[Task] = from.headTasks
override def tailTasks: Iterable[Task] = to.tailTasks
override def allTasks: Iterable[Task] = from.allTasks ++ to.allTasks
}

/**
Expand All @@ -119,7 +119,7 @@ case class DependencyGroup(a: Dependable, b: Dependable) extends Dependable {
f(b)
}

override def headTasks: Traversable[Task] = a.headTasks ++ b.headTasks
override def tailTasks: Traversable[Task] = a.tailTasks ++ b.tailTasks
override def allTasks: Traversable[Task] = a.allTasks ++ b.allTasks
override def headTasks: Iterable[Task] = a.headTasks ++ b.headTasks
override def tailTasks: Iterable[Task] = a.tailTasks ++ b.tailTasks
override def allTasks: Iterable[Task] = a.allTasks ++ b.allTasks
}
Loading

0 comments on commit e2a634a

Please sign in to comment.