Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tapasco
tapasco
Commits
023033c4
Commit
023033c4
authored
Aug 16, 2017
by
Jens Korinth
Browse files
Slurm scalastyle fix
parent
c96cb0e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/scala/tapasco/slurm/Slurm.scala
View file @
023033c4
...
@@ -15,6 +15,7 @@ import java.nio.file.attribute.PosixFilePermission._
...
@@ -15,6 +15,7 @@ import java.nio.file.attribute.PosixFilePermission._
**/
**/
final
object
Slurm
extends
Publisher
{
final
object
Slurm
extends
Publisher
{
private
implicit
val
logger
=
de
.
tu_darmstadt
.
cs
.
esa
.
tapasco
.
Logging
.
logger
(
getClass
)
private
implicit
val
logger
=
de
.
tu_darmstadt
.
cs
.
esa
.
tapasco
.
Logging
.
logger
(
getClass
)
private
val
SLURM_RETRIES
=
10
/** Model of a SLURM job. */
/** Model of a SLURM job. */
final
case
class
Job
(
final
case
class
Job
(
...
@@ -113,22 +114,23 @@ final object Slurm extends Publisher {
...
@@ -113,22 +114,23 @@ final object Slurm extends Publisher {
* @param script Job script file to schedule via `sbatch`.
* @param script Job script file to schedule via `sbatch`.
* @return Either a positive integer (SLURM id), or an Exception.
* @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: "
)
{
def
apply
(
script
:
Path
,
retries
:
Int
=
SLURM_RETRIES
)
:
Option
[
Int
]
=
val
cmd
=
"sbatch %s"
.
format
(
script
.
toAbsolutePath
().
normalize
().
toString
)
catchAllDefault
[
Option
[
Int
]](
None
,
"Slurm scheduling failed: "
)
{
logger
.
debug
(
"running slurm batch job: '%s'"
.
format
(
cmd
))
val
cmd
=
"sbatch %s"
.
format
(
script
.
toAbsolutePath
().
normalize
().
toString
)
val
res
=
cmd
.!!
logger
.
debug
(
"running slurm batch job: '%s'"
.
format
(
cmd
))
val
id
=
slurmSubmissionAck
.
findFirstMatchIn
(
res
)
map
(
_
group
(
1
)
toInt
)
val
res
=
cmd
.!!
if
(
id
.
isEmpty
)
{
val
id
=
slurmSubmissionAck
.
findFirstMatchIn
(
res
)
map
(
_
group
(
1
)
toInt
)
if
(
retries
>
0
)
{
if
(
id
.
isEmpty
)
{
// wait for 10 secs + random up to 5 secs to avoid congestion
if
(
retries
>
0
)
{
Thread
.
sleep
(
slurmRetryDelay
+
scala
.
util
.
Random
.
nextInt
()
%
(
slurmRetryDelay
/
2
))
// wait for 10 secs + random up to 5 secs to avoid congestion
apply
(
script
,
retries
-
1
)
Thread
.
sleep
(
slurmRetryDelay
+
scala
.
util
.
Random
.
nextInt
()
%
(
slurmRetryDelay
/
2
))
}
else
{
throw
new
SlurmException
(
script
.
toString
,
res
)
}
apply
(
script
,
retries
-
1
)
}
else
{
}
else
{
throw
new
SlurmException
(
script
.
toString
,
res
)
}
logger
.
debug
(
"received SLURM id: {}"
,
id
)
}
else
{
id
logger
.
debug
(
"received SLURM id: {}"
,
id
)
id
}
}
}
}
/** Check via `squeue` if the SLURM job is still running. */
/** Check via `squeue` if the SLURM job is still running. */
def
isRunning
(
id
:
Int
)
:
Boolean
=
catchAllDefault
[
Boolean
](
true
,
"Slurm `squeue` failed: "
)
{
def
isRunning
(
id
:
Int
)
:
Boolean
=
catchAllDefault
[
Boolean
](
true
,
"Slurm `squeue` failed: "
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment