IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2010, 12:49:05 PM (16 years ago)
Author:
eugene
Message:

merging changes from trunk into branches/pap

Location:
branches/pap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/pstamp/scripts/pstamp_job_run.pl

    r27577 r28003  
    7474my $ppstamp    = can_run('ppstamp') or (warn "Can't find ppstamp" and $missing_tools = 1);
    7575my $pstamp_get_image_job    = can_run('pstamp_get_image_job.pl') or (warn "Can't find pstamp_get_image_job.pl" and $missing_tools = 1);
     76my $dqueryparse = can_run('dqueryparse.pl') or (warn "Can't find dqueryparse.pl" and $missing_tools = 1);
    7677
    7778if ($missing_tools) {
     
    8384my $jobStatus;
    8485if ($jobType eq "stamp") {
    85     my $argslist = "$outputBase.args";
    86     open ARGSLIST, "<$argslist" or my_die("failed to open argslist file $argslist", $job_id, $PS_EXIT_UNKNOWN_ERROR);
    87     my $argString = <ARGSLIST>;
    88     close ARGSLIST;
    89     chomp $argString;
     86    my $params = read_params_file($outputBase);
     87
     88    my $argString;
     89    $argString = $params->{job_args};
    9090
    9191    # XXX: should we do any other sanity checking?
    92     my_die("arglist file $argslist is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString;
     92    my_die("argument list is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString;
     93
     94    # XXX: remove -astrom from argString and add it here
     95
     96    $argString .= " -file $params->{image}";
     97    $argString .= " -mask $params->{mask}";
     98    if ($options & $PSTAMP_SELECT_VARIANCE) {
     99        $argString .= " -variance $params->{weight}";
     100    }
    93101
    94102    my $command = "$ppstamp $outputBase $argString";
     
    119127        my %extensions = ( $PSTAMP_SELECT_IMAGE  => "fits",
    120128                           $PSTAMP_SELECT_MASK   => "mk.fits",
    121                            $PSTAMP_SELECT_WEIGHT => "wt.fits");
    122 
    123         my $output_mask = $options & ($PSTAMP_SELECT_IMAGE | $PSTAMP_SELECT_MASK | $PSTAMP_SELECT_WEIGHT);
     129                           $PSTAMP_SELECT_VARIANCE => "wt.fits");
     130
     131        my $output_mask = $options & ($PSTAMP_SELECT_IMAGE | $PSTAMP_SELECT_MASK | $PSTAMP_SELECT_VARIANCE);
    124132
    125133        foreach my $key (keys (%extensions)) {
     
    139147        }
    140148
    141         get_other_outputs($F, $outputBase, $options);
     149        get_other_outputs($F, $outputBase, $options, $params);
    142150
    143151        close $F;
     
    165173    }
    166174} elsif ($jobType eq "detect_query") {
    167     my_die("detect_query jobs not supported yet", $job_id,$PS_EXIT_CONFIG_ERROR);
     175    # detect_query jobs are basically holders to note that we need a file updated before we can continue.
     176    # Load the argument list that dqueryparse should have created the first time it ran, so we know how to
     177    # run it again the same way.
     178    my $argslist = "$outputBase/parse.args";
     179    open ARGSLIST, "<$argslist" or my_die("failed to open argslist file $argslist", $job_id, $PS_EXIT_UNKNOWN_ERROR);
     180    my $argString = <ARGSLIST>;
     181    close ARGSLIST;
     182    chomp $argString;
     183
     184    # XXX: should we do any other sanity checking?
     185    my_die("arglist file $argslist is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString;
     186
     187    my $command = "$dqueryparse --job_id $job_id $argString";
     188    $command .= " --dbname $dbname" if $dbname;
     189    $command .= " --dbserver $dbserver" if $dbserver;
     190    $command .= " --verbose" if $verbose;
     191    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     192        run(command => $command, verbose => $verbose);
     193
     194    # Although dqueryparse can potentially force more updates (and more jobs), it should still return success.
     195    if ($success) {
     196        $jobStatus = $PS_EXIT_SUCCESS;
     197    } else {
     198        $jobStatus = $error_code >> 8;
     199        my_die("dqueryparse.pl failed with error code: $jobStatus", $job_id, $jobStatus);
     200    }
    168201} else {
    169202    my_die("unknown jobType $jobType found", $job_id, $PS_EXIT_PROG_ERROR);
     
    172205# mark the job stopped in the database
    173206{
    174     my $command = "$pstamptool -updatejob -job_id $job_id -state stop";
    175     $command .= " -fault $jobStatus" if $jobStatus;
     207    my $command = "$pstamptool -updatejob -job_id $job_id -set_state stop";
     208    $command .= " -set_fault $jobStatus" if $jobStatus;
    176209    $command .= " -dbname $dbname" if $dbname;
    177210    $command .= " -dbserver $dbserver" if $dbserver;
     
    212245    my $output_base = shift;
    213246    my $options = shift;
     247    my $params = shift;
    214248
    215249    if ($options & ( $PSTAMP_SELECT_CMF | $PSTAMP_SELECT_PSF | $PSTAMP_SELECT_BACKMDL)) {
    216         my $comp = read_params_file($output_base);
    217 
    218         my $stage = $comp->{stage};
     250        if (!$params) {
     251            $params = read_params_file($output_base);
     252        }
     253
     254        my $stage = $params->{stage};
    219255
    220256        # raw files don't have any other data products
     
    225261        # detected in pstampparse so that the user can be notified with
    226262        # a message in parse_error.txt ("warp do not have a background model")
    227         my $cmf_file = $comp->{cmf} if ($options & $PSTAMP_SELECT_CMF);
    228         my $psf_file = $comp->{psf} if ($options & $PSTAMP_SELECT_PSF);
    229         my $backmdl_file = $comp->{backmdl} if ($options & $PSTAMP_SELECT_BACKMDL);
    230         my $pattern_file = $comp->{pattern} if ($options & $PSTAMP_SELECT_BACKMDL);
     263        my $cmf_file = $params->{cmf} if ($options & $PSTAMP_SELECT_CMF);
     264        my $psf_file = $params->{psf} if ($options & $PSTAMP_SELECT_PSF);
     265        my $backmdl_file = $params->{backmdl} if ($options & $PSTAMP_SELECT_BACKMDL);
     266        my $pattern_file = $params->{pattern} if ($options & $PSTAMP_SELECT_BACKMDL);
    231267
    232268        my $outdir = dirname($output_base);
     
    250286            copy_and_register_file($f, $backmdl_file, $outdir, $prefix);
    251287        }
    252         if (0) {
     288       if (0) {
    253289        # don't enable this yet
    254290        if ($pattern_file) {
     
    256292            copy_and_register_file($f, $pattern_file, $outdir, $prefix);
    257293        }
    258         }
     294       }
    259295    }
    260296}
     
    317353        my $command = "$pstamptool -updatejob";
    318354        $command .= " -job_id $job_id";
    319         $command .= " -fault $exit_code";
     355        $command .= " -set_fault $exit_code";
    320356        # XXX: fix pstamptool to not require -state when -fault with nonzero value is provided
    321         $command .= " -state run";
     357        $command .= " -set_state run";
    322358        $command .= " -dbname $dbname" if defined $dbname;
    323359        $command .= " -dbserver $dbserver" if defined $dbserver;
Note: See TracChangeset for help on using the changeset viewer.