Changeset 26151 for trunk/pstamp/scripts/pstampparse.pl
- Timestamp:
- Nov 15, 2009, 1:53:33 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstampparse.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstampparse.pl
r26083 r26151 98 98 99 99 # make sure the file contains what we are expecting 100 101 # we shouldn't get here if this is the case so just die.No need to notify the client100 # This program shouldn't have been run if the request file is bogus. 101 # No need to notify the client 102 102 my_die("$request_file_name is not a PS1_PS_REQEST", $PS_EXIT_PROG_ERROR) if $extname ne "PS1_PS_REQUEST"; 103 103 my_die("REQ_NAME not found in $request_file_name", $PS_EXIT_PROG_ERROR) if (!$req_name); … … 165 165 # XXX: TODO: sanity check all parameters 166 166 167 # XXX: TODO: We shouldn't really just die in this loop. 168 # If we encounter an error for a particular row 169 # add a job with the proper fault code. If there is a db or config error we should probably just 170 # trash the request. 167 # If we encounter an error for a particular row add a job with the proper fault code. 168 # If we encounter an error in this loop we shouldn't really just die. 169 # We only do that now in the case of I/O or DB errors or the like. 171 170 172 171 my $rownum = $row->{ROWNUM}; … … 236 235 } 237 236 238 # collect rows with the same images of interest in a list so that they239 # can be looked up together 237 # For "stamp" and "list_uri" jobs collect rows with the same images of interest in a list so that they 238 # can be looked up together. 240 239 if (@rowList) { 241 240 my $firstRow = $rowList[0]; 242 # note order of these parameters matters 243 if (same_images_of_interest($firstRow, $row)) { 241 if (($firstRow->{JOB_TYPE} ne "get_image") and same_images_of_interest($firstRow, $row)) { 244 242 245 243 # add this row to the list and move on … … 305 303 my $have_skycells = shift; 306 304 my $need_magic = shift; 305 my $mode = shift; 307 306 308 307 my $num_jobs = 0; … … 476 475 } 477 476 } elsif ($job_type eq "get_image") { 478 print STDERR "get_image jobs not implemented yet" if $verbose; 479 foreach my $row (@$rowList) { 480 insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED); 481 $num_jobs++; 482 } 477 my $n = scalar @$rowList; 478 479 my_die( "error: unexpected number of rows for get_image request: $n", $PS_EXIT_PROG_ERROR) if $n != 1; 480 481 $num_jobs = queueGetImageJobs($firstRow, $imageList, $stage, $need_magic, $mode); 482 483 483 } else { 484 484 if (!$imageList or (scalar @$imageList eq 0)) { … … 582 582 583 583 foreach my $row (@$rowList) { 584 $num_jobs += queueJobsForRow($row, $stage, $thisRun, $have_skycells, $need_magic );584 $num_jobs += queueJobsForRow($row, $stage, $thisRun, $have_skycells, $need_magic, $mode); 585 585 } 586 586 } 587 } 588 return $num_jobs; 589 } 590 591 # $num_jobs = queueGetImageJobs($firstRow, $imageList, $stage, $need_magic, $mode); 592 sub queueGetImageJobs 593 { 594 my $row = shift; 595 my $imageList = shift; 596 my $stage = shift; 597 my $need_magic = shift; 598 my $mode = shift; 599 600 my $num_jobs = 0; 601 my $rownum = $row->{ROWNUM}; 602 my $option_mask = $row->{OPTION_MASK}; 603 604 # For dist_bundle we need 605 # --camera from $image 606 # --stage 607 # --stage_id from $image 608 # --component from $image 609 # --path_base 610 # --outdir global to this script 611 612 # loop over images 613 my $job_num = 0; 614 foreach my $image (@$imageList) { 615 my $stage_id = $image->{stage_id}; 616 my $component = $image->{component}; 617 618 # skip faulted components for now. Should we even be here? 619 if ($image->{fault} > 0) { 620 printf STDERR "skipping faulted component for $stage $stage_id $component\n" if $verbose; 621 next; 622 } 623 624 $job_num++; 625 626 my $imagefile = $image->{image}; 627 if (($stage ne "stack") and ($need_magic and !$image->{magicked})) { 628 # we only get here if req_type is (byid or byexp). For other types the test for magicked is performed 629 # in locate_images because it's much more efficient to do the test in the database. 630 # For these two modes we fall through to here in order to give feedback to the requestor as 631 # to why the request failed to queue jobs. 632 print STDERR "skipping non-magicked image $imagefile\n" if $verbose; 633 insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_DESTREAKED); 634 $num_jobs++; 635 636 next; 637 } 638 my $exp_id = $image->{exp_id}; 639 640 my $output_base = "$out_dir/${rownum}_${job_num}_"; 641 my $params = "${output_base}.params"; 642 643 # copy the argument list to a file 644 open PARAMS, ">$params" or my_die("failed to open $params", $PS_EXIT_UNKNOWN_ERROR); 645 print PARAMS "$stage $image->{stage_id} $image->{component} $image->{path_base} $image->{camera}\n"; 646 close PARAMS or my_die("failed to close $params", $PS_EXIT_UNKNOWN_ERROR); 647 648 my $newState = "run"; 649 my $fault = 0; 650 my $dep_id; 651 652 if ($stage ne 'raw') { 653 my $run_state = $image->{state}; 654 my $data_state = $image->{data_state}; 655 $data_state = $run_state if $stage eq "stack"; 656 if (($run_state eq 'goto_purged') or ($data_state eq 'purged') or 657 ($run_state eq 'goto_scrubbed') or ($data_state eq 'scrubbed')) { 658 # image is gone and it's not coming back 659 $newState = 'stop'; 660 $fault = $PSTAMP_GONE; 661 } elsif (($data_state ne 'full') or ($run_state ne 'full' )) { 662 # don't wait for update unless the caller asks us to 663 if (!($option_mask & $PSTAMP_WAIT_FOR_UPDATE)) { 664 $newState = 'stop'; 665 $fault = $PSTAMP_NOT_AVAILABLE; 666 } else { 667 # cause the image to be re-made 668 # set up to queue an update run 669 queue_update_run(\$newState, \$fault, \$dep_id, $image->{image_db}, 670 $run_state, $stage, $image->{stage_id}, $need_magic, $image->{label}); 671 } 672 } 673 } 674 675 $num_jobs++; 676 my $command = "$pstamptool -addjob -req_id $req_id -job_type $row->{JOB_TYPE}" 677 . " -outputBase $output_base -rownum $rownum -state $newState -options $option_mask"; 678 $command .= " -fault $fault" if $fault; 679 $command .= " -exp_id $exp_id" if $exp_id; 680 $command .= " -dep_id $dep_id" if $dep_id; 681 682 if ($mode eq "list_job") { 683 # this is a debugging mode, just print the pstamptool that would have run 684 # this is sort of like the mode -noupdate that some other tools support 685 print "$command\n"; 686 } elsif (!$no_update) { 687 # mode eq "queue_job" 688 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 689 run(command => $command, verbose => $verbose); 690 unless ($success) { 691 print STDERR @$stderr_buf; 692 # XXX TODO: now what? Should we mark the error state for the request? 693 # should we keep going for other uris? If so how do we report that some 694 # of the work that the request wanted isn't going to get done 695 my_die("failed to queue job for request $req_id", $PS_EXIT_UNKNOWN_ERROR); 696 } 697 } else { 698 print "skipping command: $command\n"; 699 } 700 } 701 if ( $num_jobs == 0 ) { 702 print STDERR "no jobs for row $rownum\n" if $verbose; 703 insertFakeJobForRow($row, 1, $PSTAMP_NO_JOBS_QUEUED); 704 $num_jobs = 1; 587 705 } 588 706 return $num_jobs; … … 677 795 return 0 if ($r1->{REQ_TYPE} ne $r2->{REQ_TYPE}); 678 796 return 0 if ($r1->{IMG_TYPE} ne $r2->{IMG_TYPE}); 679 return 0 if ($r1->{ID} ne $r2->{ID});680 return 0 if ($r1->{TESS_ID} ne $r2->{TESS_ID});681 return 0 if ($r1->{REQFILT} ne $r2->{REQFILT});682 return 0 if ($r1->{LABEL} ne $r2->{LABEL});683 return 0 if ($r1->{MJD_MIN} ne $r2->{MJD_MAX});684 return 0 if ($r1->{MJD_MAX} ne $r2->{MJD_MAX});685 return 0 if ($r1->{inverse} ne $r2->{inverse});797 return 0 if ($r1->{ID} ne $r2->{ID}); 798 return 0 if ($r1->{TESS_ID} ne $r2->{TESS_ID}); 799 return 0 if ($r1->{REQFILT} ne $r2->{REQFILT}); 800 return 0 if ($r1->{LABEL} ne $r2->{LABEL}); 801 return 0 if ($r1->{MJD_MIN} ne $r2->{MJD_MAX}); 802 return 0 if ($r1->{MJD_MAX} ne $r2->{MJD_MAX}); 803 return 0 if ($r1->{inverse} ne $r2->{inverse}); 686 804 687 805 if (defined($r1->{COMPONENT})) {
Note:
See TracChangeset
for help on using the changeset viewer.
