IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 30, 2013, 4:48:58 PM (13 years ago)
Author:
eugene
Message:

updates from trunk

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

Legend:

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

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

    r35504 r36071  
    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 my $nRows = scalar @$rows;
     226my $nRows = $rows ? scalar @$rows : 0;
    215227print "\n$nRows rows read from request file\n";
     228
     229unless ($nRows) {
     230    # pstamp_job_run was invoked so the request file must have contained a valid header
     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.
     234    print STDERR "Invalid request file.\n";
     235    insertFakeJobForRow(undef, 0, $PSTAMP_INVALID_REQUEST);
     236    exit 0;
     237}
     238
    216239
    217240
     
    219242my $imageList;
    220243my $stage;
     244my $big_limit = 100;    # XXX: this should be in a configuration file some where
    221245foreach my $row (@$rows) {
    222246
    223     if ($label eq 'WEB.UP' and ($nRows > 500 or $num_jobs > 500) and $req_id and !$no_update) {
    224         # this is a big request and it came from the upload page and doesn't have a specific label assigned
    225         # change it to the generic one that has lower with lower priority
    226         $label = 'WEB.BIG';
    227         print "\nChanging label for big WEB.UP request to $label\n";
     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";
    228258
    229259        my $command = "$pstamptool -updatereq -req_id $req_id  -set_label $label";
     
    249279
    250280if (($action eq 'LIST' or $mode eq "queue_job") and ($num_jobs eq 0)) {
    251     print STDERR "no jobs created for $req_name\n" if $verbose;
    252     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);
    253285}
    254286
     
    286318    }
    287319    if ($job_type eq 'get_image') {
    288         unless ($req_type eq 'byid' or $req_type eq 'byexp' or ($req_type eq 'byskycell' and $stage eq 'stack')) {
    289             print STDERR "REQ_TYPE must be 'byid' or 'byexp' or byskcyell for stacks for JOB_TYPE 'get_image'\n";
     320        # get_image jobs are quite expensive in terms of space so we are currently restricting them
     321        unless ($req_type eq 'byid' or $req_type eq 'byexp'
     322            or ($req_type eq 'byskycell' and $stage eq 'stack')
     323            or ($stage eq 'stack_summary')) {
     324            print STDERR "REQ_TYPE must be 'byid' or 'byexp' JOB_TYPE 'get_image' for IMG_TYPE $stage\n";
    290325            insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST);
    291326            return 0;
     
    295330    my $component = $row->{COMPONENT};
    296331    if (!defined $component or (lc($component) eq "null") or (lc($component) eq "all")) {
    297         if ($job_type eq 'get_image') {
     332        if ($job_type eq 'get_image' and ! ($stage eq 'stack' or $stage eq 'stack_summary')) {
    298333            $row->{COMPONENT} = 'all';
    299334        } else {
     
    384419    }
    385420
    386     if (($req_type eq "byexp") and ($stage eq "stack")) {
    387         print STDERR "byexp not implemented for stack stage. row: $rownum\n";
     421    if (($req_type eq "byexp") and ($stage eq "stack" or $stage eq 'stack_summary')) {
     422        print STDERR "byexp not implemented for $stage stage. row: $rownum\n";
    388423        insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED);
    389424        return 0;
     
    457492    my $start_locate = gettimeofday();
    458493
    459     print "\nCalling new_locate_images for row: $rownum\n";
     494    print "\nCalling locate_images_for_row for row: $rownum\n";
    460495
    461496    $imageList = locate_images_for_row($ipprc, $image_db, $camera, $row, $verbose);
     
    521556    my $image_db   = $proj_hash->{dbname};
    522557    my $camera     = $proj_hash->{camera};
    523     my $need_magic    = $proj_hash->{need_magic};
     558    my $need_magic = $proj_hash->{need_magic};
    524559    # Since user can get unmagicked data "by coordinate" requests can go back in time
    525560    # to dredge unusable data from the "dark days"...
     
    532567    $need_magic = 0 if $stage eq 'stack';
    533568
    534     if ($need_magic) {
    535 
    536         # this project requires that postage stamps be extracted from destreaked images
    537 
    538         if ($option_mask & ($PSTAMP_REQUEST_UNCENSORED | $PSTAMP_REQUIRE_UNCENSORED)) {
    539             # The user has requested uncensored stamps
    540 
    541             if (!$dest_requires_magic) {
    542                 # and this user's data store destination is allowed uncensored stamps, so accept the request
    543                 $need_magic = 0;
    544             } else {
    545                 print STDERR "Error row $rownum: User not authorized to to request uncensored stamps.\n";
    546                 if ($option_mask & $PSTAMP_REQUIRE_UNCENSORED) {
    547                     # user required uncensored stamps. Can't do it so fail.
    548                     foreach my $r (@$rowList) {
    549                         insertFakeJobForRow($r, 1, $PSTAMP_NOT_AUTHORIZED);
    550                         $num_jobs++;
    551                     }
    552                     return $num_jobs;
    553                 }
    554 
    555                 # user will accept censored stamps. alter OPTION_MASK and continue
    556 
    557                 print STDERR "    Will attempt to make destreaked stamps\n";
    558                 # zap the offending bit in the option mask
    559                 $option_mask = $option_mask ^ ($PSTAMP_REQUEST_UNCENSORED);
    560                 foreach my $r (@$rowList) {
    561                     $r->{OPTION_MASK} = $option_mask;
    562                 }
    563             }
    564         }
    565     }
    566    
     569    # XXX: magic is dead
     570    $need_magic = 0;
     571
    567572    my $numRows = scalar @$rowList;
    568573
     
    701706    }
    702707    $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);
    703722           
    704     my $output_base = "$outdir/${rownum}_${job_num}_${base}";
     723    my $output_base = "$outdir/${rownum}_${job_num}_${filter}_${base}";
    705724    write_params($output_base, $image);
    706725
     
    719738    if (!$no_update) {
    720739        # mode eq "queue_job"
     740        my $start_addjob = gettimeofday();
    721741        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    722742            run(command => $command, verbose => $verbose);
     
    728748            my_die("failed to queue job for request $req_id", $PS_EXIT_UNKNOWN_ERROR);
    729749        }
     750        my $dtime_addjob = gettimeofday() - $start_addjob;
     751        print "Time to addjob for row $rownum $dtime_addjob\n";
    730752    } else {
    731753        print "skipping command: $command\n";
     
    11601182    }
    11611183    if (($img_type eq "raw") or ($img_type eq "chip") or ($img_type eq "warp") or
    1162         ($img_type eq "stack") or ($img_type eq "diff")) {
     1184        ($img_type eq "stack") or ($img_type eq 'stack_summary') or ($img_type eq "diff")) {
    11631185        return 1;
    11641186    } else {
Note: See TracChangeset for help on using the changeset viewer.