parallel: --keep-order --resume-failed works.

This commit is contained in:
Ole Tange 2013-02-13 01:15:37 +01:00
parent f948768a1f
commit cf38b9078c
3 changed files with 47 additions and 20 deletions

View file

@ -500,7 +500,7 @@ sub options_hash {
"resume-failed|resumefailed" => \$opt::resume_failed, "resume-failed|resumefailed" => \$opt::resume_failed,
"silent" => \$opt::silent, "silent" => \$opt::silent,
#"silent-error|silenterror" => \$opt::silent_error, #"silent-error|silenterror" => \$opt::silent_error,
"keep-order|keeporder|k" => \$opt::k, "keep-order|keeporder|k" => \$opt::keeporder,
"group" => \$opt::group, "group" => \$opt::group,
"g" => \$opt::retired, "g" => \$opt::retired,
"ungroup|u" => \$opt::u, "ungroup|u" => \$opt::u,
@ -674,7 +674,7 @@ sub parse_options {
$Global::debug = (defined $opt::D); $Global::debug = (defined $opt::D);
if(defined $opt::X) { $Global::ContextReplace = 1; } if(defined $opt::X) { $Global::ContextReplace = 1; }
if(defined $opt::silent) { $Global::verbose = 0; } if(defined $opt::silent) { $Global::verbose = 0; }
if(defined $opt::k) { $Global::keeporder = 1; } if(defined $opt::keeporder) { $Global::keeporder = 1; }
if(defined $opt::group) { $Global::grouped = 1; } if(defined $opt::group) { $Global::grouped = 1; }
if(defined $opt::u) { $Global::grouped = 0; } if(defined $opt::u) { $Global::grouped = 0; }
if(defined $opt::0) { $/ = "\0"; } if(defined $opt::0) { $/ = "\0"; }
@ -1858,8 +1858,11 @@ sub reaper {
$Private::job_end_sequence ||= 1; $Private::job_end_sequence ||= 1;
debug("Looking for: $Private::job_end_sequence ". debug("Looking for: $Private::job_end_sequence ".
"Current: ".$job->seq()."\n"); "Current: ".$job->seq()."\n");
while($Private::print_later{$Private::job_end_sequence}) { while($Private::print_later{$Private::job_end_sequence}
or
vec($Global::job_already_run,$Private::job_end_sequence,1)) {
debug("Found job end $Private::job_end_sequence"); debug("Found job end $Private::job_end_sequence");
defined $Private::print_later{$Private::job_end_sequence} and
$Private::print_later{$Private::job_end_sequence}->print(); $Private::print_later{$Private::job_end_sequence}->print();
delete $Private::print_later{$Private::job_end_sequence}; delete $Private::print_later{$Private::job_end_sequence};
$Private::job_end_sequence++; $Private::job_end_sequence++;
@ -4070,7 +4073,7 @@ sub print {
my $err = $self->stderr(); my $err = $self->stderr();
my $command = $self->sshlogin_wrap(); my $command = $self->sshlogin_wrap();
if($Global::joblog and not $self->virgin()) { if($Global::joblog and not ($opt::pipe and $self->virgin())) {
my $cmd; my $cmd;
if($Global::verbose <= 1) { if($Global::verbose <= 1) {
$cmd = $self->replaced(); $cmd = $self->replaced();

View file

@ -112,27 +112,28 @@ echo '### -k -0 -i repl'
echo '### test --sshdelay' echo '### test --sshdelay'
stdout /usr/bin/time -f %e parallel -j0 --sshdelay 0.5 -S localhost true ::: 1 2 3 | perl -ne 'print($_ > 1.80 ? "OK\n" : "Not OK\n")' stdout /usr/bin/time -f %e parallel -j0 --sshdelay 0.5 -S localhost true ::: 1 2 3 | perl -ne 'print($_ > 1.80 ? "OK\n" : "Not OK\n")'
echo '### bug #38299: --resume-failed -k'
rm /tmp/joblog-38299
parallel -k --resume-failed --joblog /tmp/joblog-38299 echo job{#}id{}\;exit {} ::: 0 1 2 3 0 1
echo try 2
parallel -k --resume-failed --joblog /tmp/joblog-38299 echo job{#}id{}\;exit {} ::: 0 1 2 3 0 1
echo with exit 0
parallel -k --resume-failed --joblog /tmp/joblog-38299 echo job{#}id{}\;exit 0 ::: 0 1 2 3 0 1
echo '### --resume -k'
rm -f /tmp/joblog-resume
parallel -k --resume --joblog /tmp/joblog-resume echo job{}id\;exit {} ::: 0 1 2 3 0 5
echo try 2 = nothing
parallel -k --resume --joblog /tmp/joblog-resume echo job{}id\;exit {} ::: 0 1 2 3 0 5
echo two extra
parallel -k --resume --joblog /tmp/joblog-resume echo job{}id\;exit 0 ::: 0 1 2 3 0 5 6 7
echo '### Negative replacement strings' echo '### Negative replacement strings'
parallel -X -j1 -N 6 echo {-1}orrec{1} ::: t B X D E c parallel -X -j1 -N 6 echo {-1}orrec{1} ::: t B X D E c
parallel -N 6 echo {-1}orrect ::: A B X D E c parallel -N 6 echo {-1}orrect ::: A B X D E c
parallel --colsep ' ' echo '{2} + {4} = {2} + {-1}=' '$(( {2} + {-1} ))' ::: "1 2 3 4" parallel --colsep ' ' echo '{2} + {4} = {2} + {-1}=' '$(( {2} + {-1} ))' ::: "1 2 3 4"
parallel --colsep ' ' echo '{-3}orrect' ::: "1 c 3 4" parallel --colsep ' ' echo '{-3}orrect' ::: "1 c 3 4"
echo '### bug #38299: --resume-failed -k';
rm /tmp/joblog-38299;
parallel -k --resume-failed --joblog /tmp/joblog-38299 echo job{#} val {}\;exit {} ::: 0 1 2 3 0 1;
echo try 2. Gives failing - not 0;
parallel -k --resume-failed --joblog /tmp/joblog-38299 echo job{#} val {}\;exit {} ::: 0 1 2 3 0 1;
echo with exit 0;
parallel -k --resume-failed --joblog /tmp/joblog-38299 echo job{#} val {}\;exit 0 ::: 0 1 2 3 0 1;
echo try 2 again. Gives empty;
parallel -k --resume-failed --joblog /tmp/joblog-38299 echo job{#} val {}\;exit {} ::: 0 1 2 3 0 1
echo '### --resume -k';
rm -f /tmp/joblog-resume;
parallel -k --resume --joblog /tmp/joblog-resume echo job{}id\;exit {} ::: 0 1 2 3 0 5;
echo try 2 = nothing;
parallel -k --resume --joblog /tmp/joblog-resume echo job{}id\;exit {} ::: 0 1 2 3 0 5;
echo two extra;
parallel -k --resume --joblog /tmp/joblog-resume echo job{}id\;exit 0 ::: 0 1 2 3 0 5 6 7
EOF EOF

View file

@ -199,3 +199,26 @@ OK
5 OK 5 OK
### test --sshdelay ### test --sshdelay
OK OK
### Negative replacement strings
correct
correct
2 + 4 = 2 + 4= 6
correct
### bug #38299: --resume-failed -k
job1 val 0
job2 val 1
job3 val 2
job4 val 3
job5 val 0
job6 val 1
try 2. Gives failing - not 0
job2 val 1
job3 val 2
job4 val 3
job6 val 1
with exit 0
job2 val 1
job3 val 2
job4 val 3
job6 val 1
try 2 again. Gives empty