IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36061


Ignore:
Timestamp:
Aug 30, 2013, 3:20:12 PM (13 years ago)
Author:
bills
Message:

Include filter in pstampJob.outputBase
remove some dead magic code including references to UNCENSORED variables
only change the label to xxx.BIG once

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/pstampparse.pl

    r36048 r36061  
    5151
    5252die "invalid mode '$mode'" unless ($mode eq "list_uri") or ($mode eq "queue_job");
    53 die "--file is required"     if !defined($request_file_name);
     53die "--file is required"   unless defined($request_file_name);
    5454
    5555if ($mode ne "list_uri") {
    56     die "req_id is required"   if !$req_id;
     56    die "req_id is required"  if !$req_id;
    5757    die "outdir is required"  if !$outdir;
    58     die "product is required"  if !$product;
     58    die "product is required" if !$product;
    5959} else {
    60     $req_id = 0;
    61     $outdir = "nowhere";
     60    # mode eq 'list_uri' (used for parser testing)
     61    # these values won't be used for anything but should be defined to avoid errors
     62    $req_id  = 0;
     63    $outdir  = "nowhere";
    6264    $product = "dummy";
    6365}
     
    7678my $pstamptool  = can_run('pstamptool')  or (warn "Can't find pstamptool"  and $missing_tools = 1);
    7779my $pstampdump  = can_run('pstampdump') or (warn "Can't find pstampdump" and $missing_tools = 1);
    78 my $fields  = can_run('fields') or (warn "Can't find fields" and $missing_tools = 1);
     80my $fields      = can_run('fields') or (warn "Can't find fields" and $missing_tools = 1);
    7981
    8082if ($missing_tools) {
     
    116118if ($extver >= 2) {
    117119    # We have a version 2 file. Require that the new keywords be supplied.
    118     my_die("action not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) unless defined $action;
    119 
    120     my_die("invalid action: $action supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) unless (uc($action) eq 'PROCESS' or uc($action) eq 'PREVIEW');
    121 
    122     my_die("email not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) unless $email;
     120    my_die("action not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST)
     121        unless defined $action;
     122
     123    my_die("invalid action: $action supplied in version $extver request file $request_file_name\n",
     124        $PSTAMP_INVALID_REQUEST)
     125        unless (uc($action) eq 'PROCESS' or uc($action) eq 'PREVIEW');
     126
     127    my_die("email not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST)
     128        unless $email;
     129
    123130    # XXX check for "valid" $email
    124131} else {
    125132    # for version 1 file the action is process and email is not used
    126133    $action = 'PROCESS';
    127     $email = 'null';
     134    $email  = 'null';
    128135}
    129136
     
    175182
    176183
    177 if ($req_id and !$no_update) {
     184{
    178185    # update the database with the request name. This will be used as the
    179     # the output data store's product name
     186    # the fileset name in the output data store
    180187    my $command = "$pstamptool -updatereq -req_id $req_id  -set_name $req_name";
    181188    $command .= " -set_username $email" if $email ne 'null';
    182189    $command .= " -set_outProduct $product";
    183190    $command .= " -set_label $label" if $label_changed;
    184     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    185         run(command => $command, verbose => $verbose);
    186     unless ($success) {
    187         my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
    188     }
    189 }
     191    unless ($no_update) {
     192        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     193            run(command => $command, verbose => $verbose);
     194        unless ($success) {
     195            my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
     196        }
     197    } else {
     198        print "skipping $command\n";
     199    }
     200}
     201
    190202if ($duplicate_req_name) {
    191203    exit 0;
     
    212224}
    213225
    214 if (!$rows) {
     226my $nRows = $rows ? scalar @$rows : 0;
     227print "\n$nRows rows read from request file\n";
     228
     229unless ($nRows) {
    215230    # pstamp_job_run was invoked so the request file must have contained a valid header
    216     # We can only assume that the file is invalid or more likely empty. The print above will let the
    217     # log file know. Insert a faulted fake job and exit successfully.
     231    # a request file with no rows is invalid.
     232    # The print above will let the log file know a bit more.
     233    # Insert a faulted fake job and exit this program successfully.
    218234    print STDERR "Invalid request file.\n";
    219235    insertFakeJobForRow(undef, 0, $PSTAMP_INVALID_REQUEST);
     
    222238
    223239
    224 my $nRows = scalar @$rows;
    225 print "\n$nRows rows read from request file\n";
    226 
    227240
    228241my $num_jobs = 0;
    229242my $imageList;
    230243my $stage;
     244my $big_limit = 100;    # XXX: this should be in a configuration file some where
    231245foreach my $row (@$rows) {
    232246
    233     if (($label =~ /PSI/ or $label =~ /WEB/) and ($nRows > 200 or $num_jobs > 200) and $req_id and !$no_update) {
    234         # this is a big request and it came from one of the "high priority" channels
    235         # upload page and doesn't have a specific label assigned
    236         # change it to a generic one that runs with lower priority
     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;
    237256        $label = ($label =~ /WEB/) ? 'WEB.BIG' : 'PSI.BIG';
    238         print "\nChanging label for big WEB.UP request to $label\n";
     257        print "\nChanging label for big $old_label request to $label\n";
    239258
    240259        my $command = "$pstamptool -updatereq -req_id $req_id  -set_label $label";
     
    260279
    261280if (($action eq 'LIST' or $mode eq "queue_job") and ($num_jobs eq 0)) {
    262     print STDERR "no jobs created for $req_name\n" if $verbose;
    263     insertFakeJobForRow(undef, 0, $PSTAMP_INVALID_REQUEST);
     281    # this should not happen. The function above is required to insert a fake job for any
     282    # rows that did not yield any jobs.
     283    print STDERR "ERROR: zero jobs created for $req_name\n";
     284    insertFakeJobForRow(undef, 0, $PS_EXIT_PROG_ERROR);
    264285}
    265286
     
    535556    my $image_db   = $proj_hash->{dbname};
    536557    my $camera     = $proj_hash->{camera};
    537     my $need_magic    = $proj_hash->{need_magic};
     558    my $need_magic = $proj_hash->{need_magic};
    538559    # Since user can get unmagicked data "by coordinate" requests can go back in time
    539560    # to dredge unusable data from the "dark days"...
     
    546567    $need_magic = 0 if $stage eq 'stack';
    547568
    548     if ($need_magic) {
    549 
    550         # this project requires that postage stamps be extracted from destreaked images
    551 
    552         if ($option_mask & ($PSTAMP_REQUEST_UNCENSORED | $PSTAMP_REQUIRE_UNCENSORED)) {
    553             # The user has requested uncensored stamps
    554 
    555             if (!$dest_requires_magic) {
    556                 # and this user's data store destination is allowed uncensored stamps, so accept the request
    557                 $need_magic = 0;
    558             } else {
    559                 print STDERR "Error row $rownum: User not authorized to to request uncensored stamps.\n";
    560                 if ($option_mask & $PSTAMP_REQUIRE_UNCENSORED) {
    561                     # user required uncensored stamps. Can't do it so fail.
    562                     foreach my $r (@$rowList) {
    563                         insertFakeJobForRow($r, 1, $PSTAMP_NOT_AUTHORIZED);
    564                         $num_jobs++;
    565                     }
    566                     return $num_jobs;
    567                 }
    568 
    569                 # user will accept censored stamps. alter OPTION_MASK and continue
    570 
    571                 print STDERR "    Will attempt to make destreaked stamps\n";
    572                 # zap the offending bit in the option mask
    573                 $option_mask = $option_mask ^ ($PSTAMP_REQUEST_UNCENSORED);
    574                 foreach my $r (@$rowList) {
    575                     $r->{OPTION_MASK} = $option_mask;
    576                 }
    577             }
    578         }
    579     }
    580    
     569    # XXX: magic is dead
     570    $need_magic = 0;
     571
    581572    my $numRows = scalar @$rowList;
    582573
     
    715706    }
    716707    $base =~ s/.fits$//;
     708
     709    my $filter = $image->{filter};
     710    if (!$filter) {
     711        if ($stage eq 'diff') {
     712            $filter = $image->{filter_1};
     713        }
     714        if (!$filter) {
     715            # XXX: perhaps this should be a programming error...
     716            print STDERR "missing filter using 'X'\n";
     717            $filter = 'X';
     718        }
     719    }
     720    # use first character of filter
     721    $filter = substr($filter, 0, 1);
    717722           
    718     my $output_base = "$outdir/${rownum}_${job_num}_${base}";
     723    my $output_base = "$outdir/${rownum}_${job_num}_${filter}_${base}";
    719724    write_params($output_base, $image);
    720725
Note: See TracChangeset for help on using the changeset viewer.