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( ...@@ -51,7 +51,7 @@ private class ConcreteExploration(
val batchSize: Int = Exploration.MAX_BATCH_SZ, val batchSize: Int = Exploration.MAX_BATCH_SZ,
val basePath: Path, val basePath: Path,
val debugMode: Option[String], 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 implicit val _exploration = this
private[this] val _logger = de.tu_darmstadt.cs.esa.tapasco.Logging.logger(getClass) private[this] val _logger = de.tu_darmstadt.cs.esa.tapasco.Logging.logger(getClass)
private var _result: Option[(DesignSpace.Element, Composer.Result)] = None private var _result: Option[(DesignSpace.Element, Composer.Result)] = None
...@@ -234,7 +234,7 @@ object Exploration { ...@@ -234,7 +234,7 @@ object Exploration {
batchSize: Int = MAX_BATCH_SZ, batchSize: Int = MAX_BATCH_SZ,
basePath: Path, basePath: Path,
debugMode: Option[String] = None, 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) new ConcreteExploration(initialComposition, target, dimensions, designFrequency, batchSize, basePath, debugMode, deleteOnFail)
// scalastyle:on parameter.number // scalastyle:on parameter.number
......
...@@ -35,7 +35,7 @@ sealed private trait Run extends Startable with Ordered[Run] { ...@@ -35,7 +35,7 @@ sealed private trait Run extends Startable with Ordered[Run] {
(that.area.utilization, that.element.h, that.element.frequency) (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 { (implicit exploration: Exploration, configuration: Configuration) extends Run {
private[this] var _result: Option[Composer.Result] = None private[this] var _result: Option[Composer.Result] = None
private[this] var _task: Option[ComposeTask] = None private[this] var _task: Option[ComposeTask] = None
......
...@@ -81,7 +81,7 @@ private object Compose extends Executor[ComposeJob] { ...@@ -81,7 +81,7 @@ private object Compose extends Executor[ComposeJob] {
features = job.features, features = job.features,
debugMode = job.debugMode, debugMode = job.debugMode,
onComplete = _ => signal.release(), onComplete = _ => signal.release(),
deleteOnFail = job.deleteProjects getOrElse(false) deleteOnFail = job.deleteProjects
) )
composeTasks foreach { tsk.apply _ } composeTasks foreach { tsk.apply _ }
......
...@@ -110,6 +110,6 @@ private object DesignSpaceExploration extends Executor[DesignSpaceExplorationJob ...@@ -110,6 +110,6 @@ private object DesignSpaceExploration extends Executor[DesignSpaceExplorationJob
None, // logfile None, // logfile
job.debugMode, job.debugMode,
onComplete, onComplete,
deleteOnFail = job.deleteProjects getOrElse false job.deleteProjects
) )
} }
...@@ -84,6 +84,9 @@ private object BasicParsers { ...@@ -84,6 +84,9 @@ private object BasicParsers {
val dblstr: Parser[String] = val dblstr: Parser[String] =
(signednumstr.! ~ (CharIn(",.") ~ numstr).!.?) map { case (n, r) => n ++ r.getOrElse("") } (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) val double: Parser[Double] = dblstr.map(_.toDouble)
.opaque("floating point number") .opaque("floating point number")
......
...@@ -17,11 +17,13 @@ ...@@ -17,11 +17,13 @@
// along with Tapasco. If not, see <http://www.gnu.org/licenses/>. // along with Tapasco. If not, see <http://www.gnu.org/licenses/>.
// //
package de.tu_darmstadt.cs.esa.tapasco.parser package de.tu_darmstadt.cs.esa.tapasco.parser
import de.tu_darmstadt.cs.esa.tapasco.base._ import de.tu_darmstadt.cs.esa.tapasco.base._
import de.tu_darmstadt.cs.esa.tapasco.base.json._ import de.tu_darmstadt.cs.esa.tapasco.base.json._
import de.tu_darmstadt.cs.esa.tapasco.dse.Heuristics import de.tu_darmstadt.cs.esa.tapasco.dse.Heuristics
import fastparse.all._ import fastparse.all._
import java.nio.file._ import java.nio.file._
import scala.util.Try
private object CommonArgParsers { private object CommonArgParsers {
import BasicParsers._ import BasicParsers._
...@@ -68,7 +70,8 @@ private object CommonArgParsers { ...@@ -68,7 +70,8 @@ private object CommonArgParsers {
qstring.opaque("debug mode name, any string") ~ ws qstring.opaque("debug mode name, any string") ~ ws
def delProj: Parser[(String, Boolean)] = 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)] = def implementation: Parser[(String, String)] =
longOption("implementation", "Implementation") ~ longOption("implementation", "Implementation") ~
......
...@@ -42,7 +42,7 @@ class ComposeTask(composition: Composition, ...@@ -42,7 +42,7 @@ class ComposeTask(composition: Composition,
logFile: Option[String] = None, logFile: Option[String] = None,
debugMode: Option[String] = None, debugMode: Option[String] = None,
val onComplete: Boolean => Unit, val onComplete: Boolean => Unit,
val deleteOnFail: Boolean = false) val deleteOnFail: Option[Boolean] = None)
(implicit cfg: Configuration) extends Task with LogTracking { (implicit cfg: Configuration) extends Task with LogTracking {
private[this] implicit val _logger = de.tu_darmstadt.cs.esa.tapasco.Logging.logger(getClass) private[this] implicit val _logger = de.tu_darmstadt.cs.esa.tapasco.Logging.logger(getClass)
private[this] val _slurm = Slurm.enabled private[this] val _slurm = Slurm.enabled
...@@ -90,7 +90,9 @@ class ComposeTask(composition: Composition, ...@@ -90,7 +90,9 @@ class ComposeTask(composition: Composition,
LogFileTracker.stopLogFileAppender(appender) LogFileTracker.stopLogFileAppender(appender)
val result = (_composerResult map (_.result) getOrElse false) == ComposeResult.Success 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 result
} }
......
...@@ -51,7 +51,7 @@ private class DesignSpaceExplorationTask( ...@@ -51,7 +51,7 @@ private class DesignSpaceExplorationTask(
logFile: Option[String], logFile: Option[String],
debugMode: Option[String], debugMode: Option[String],
val onComplete: Boolean => Unit, val onComplete: Boolean => Unit,
val deleteOnFail: Boolean = false) val deleteOnFail: Option[Boolean])
(implicit cfg: Configuration, tsk: Tasks) extends Task with LogTracking with ExplorationTask { (implicit cfg: Configuration, tsk: Tasks) extends Task with LogTracking with ExplorationTask {
private[this] val _logger = de.tu_darmstadt.cs.esa.tapasco.Logging.logger(getClass) private[this] val _logger = de.tu_darmstadt.cs.esa.tapasco.Logging.logger(getClass)
/** Internal representation of result. **/ /** Internal representation of result. **/
...@@ -170,7 +170,7 @@ object DesignSpaceExplorationTask { ...@@ -170,7 +170,7 @@ object DesignSpaceExplorationTask {
logFile: Option[String], logFile: Option[String],
debugMode: Option[String], debugMode: Option[String],
onComplete: Boolean => Unit, onComplete: Boolean => Unit,
deleteOnFail: Boolean = false) deleteOnFail: Option[Boolean])
(implicit cfg: Configuration, tsk: Tasks): ExplorationTask = { (implicit cfg: Configuration, tsk: Tasks): ExplorationTask = {
new DesignSpaceExplorationTask( new DesignSpaceExplorationTask(
composition, 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