IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 9, 2013, 4:06:09 PM (13 years ago)
Author:
eugene
Message:

merge from trunk

Location:
branches/eam_branches/ipp-20130904/pstamp/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130904/pstamp/scripts

  • branches/eam_branches/ipp-20130904/pstamp/scripts/pstampparse.pl

    r36061 r36192  
    3131my $no_update;
    3232my $dest_requires_magic;
     33my $dump_params = 0;
    3334
    3435# set this to true to disable update processing
     
    4849    'save-temps'=>  \$save_temps,
    4950    'no-update' =>  \$no_update,
     51    'dump-params' => \$dump_params,
    5052);
    5153
     
    238240
    239241
     242# if label is for one of the high priority channels, watch for big requests
     243my $watch_for_big_requests = (!($label =~ /BIG/) and ($label =~ /PSI/ or $label =~ /WEB/));
     244
     245my $big_limit = 100;    # XXX: this should be in a configuration file somewhere not hard coded
     246
     247if ($watch_for_big_requests and $nRows > $big_limit) {
     248    $label = change_to_lower_priority_label($label);
     249    $watch_for_big_requests = 0;
     250}
    240251
    241252my $num_jobs = 0;
    242 my $imageList;
    243 my $stage;
    244 my $big_limit = 100;    # XXX: this should be in a configuration file some where
     253
    245254foreach my $row (@$rows) {
    246 
    247 
    248     if (!($label =~ /BIG/) and ($label =~ /PSI/ or $label =~ /WEB/) and ($nRows > $big_limit or $num_jobs > $big_limit)
    249         and $req_id and !$no_update) {
    250 
    251         # This is a "big" request and it came from one of the "high priority" channels
    252         # and doesn't have a specific label assigned.
    253         # Change the label to a value that its jobs run with lower priority.
    254 
    255         my $old_label = $label;
    256         $label = ($label =~ /WEB/) ? 'WEB.BIG' : 'PSI.BIG';
    257         print "\nChanging label for big $old_label request to $label\n";
    258 
    259         my $command = "$pstamptool -updatereq -req_id $req_id  -set_label $label";
    260         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    261             run(command => $command, verbose => $verbose);
    262         unless ($success) {
    263             my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
    264         }
    265     }
    266255
    267256    # validate the paramaters
     
    276265
    277266    $num_jobs += processRow($action, $row);
     267
     268    # see whether number of jobs limit for high priority request was exceeded
     269    if ($watch_for_big_requests and $num_jobs > $big_limit) {
     270        $label = change_to_lower_priority_label($label);
     271        $watch_for_big_requests = 0;
     272    }
    278273}
    279274
     
    286281
    287282exit 0;
     283
     284# end of main function
     285
     286sub change_to_lower_priority_label {
     287    my $label = shift;
     288    my $old_label = $label;
     289    $label = ($label =~ /WEB/) ? 'WEB.BIG' : 'PSI.BIG';
     290    print "\nChanging label for big $old_label request to $label\n";
     291
     292    my $command = "$pstamptool -updatereq -req_id $req_id  -set_label $label";
     293    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     294        run(command => $command, verbose => $verbose);
     295    unless ($success) {
     296        my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
     297    }
     298    return $label;
     299}
    288300
    289301sub checkRow {
     
    494506    print "\nCalling locate_images_for_row for row: $rownum\n";
    495507
    496     $imageList = locate_images_for_row($ipprc, $image_db, $camera, $row, $verbose);
     508    my $imageList = locate_images_for_row($ipprc, $image_db, $camera, $row, $verbose);
    497509
    498510    my $dtime_locate = gettimeofday() - $start_locate;
     
    586598    # information required is contained there
    587599
    588     $imageList = locate_images($ipprc, $image_db, $rowList, $req_type, $stage, $id, $tess_id, $component,
     600    my $imageList = locate_images($ipprc, $image_db, $rowList, $req_type, $stage, $id, $tess_id, $component,
    589601                $option_mask, $need_magic, $mjd_min, $mjd_max, $filter, $data_group, $verbose);
    590602
     
    777789            print "$image->{image}\n";
    778790            ++$firstRow->{job_num};
     791            if ($dump_params) {
     792                my $rownum = $firstRow->{ROWNUM};
     793                my $jobnum = $firstRow->{job_num};
     794                my $filter = substr $image->{filter}, 0, 1;
     795                my $output_base = "${rownum}_${jobnum}_${filter}";
     796                write_params($output_base, $image);
     797            }
    779798        }
    780799    } elsif ($job_type eq "get_image") {
Note: See TracChangeset for help on using the changeset viewer.