Commit 4aac4dda authored by Jens Korinth's avatar Jens Korinth
Browse files

Fixes #128 - Notify the user if a platform is unknown

* check all Job instances for empty filters, e.g., Platforms,
  Architectures, Kernels, and issue error message accordingly
* helpful error message contains available instances
* job is not executed, if check fails
parent 1ede7604
Pipeline #63 failed with stage
in 1 minute and 46 seconds
package de.tu_darmstadt.cs.esa.tapasco.jobs
import de.tu_darmstadt.cs.esa.tapasco.base._
import de.tu_darmstadt.cs.esa.tapasco.task._
import de.tu_darmstadt.cs.esa.tapasco.Logging._
import de.tu_darmstadt.cs.esa.tapasco.filemgmt.FileAssetManager
package object executors {
trait Executor[-A] { def execute(a: A)(implicit cfg: Configuration, tsk: Tasks): Boolean }
......@@ -12,7 +14,7 @@ package object executors {
implicit final val ImportExecutor: Executor[ImportJob] = Import
implicit final val DesignSpaceExplorationExecutor: Executor[DesignSpaceExplorationJob] = DesignSpaceExploration
def execute(j: Job)(implicit cfg: Configuration, tsk: Tasks): Boolean = j match {
def execute(j: Job)(implicit cfg: Configuration, tsk: Tasks, logger: Logger): Boolean = check(j) && (j match {
case cs: CoreStatisticsJob => cs.execute
case bi: BulkImportJob => bi.execute
case ce: ComposeJob => ce.execute
......@@ -20,5 +22,32 @@ package object executors {
case ij: ImportJob => ij.execute
case ds: DesignSpaceExplorationJob => ds.execute
case _ => throw new Exception("not implemented")
})
private def checkPlatforms(j: { def platforms: Set[Platform] })(implicit logger: Logger) =
if (j.platforms.isEmpty) {
logger.error("no valid Platforms selected! (available: %s)".format(FileAssetManager.entities.platforms map (_.name) mkString ", "))
false
} else true
private def checkArchs(j: { def architectures: Set[Architecture] })(implicit logger: Logger) =
if (j.architectures.isEmpty) {
logger.error("no valid Architectures selected! (available: %s)".format(FileAssetManager.entities.architectures map (_.name) mkString ", "))
false
} else true
private def checkKernels(j: { def kernels: Set[Kernel] })(implicit logger: Logger) =
if (j.kernels.isEmpty) {
logger.error("no valid Kernels selected! (available: %s)".format(FileAssetManager.entities.kernels map (_.name) mkString ", "))
false
} else { logger.info(s"${j.kernels}"); true}
def check(j: Job)(implicit cfg: Configuration, logger: Logger): Boolean = j match {
case cj: ComposeJob => checkPlatforms(cj) && checkArchs(cj)
case cj: CoreStatisticsJob => checkPlatforms(cj) && checkArchs(cj)
case dj: DesignSpaceExplorationJob => checkPlatforms(dj) && checkArchs(dj)
case hj: HighLevelSynthesisJob => checkPlatforms(hj) && checkArchs(hj) && checkKernels(hj)
case ij: ImportJob => checkPlatforms(ij) && checkArchs(ij)
case _ => true
}
}
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