Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
e21e5f3a
Commit
e21e5f3a
authored
9 years ago
by
Danny Auble
Browse files
Options
Downloads
Patches
Plain Diff
Fix bsub to read in from stdin
parent
2323188e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
contribs/openlava/bsub.pl
+35
-75
35 additions, 75 deletions
contribs/openlava/bsub.pl
with
35 additions
and
75 deletions
contribs/openlava/bsub.pl
+
35
−
75
View file @
e21e5f3a
...
@@ -131,12 +131,16 @@ if ($ARGV[0]) {
...
@@ -131,12 +131,16 @@ if ($ARGV[0]) {
foreach
(
@ARGV
)
{
foreach
(
@ARGV
)
{
$script
.=
"
$_
";
$script
.=
"
$_
";
}
}
}
else
{
#print "script = $script"
$interactive
=
1
;
foreach
(
<
STDIN
>
)
{
chomp
(
$_
);
$script
.=
"
$_
\n
";
}
}
}
#print "script = $script";
my
$command
;
my
$command
=
$sbatch
;
my
$base_command
;
if
(
!
$script
)
{
if
(
!
$script
)
{
if
(
$interactive
)
{
if
(
$interactive
)
{
...
@@ -147,17 +151,6 @@ if (!$script) {
...
@@ -147,17 +151,6 @@ if (!$script) {
}
}
}
}
if
(
_check_script
(
$ARGV
[
0
]))
{
$command
=
$base_command
=
"
$sbatch
";
}
else
{
$command
=
$base_command
=
"
$srun
";
# We need to find out the jobid we got
$command
.=
"
-v
";
$interactive
=
1
;
}
$command
.=
"
-e
$err_path
"
if
$err_path
;
$command
.=
"
-e
$err_path
"
if
$err_path
;
$command
.=
"
-o
$out_path
"
if
$out_path
;
$command
.=
"
-o
$out_path
"
if
$out_path
;
...
@@ -183,74 +176,41 @@ if ($min_proc) {
...
@@ -183,74 +176,41 @@ if ($min_proc) {
$command
.=
"
-t
$time
"
if
$time
;
$command
.=
"
-t
$time
"
if
$time
;
$command
.=
"
-p
$partition
"
if
$partition
;
$command
.=
"
-p
$partition
"
if
$partition
;
$command
.=
"
--exclusive
"
if
$exclusive
;
$command
.=
"
--exclusive
"
if
$exclusive
;
$command
.=
"
$script
"
if
$script
;
if
(
$interactive
||
!
_check_script
(
$ARGV
[
0
]))
{
$command
.=
"
--wrap=
\"
$script
\"
";
}
else
{
$command
.=
"
$script
";
}
#print " command = $command\n";
#print " command = $command\n";
#exit;
#exit;
#print "Command to run = $command\n";
# Execute the command and capture its stdout, stderr, and exit status. Note
# Execute the command and capture its stdout, stderr, and exit status. Note
# that if interactive mode was requested, the standard output and standard
# that if interactive mode was requested, the standard output and standard
# error are _not_ captured.
# error are _not_ captured.
# Execute the command and capture the combined stdout and stderr.
# Execute the command and capture the combined stdout and stderr.
if
(
$base_command
eq
$srun
)
{
#srun
my
@command_output
=
`
$command
2>&1
`;
my
$job_id
=
0
;
my
$dispatch_printed
=
0
;
#Save the command exit status.
my
$launch_printed
=
0
;
my
$command_exit_status
=
$?
;
open
(
PH
,
"
$command
2>&1 |
");
# or with an open pipe
while
(
<
PH
>
)
{
# If available, extract the job ID from the command output and print
my
$line
=
$_
;
# it to stdout, as done in the OpenLava version of bsub.
if
(
$_
!~
"
srun:
")
{
if
(
$command_exit_status
==
0
)
{
print
$line
;
my
@spcommand_output
=
split
("
",
}
elsif
(
!
$dispatch_printed
&&
(
$_
=~
/srun: jobid \d/
))
{
$command_output
[
$#command_output
]);
my
@line_words
=
split
("
",
$_
);
my
$job_id
=
$spcommand_output
[
$#spcommand_output
];
$job_id
=
$line_words
[
2
];
_print_job_submitted
(
$job_id
);
chop
(
$job_id
);
}
else
{
$dispatch_printed
=
2
;
print
("
There was an error running the Slurm sbatch command.
\n
"
.
}
elsif
(
!
$dispatch_printed
&&
(
$_
=~
/srun: job \d/
))
{
"
The command was:
\n
"
.
my
@line_words
=
split
("
",
$_
);
"
'
$command
'
\n
"
.
$job_id
=
$line_words
[
2
];
"
and the output was:
\n
"
.
$dispatch_printed
=
2
;
"
'
@command_output
'
\n
");
}
elsif
(
!
$launch_printed
&&
(
$_
=~
/srun: launching \d/
))
{
my
@line_words
=
split
("
",
$_
);
my
$node_name
=
$line_words
[
5
];
chop
(
$node_name
);
print
"
<<Starting on
$node_name
>>
\n
";
$launch_printed
=
1
;
}
if
(
$dispatch_printed
==
2
)
{
_print_job_submitted
(
$job_id
);
print
"
<<Waiting for dispatch ...>>
\n
";
$dispatch_printed
=
1
;
}
}
close
(
PH
);
}
elsif
(
$base_command
eq
$sbatch
)
{
my
@command_output
=
`
$command
2>&1
`;
#Save the command exit status.
my
$command_exit_status
=
$?
;
# If available, extract the job ID from the command output and print
# it to stdout, as done in the OpenLava version of bsub.
if
(
$command_exit_status
==
0
)
{
my
@spcommand_output
=
split
("
",
$command_output
[
$#command_output
]);
my
$job_id
=
$spcommand_output
[
$#spcommand_output
];
_print_job_submitted
(
$job_id
);
}
else
{
print
("
There was an error running the Slurm sbatch command.
\n
"
.
"
The command was:
\n
"
.
"
'
$command
'
\n
"
.
"
and the output was:
\n
"
.
"
'
@command_output
'
\n
");
}
# Exit with the command return code.
exit
(
$command_exit_status
>>
8
);
}
}
# Exit with the command return code.
exit
(
$command_exit_status
>>
8
);
sub
_get_default_partition_name
{
sub
_get_default_partition_name
{
...
@@ -283,7 +243,7 @@ sub _print_job_submitted {
...
@@ -283,7 +243,7 @@ sub _print_job_submitted {
sub
_parse_procs
{
sub
_parse_procs
{
my
(
$procs_range
)
=
@_
;
my
(
$procs_range
)
=
@_
;
# Get the max process count i
t
i
f
exist
# Get the max process count i
f
i
t
exist
s
if
(
$procs_range
=~
/,/
)
{
if
(
$procs_range
=~
/,/
)
{
my
@sub_parts
=
split
(
/,/
,
$procs_range
);
my
@sub_parts
=
split
(
/,/
,
$procs_range
);
return
$sub_parts
[
1
];
return
$sub_parts
[
1
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment