Commit 023033c4 authored by Jens Korinth's avatar Jens Korinth
Browse files

Slurm scalastyle fix

parent c96cb0e8
......@@ -15,6 +15,7 @@ import java.nio.file.attribute.PosixFilePermission._
**/
final object Slurm extends Publisher {
private implicit val logger = de.tu_darmstadt.cs.esa.tapasco.Logging.logger(getClass)
private val SLURM_RETRIES = 10
/** Model of a SLURM job. */
final case class Job(
......@@ -113,22 +114,23 @@ final object Slurm extends Publisher {
* @param script Job script file to schedule via `sbatch`.
* @return Either a positive integer (SLURM id), or an Exception.
**/
def apply(script: Path, retries: Int = 10): Option[Int] = catchAllDefault[Option[Int]](None, "Slurm scheduling failed: ") {
val cmd = "sbatch %s".format(script.toAbsolutePath().normalize().toString)
logger.debug("running slurm batch job: '%s'".format(cmd))
val res = cmd.!!
val id = slurmSubmissionAck.findFirstMatchIn(res) map (_ group (1) toInt)
if (id.isEmpty) {
if (retries > 0) {
// wait for 10 secs + random up to 5 secs to avoid congestion
Thread.sleep(slurmRetryDelay + scala.util.Random.nextInt() % (slurmRetryDelay / 2))
apply(script, retries - 1)
} else { throw new SlurmException(script.toString, res) }
} else {
logger.debug("received SLURM id: {}", id)
id
def apply(script: Path, retries: Int = SLURM_RETRIES): Option[Int] =
catchAllDefault[Option[Int]](None, "Slurm scheduling failed: ") {
val cmd = "sbatch %s".format(script.toAbsolutePath().normalize().toString)
logger.debug("running slurm batch job: '%s'".format(cmd))
val res = cmd.!!
val id = slurmSubmissionAck.findFirstMatchIn(res) map (_ group (1) toInt)
if (id.isEmpty) {
if (retries > 0) {
// wait for 10 secs + random up to 5 secs to avoid congestion
Thread.sleep(slurmRetryDelay + scala.util.Random.nextInt() % (slurmRetryDelay / 2))
apply(script, retries - 1)
} else { throw new SlurmException(script.toString, res) }
} else {
logger.debug("received SLURM id: {}", id)
id
}
}
}
/** Check via `squeue` if the SLURM job is still running. */
def isRunning(id: Int): Boolean = catchAllDefault[Boolean](true, "Slurm `squeue` failed: ") {
......
Supports Markdown
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