IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 30, 2009, 10:19:40 AM (17 years ago)
Author:
bills
Message:

use a file for the list of arguments for a postage stamp job instead of the database

File:
1 edited

Legend:

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

    r24940 r24944  
    133133    # XXX: TODO: sanity check all parameters
    134134
    135     # XXX: TODO: We shouldn't just die in this loop.
     135    # XXX: TODO: We shouldn't really just die in this loop.
    136136    # If we encounter an error for a particular row
    137137    # add a job with the proper fault code. If there is a db or config error we should probably just
     
    148148    my $class_id = $row->{CLASS_ID};
    149149    my $component = $row->{COMPONENT};
     150
    150151    my $filter   = $row->{REQFILT};
    151152    my $mjd_min = $row->{MJD_MIN};
    152153    my $mjd_max = $row->{MJD_MAX};
     154
    153155    my $option_mask= $row->{OPTION_MASK};
    154156
    155     die "region of interest is required to make postage stamps"
     157    die "valid region of interest is required to make postage stamps"
    156158        if (($job_type eq "stamp") and ! validROI($row));
    157159
     
    163165
    164166
    165     # note: resolve_project remembers the last project returned so avoids running
    166     # pstamptool every time
     167    # note: resolve_project avoids running pstamptool every time by remembering the
     168    # last project resolved
    167169    my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver);
    168170    die "project $project not found\n" unless $proj_hash;
     
    176178    if (@rowList) {
    177179        my $firstRow = $rowList[0];
     180        # the collecting might work with !$skycenter but I need to think about it
    178181        if ($skycenter and same_images_of_interest($row, $firstRow)) {
    179182            push @rowList, $row;
     
    181184            next;
    182185        } else {
    183             # Process the jobs for this set of rows
    184             $num_jobs += makeJobs($mode, $stage, $need_magic, \@rowList, $imageList);
     186            # queue the jobs for this set of rows
     187            $num_jobs += queueJobs($mode, $stage, $need_magic, \@rowList, $imageList);
    185188            @rowList = ();
    186189        }
     
    207210
    208211if (@rowList) {
    209     $num_jobs += makeJobs($mode, $stage, $need_magic, \@rowList, $imageList);
     212    $num_jobs += queueJobs($mode, $stage, $need_magic, \@rowList, $imageList);
    210213}
    211214
     
    223226
    224227
    225 sub makeJobsForRow
     228sub queueJobsForRow
    226229{
    227230    my $row = shift;
     
    270273        }
    271274
    272         my $uri = $image->{image};
     275        my $imagefile = $image->{image};
    273276        if (($stage ne "stack") and ($need_magic and !$image->{magicked})) {
    274             print STDERR "skippping non-magicked image $uri\n" if $verbose;
     277            # XXX: should we add a faulted job so the client can know what happened?
     278            print STDERR "skippping non-magicked image $imagefile\n" if $verbose;
    275279            next;
    276280        }
     
    283287
    284288        my $output_base = "$out_dir/${rownum}_${job_num}";
     289        my $argslist = "${output_base}.argslist";
    285290
    286291        # add astrometry file for raw and chip images if one is available
     
    289294        }
    290295
     296        $args .= " -file $imagefile";
     297
    291298        if (($row->{OPTION_MASK} & $PSTAMP_SELECT_MASK) &&  $image->{mask} ) {
    292299            $args .= " -mask $image->{mask}";
     
    296303        }
    297304
     305        # copy the argument list to a file
     306        open ARGSLIST, ">$argslist" or die "failed to open $argslist";
     307        print ARGSLIST "$args\n";
     308        close ARGSLIST or die "failed to close $argslist";
     309
    298310        # XXX: TODO: here is where we need to check whether or not the source inputs still exist
    299311        # and if not, queue an update job and set the job state appropriately.
     
    303315        $num_jobs++;
    304316        my $command = "$pstamptool -addjob -req_id $req_id -job_type $row->{JOB_TYPE}"
    305             . " -uri $uri -outputBase $output_base -args '$args' -rownum $rownum"
     317            . " -uri $argslist -outputBase $output_base -rownum $rownum"
    306318            . " -state $newState";
     319#        $command .= " -args '$args'" if $args;
    307320        $command .= " -exp_id $exp_id" if $exp_id;
    308321        $command .= " -dbname $dbname" if $dbname;
     
    329342}
    330343
    331 sub makeJobs
     344sub queueJobs
    332345{
    333346    my $mode = shift;
     
    404417            }
    405418           
    406 
    407                 # XXX TODO: for raw and chip level images and class_id "null" if there are multiple images
    408                 # use -list instead of -file
    409419            foreach my $row (@$rowList) {
    410                 $num_jobs += makeJobsForRow($row, $thisRun, $have_skycells, $need_magic);
     420                $num_jobs += queueJobsForRow($row, $thisRun, $have_skycells, $need_magic);
    411421            }
    412422        }
     
    461471    my $r2 = shift;
    462472
    463     return 0 if ($r1->{PROJECT} ne $r2->{PROJECT});
     473    return 0 if ($r1->{PROJECT}  ne $r2->{PROJECT});
    464474    return 0 if ($r1->{JOB_TYPE} ne $r2->{JOB_TYPE});
    465475    return 0 if ($r1->{REQ_TYPE} ne $r2->{REQ_TYPE});
     
    467477    return 0 if ($r1->{ID} ne $r2->{ID});
    468478
    469 #    XXX: turn this on when we change the request file format to change class_id into component
    470 #    return false if ($r1->{component} ne $r2->{component});
     479    if (defined($r1->{COMPONENT})) {
     480        return 0 if !defined $r2->{COMPONENT} or ($r1->{COMPONENT} ne $r2->{COMPONENT});
     481    } elsif (defined($r2->{COMPONENT})) {
     482        return 0;
     483    }
    471484
    472485    return 1;
    473486}
    474487
     488sub validNumber
     489{
     490    my $val = shift;
     491
     492    return $val =~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/;
     493}
     494
    475495sub validROI
    476496{
    477497    my $row = shift;
    478     return 0 if !defined $row->{CENTER_X};
    479     return 0 if !defined $row->{CENTER_Y};
    480     return 0 if !defined $row->{WIDTH};
    481     return 0 if !defined $row->{HEIGHT};
     498    return 0 if !validNumber($row->{CENTER_X});
     499    return 0 if !validNumber($row->{CENTER_Y});
     500    return 0 if !validNumber($row->{WIDTH});
     501    return 0 if !validNumber($row->{HEIGHT});
    482502
    483503    return 1;
Note: See TracChangeset for help on using the changeset viewer.