Commit 856f4e2c authored by Lukas Weber's avatar Lukas Weber Committed by Lukas Sommer

Added the possibility to override the project deletion with true or false

parent 379dd977
......@@ -51,7 +51,7 @@ private class ConcreteExploration(
val batchSize: Int = Exploration.MAX_BATCH_SZ,
val basePath: Path,
val debugMode: Option[String],
val deleteOnFail: Boolean = false)(implicit cfg: Configuration, val tasks: Tasks) extends Exploration {
val deleteOnFail: Option[Boolean])(implicit cfg: Configuration, val tasks: Tasks) extends Exploration {
private implicit val _exploration = this
private[this] val _logger = de.tu_darmstadt.cs.esa.tapasco.Logging.logger(getClass)
private var _result: Option[(DesignSpace.Element, Composer.Result)] = None
......@@ -234,7 +234,7 @@ object Exploration {
batchSize: Int = MAX_BATCH_SZ,
basePath: Path,
debugMode: Option[String] = None,
deleteOnFail: Boolean = false) (implicit cfg: Configuration, tsk: Tasks): Exploration =
deleteOnFail: Option[Boolean]) (implicit cfg: Configuration, tsk: Tasks): Exploration =
new ConcreteExploration(initialComposition, target, dimensions, designFrequency, batchSize, basePath, debugMode, deleteOnFail)
// scalastyle:on parameter.number
......
......@@ -35,7 +35,7 @@ sealed private trait Run extends Startable with Ordered[Run] {
(that.area.utilization, that.element.h, that.element.frequency)
}
private class ConcreteRun(val no: Int, val element: DesignSpace.Element, val target: Target, val debugMode: Option[String], val deleteOnFail: Boolean = false)
private class ConcreteRun(val no: Int, val element: DesignSpace.Element, val target: Target, val debugMode: Option[String], val deleteOnFail: Option[Boolean])
(implicit exploration: Exploration, configuration: Configuration) extends Run {
private[this] var _result: Option[Composer.Result] = None
private[this] var _task: Option[ComposeTask] = None
......
......@@ -81,7 +81,7 @@ private object Compose extends Executor[ComposeJob] {
features = job.features,
debugMode = job.debugMode,
onComplete = _ => signal.release(),
deleteOnFail = job.deleteProjects getOrElse(false)
deleteOnFail = job.deleteProjects
)
composeTasks foreach { tsk.apply _ }
......
......@@ -110,6 +110,6 @@ private object DesignSpaceExploration extends Executor[DesignSpaceExplorationJob
None, // logfile
job.debugMode,
onComplete,
deleteOnFail = job.deleteProjects getOrElse false
job.deleteProjects
)
}
......@@ -84,6 +84,9 @@ private object BasicParsers {
val dblstr: Parser[String] =
(signednumstr.! ~ (CharIn(",.") ~ numstr).!.?) map { case (n, r) => n ++ r.getOrElse("") }
val boolstr: Parser[Boolean] =
("true" | "false" ).! map { _.toBoolean} opaque "boolean"
val double: Parser[Double] = dblstr.map(_.toDouble)
.opaque("floating point number")
......
......@@ -17,11 +17,13 @@
// along with Tapasco. If not, see <http://www.gnu.org/licenses/>.
//
package de.tu_darmstadt.cs.esa.tapasco.parser
import de.tu_darmstadt.cs.esa.tapasco.base._
import de.tu_darmstadt.cs.esa.tapasco.base.json._
import de.tu_darmstadt.cs.esa.tapasco.dse.Heuristics
import fastparse.all._
import java.nio.file._
import de.tu_darmstadt.cs.esa.tapasco.base._
import de.tu_darmstadt.cs.esa.tapasco.base.json._
import de.tu_darmstadt.cs.esa.tapasco.dse.Heuristics
import fastparse.all._
import java.nio.file._
import scala.util.Try
private object CommonArgParsers {
import BasicParsers._
......@@ -68,7 +70,8 @@ private object CommonArgParsers {
qstring.opaque("debug mode name, any string") ~ ws
def delProj: Parser[(String, Boolean)] =
(longOption("deleteProjects", "DeleteProjects") ~ ws) map {case s => (s, true)}
(longOption("deleteProjects", "DeleteProjects") ~ ws ~/
( boolstr ~ ws).?) map {case s => (s._1, s._2.getOrElse(true))}
def implementation: Parser[(String, String)] =
longOption("implementation", "Implementation") ~
......
......@@ -42,7 +42,7 @@ class ComposeTask(composition: Composition,
logFile: Option[String] = None,
debugMode: Option[String] = None,
val onComplete: Boolean => Unit,
val deleteOnFail: Boolean = false)
val deleteOnFail: Option[Boolean] = None)
(implicit cfg: Configuration) extends Task with LogTracking {
private[this] implicit val _logger = de.tu_darmstadt.cs.esa.tapasco.Logging.logger(getClass)
private[this] val _slurm = Slurm.enabled
......@@ -90,7 +90,9 @@ class ComposeTask(composition: Composition,
LogFileTracker.stopLogFileAppender(appender)
val result = (_composerResult map (_.result) getOrElse false) == ComposeResult.Success
if (result || deleteOnFail) { composer.clean(composition, target, designFrequency) } // TODO This has to be run, if this compose task is part of a DSE
// If --deleteProjects is set use the corresponding value, else delete only successful runs
val delete = if(deleteOnFail.isDefined) deleteOnFail.get else result
if (delete) { composer.clean(composition, target, designFrequency) }
result
}
......
......@@ -51,7 +51,7 @@ private class DesignSpaceExplorationTask(
logFile: Option[String],
debugMode: Option[String],
val onComplete: Boolean => Unit,
val deleteOnFail: Boolean = false)
val deleteOnFail: Option[Boolean])
(implicit cfg: Configuration, tsk: Tasks) extends Task with LogTracking with ExplorationTask {
private[this] val _logger = de.tu_darmstadt.cs.esa.tapasco.Logging.logger(getClass)
/** Internal representation of result. **/
......@@ -170,7 +170,7 @@ object DesignSpaceExplorationTask {
logFile: Option[String],
debugMode: Option[String],
onComplete: Boolean => Unit,
deleteOnFail: Boolean = false)
deleteOnFail: Option[Boolean])
(implicit cfg: Configuration, tsk: Tasks): ExplorationTask = {
new DesignSpaceExplorationTask(
composition,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment