Changeset 33141
- Timestamp:
- Jan 24, 2012, 4:40:12 PM (14 years ago)
- Location:
- trunk/pstamp/scripts
- Files:
-
- 4 edited
-
detectability_respond.pl (modified) (5 diffs)
-
dquery_finish.pl (modified) (5 diffs)
-
dqueryparse.pl (modified) (5 diffs)
-
pstamp_job_run.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/detectability_respond.pl
r33126 r33141 41 41 my $EXTVER = 1.0; 42 42 my $EXTNAME = 'MOPS_DETECTABILITY_RESPONSE'; 43 my ($req_id,$ req_name,$product,$need_magic,$missing_tools,$project);43 my ($req_id,$job_id,$req_name,$product,$need_magic,$missing_tools,$project); 44 44 my ($request_file,$output,$workdir,$dbname,$dbserver,$verbose,$save_temps,$ignore_wisdom); 45 45 GetOptions( … … 47 47 'output=s' => \$output, 48 48 'workdir=s' => \$workdir, 49 'job_id=s' => \$job_id, 49 50 'dbname=s' => \$dbname, 50 51 'dbserver=s' => \$dbserver, … … 298 299 $query{$fpa_id}{FAULT}[$valid_index] = $PSTAMP_GONE; 299 300 } 300 elsif ($need_magic and ($query{$fpa_id}{MAGICKED}[$valid_index] =0)) {301 elsif ($need_magic and ($query{$fpa_id}{MAGICKED}[$valid_index] eq 0)) { 301 302 $query{$fpa_id}{FAULT}[$valid_index] = $PSTAMP_NOT_DESTREAKED; 302 303 } … … 324 325 my %processing_request; 325 326 326 open(WISDOM,">$wisdom_file") or my_die("failed to open wisdom file $wisdom_file"); 327 foreach my $fpa_id (keys %query) { 328 for (my $i = 0; $i <= $#{ $query{$fpa_id}{ROWNUM} }; $i++) { 329 print WISDOM "$fpa_id\t"; 330 foreach my $key (keys %{ $query{$fpa_id} }) { 331 print WISDOM "$key $query{$fpa_id}{$key}[$i]\t"; 332 } 333 print WISDOM "\n"; 334 my $data_state = $query{$fpa_id}{DATA_STATE}[$i]; 335 if ($query{$fpa_id}{BAD_COMPONENT}[$i] == 0) { 336 if ($data_state ne 'full') { 337 338 @{ $update_request{$query{$fpa_id}{IMAGE}[$i]}{$query{$fpa_id}{FAULT}[$i]} } = 339 ($query{$fpa_id}{STATE}[$i],$query{$fpa_id}{STAGE}[$i],$query{$fpa_id}{STAGE_ID}[$i], 340 $query{$fpa_id}{COMPONENT_ID}[$i],$query{$fpa_id}{NEED_MAGIC}[$i],$query{$fpa_id}{IMAGE_DB}[$i]); 327 if (!$job_id) { 328 open(WISDOM,">$wisdom_file") or my_die("failed to open wisdom file $wisdom_file"); 329 foreach my $fpa_id (keys %query) { 330 for (my $i = 0; $i <= $#{ $query{$fpa_id}{ROWNUM} }; $i++) { 331 print WISDOM "$fpa_id\t"; 332 foreach my $key (keys %{ $query{$fpa_id} }) { 333 print WISDOM "$key $query{$fpa_id}{$key}[$i]\t"; 341 334 } 342 push @{ $processing_request{$fpa_id}{$query{$fpa_id}{IMAGE}[$i]} }, $i; 343 } 344 } 345 } 346 close(WISDOM); 347 348 # If there is anything that needs to be updated, create the update request list, and then exit the program. 349 my $exit_code = 0; 350 my $update_request_file = "${workdir}/update_request.dat"; 351 open(UPDATE_REQUEST,">$update_request_file") or my_die("failed to open update request_file $update_request_file"); 352 foreach my $images (keys %update_request) { 353 foreach my $fault (keys %{ $update_request{$images} }) { 354 if ($fault == 25) { 355 $exit_code = 25; 356 } 357 elsif ($fault != 0) { 358 $exit_code = 21; 359 } 360 my $update_request = join ' ', @{ $update_request{$images}{$fault} }; 361 print UPDATE_REQUEST "$update_request\n"; 362 } 363 } 364 close(UPDATE_REQUEST); 365 if ($exit_code != 0) { 366 exit($exit_code); 335 print WISDOM "\n"; 336 my $data_state = $query{$fpa_id}{DATA_STATE}[$i]; 337 if ($query{$fpa_id}{BAD_COMPONENT}[$i] == 0) { 338 if ($data_state ne 'full') { 339 340 @{ $update_request{$query{$fpa_id}{IMAGE}[$i]}{$query{$fpa_id}{FAULT}[$i]} } = 341 ($query{$fpa_id}{STATE}[$i],$query{$fpa_id}{STAGE}[$i],$query{$fpa_id}{STAGE_ID}[$i], 342 $query{$fpa_id}{COMPONENT_ID}[$i],$query{$fpa_id}{NEED_MAGIC}[$i],$query{$fpa_id}{IMAGE_DB}[$i]); 343 } 344 push @{ $processing_request{$fpa_id}{$query{$fpa_id}{IMAGE}[$i]} }, $i; 345 } 346 } 347 } 348 close(WISDOM); 349 350 # If there is anything that needs to be updated, create the update request list, and then exit the program. 351 my $exit_code = 0; 352 my $update_request_file = "${workdir}/update_request.dat"; 353 open(UPDATE_REQUEST,">$update_request_file") or my_die("failed to open update request_file $update_request_file"); 354 foreach my $images (keys %update_request) { 355 foreach my $fault (keys %{ $update_request{$images} }) { 356 if ($fault == 25) { 357 $exit_code = 25; 358 } 359 elsif ($fault != 0) { 360 $exit_code = 21; 361 } 362 my $update_request = join ' ', @{ $update_request{$images}{$fault} }; 363 print UPDATE_REQUEST "$update_request\n"; 364 } 365 } 366 close(UPDATE_REQUEST); 367 if ($exit_code != 0) { 368 exit($exit_code); 369 } 367 370 } 368 371 … … 714 717 $status = 0; 715 718 # print "$output\n"; 719 if (-e $output) { 720 unlink $output or die "failed to unlink existing response file $output\n"; 721 } 716 722 my $outFits = Astro::FITS::CFITSIO::create_file( $output, $status ); 717 723 check_fitsio( $status ); -
trunk/pstamp/scripts/dquery_finish.pl
r27874 r33141 66 66 if ($product eq "NULL") { 67 67 # parsing failed just with fault = 0 (this leaves previously set fault in place 68 stop_request($req_id, 0, $verbose);68 update_request($req_id, 0, $verbose); 69 69 exit 0; 70 70 } … … 73 73 if (! -e $prod_dir ) { 74 74 # something must have gone wrong at the parse stage 75 stop_request($req_id, $PS_EXIT_SYS_ERROR, $verbose);75 update_request($req_id, $PS_EXIT_SYS_ERROR, $verbose); 76 76 die "product directory does not exist $prod_dir"; 77 77 } … … 82 82 print STDERR "output fileset directory $outdir does not exist\n" if $verbose; 83 83 if (! mkdir $outdir ) { 84 stop_request($req_id, $PS_EXIT_SYS_ERROR, $verbose);84 update_request($req_id, $PS_EXIT_SYS_ERROR, $verbose); 85 85 die "cannot create output directory $outdir"; 86 86 } 87 87 } elsif (! -d $outdir) { 88 stop_request($req_id, $PS_EXIT_SYS_ERROR, $verbose);88 update_request($req_id, $PS_EXIT_SYS_ERROR, $verbose); 89 89 die "output fileset directory $outdir exists but is not a directory"; 90 90 } … … 121 121 122 122 foreach my $job (@jobs) { 123 next if $job->{parent_id}; 123 124 my $job_id = $job->{job_id}; 124 my $response_file = "response ${job_id}.fits";125 my $response_file = "response.${job_id}.fits"; 125 126 my $response_path = "$outdir/$response_file"; 126 127 … … 157 158 } 158 159 159 stop_request($req_id, $request_fault, $verbose);160 update_request($req_id, $request_fault, $verbose); 160 161 161 162 exit 0; 162 163 163 sub stop_request {164 sub update_request { 164 165 my $req_id = shift; 165 166 my $fault = shift; 166 167 my $verbose = shift; 167 168 168 my $command = "$pstamptool -updatereq -req_id $req_id -set_state stop"; 169 $command .= " -set_fault $fault" if $fault; 169 my $command = "$pstamptool -updatereq -req_id $req_id"; 170 if ($fault) { 171 $command .= " -set_fault $fault"; 172 } else { 173 $command .= " -set_state stop"; 174 } 170 175 $command .= " -dbname $dbname" if $dbname; 171 176 $command .= " -dbserver $dbserver" if $dbserver; -
trunk/pstamp/scripts/dqueryparse.pl
r33126 r33141 118 118 { 119 119 my $command = "$detectresponse --input $req_file --output $response_file --workdir $outdir"; 120 if ($job_id) { 121 $command .= " --job_id $job_id"; 122 } else { 123 $command .= " --ignore-wisdom"; 124 } 120 125 $command .= " --save-temps" if $save_temps; 121 126 $command .= " --verbose" if $verbose; 122 $command .= " --ignore-wisdom" if !$job_id;123 127 124 128 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 133 137 my_die ("Update request indicated, but unable to find actual request!", $PS_EXIT_PROG_ERROR); 134 138 } 139 warn("Some inputs are not available must be updated."; 135 140 } 136 141 … … 139 144 my $result; 140 145 unless ($job_id) { 146 # We are running as a parse job 141 147 # If we returned correctly with a valid response file, get a job ID 142 148 # for the completed work, and move the response to a standardized name. … … 152 158 chomp $job_id; 153 159 if ($job_id && -e $response_file) { 154 rename $response_file, "$outdir/response ${job_id}.fits";160 rename $response_file, "$outdir/response.${job_id}.fits"; 155 161 } 156 162 $result = 0; … … 222 228 my_die ("Parse fault!!", $fault); 223 229 } 230 # This does not set the request state to stop. That will happen with the request_finish.pl script, 231 # which will notice that we've inserted the stopped job and decide we're finished. Easy enough. 232 { 233 my $command = "$pstamptool -updatereq -req_id $req_id -set_name $req_name -set_outProduct $product"; 234 $command .= " -set_fault $result" if $result; 235 236 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 237 run(command => $command, verbose => $verbose); 238 unless ($success) { 239 my_die("$command failed",$PS_EXIT_UNKNOWN_ERROR); 240 } 241 } 224 242 } else { 243 # We are running as a job presumably because an input needed 244 # to be regenerated 245 if ($fault) { 225 246 # in some cases we will need to finish off the request 226 247 my_die ("Run fault!!", $fault); 227 } 228 229 # This does not set the request state to stop. That will happen with the request_finish.pl script, 230 # which will notice that we've inserted the stopped job and decide we're finished. Easy enough. 231 { 232 my $command = "$pstamptool -updatereq -req_id $req_id -set_name $req_name -set_outProduct $product"; 233 $command .= " -set_fault $result" if $result; 234 235 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 236 run(command => $command, verbose => $verbose); 237 unless ($success) { 238 my_die("$command failed",$PS_EXIT_UNKNOWN_ERROR); 239 } 240 } 248 } 249 if (-e $response_file) { 250 rename $response_file, "$outdir/response.${job_id}.fits"; 251 } 252 } 253 241 254 242 255 exit 0; -
trunk/pstamp/scripts/pstamp_job_run.pl
r33126 r33141 306 306 # Load the argument list that dqueryparse should have created the first time it ran, so we know how to 307 307 # run it again the same way. 308 my $argslist = "$outputBase/parse.args"; 308 my $outdir = dirname($outputBase); 309 my $argslist = "$outdir/parse.args"; 309 310 open ARGSLIST, "<$argslist" or my_die("failed to open argslist file $argslist", $job_id, $PS_EXIT_UNKNOWN_ERROR); 310 311 my $argString = <ARGSLIST>; … … 319 320 $command .= " --dbserver $dbserver" if $dbserver; 320 321 $command .= " --verbose" if $verbose; 322 $command .= " --save-temps" if $save_temps; 321 323 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 322 324 run(command => $command, verbose => $verbose); … … 616 618 617 619 $exit_code = $PS_EXIT_PROG_ERROR unless $exit_code; 620 if ($exit_code > 100) { 621 carp ("invalid exit code: $exit_code changing to $PS_EXIT_UNKNOWN_ERROR"); 622 $exit_code = $PS_EXIT_UNKNOWN_ERROR; 623 } 618 624 $job_state = 'run' unless $job_state; 619 625
Note:
See TracChangeset
for help on using the changeset viewer.
