IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28015


Ignore:
Timestamp:
May 18, 2010, 4:16:25 PM (16 years ago)
Author:
bills
Message:

Better reporting of errors to client

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm

    r27994 r28015  
    632632    if (($img_type eq "raw") or ($img_type eq "chip")) {
    633633
    634         my $runs = lookup_runs_by_cam_id_and_coords($ipprc, $imagedb, $img_type,
     634        my $chips = lookup_by_cam_id_and_coords($ipprc, $imagedb, $img_type,
    635635            $ra, $dec, $need_magic, $dateobs_begin, $dateobs_end, $filter, $data_group, $verbose);
    636636
    637         # lookup is going to filter these we don't need to do it here
    638 #        $runs = filterRuns($img_type, $need_magic, $runs, $verbose);
    639         foreach my $run (@$runs) {
    640             next if $component and ($run->{component} ne $component);
    641             my $these_results = lookup($ipprc, $rowList, $imagedb, "byid", $img_type, $run->{id},
    642                 $tess_id, $run->{component}, $need_magic,
    643                 $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $verbose);
    644 
    645             next if !$these_results;
    646             push @$results, @$these_results;
     637        if (!$chips or scalar @$chips == 0) {
     638            setErrorCodes($rowList, $PSTAMP_NO_IMAGE_MATCH);
     639        } else {
     640            foreach my $chip (@$chips) {
     641                next if $component and ($chip->{component} ne $component);
     642                my $these_results = lookup($ipprc, $rowList, $imagedb, "byid", $img_type, $chip->{id},
     643                    $tess_id, $chip->{component}, $need_magic,
     644                    $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $verbose);
     645
     646                next if !$these_results;
     647                push @$results, @$these_results;
     648            }
    647649        }
    648650       
    649651    } else {
    650         # this should be checked elsewhere
     652        # this should have been checked elsewhere
    651653        die "unexpected image type $img_type" if ($img_type ne "warp")
    652654                                              and ($img_type ne "stack") and ($img_type ne "diff");
     
    654656        my $skycells = lookup_skycell_by_coords($ipprc, $tess_id, $component, $ra, $dec, $verbose);
    655657
    656         foreach my $skycell (@$skycells) {
    657             my $these_results = lookup($ipprc, $rowList, $imagedb, "byskycell", $img_type, undef,
    658                 $skycell->{tess_id}, $skycell->{component}, $need_magic,
    659                 $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $verbose);
    660 
    661             next if !$these_results;
    662             push @$results, @$these_results;
     658        if (!$skycells or scalar @$skycells == 0) {
     659            setErrorCodes($rowList, $PSTAMP_NO_IMAGE_MATCH);
     660        } else {
     661            foreach my $skycell (@$skycells) {
     662                my $these_results = lookup($ipprc, $rowList, $imagedb, "byskycell", $img_type, undef,
     663                    $skycell->{tess_id}, $skycell->{component}, $need_magic,
     664                    $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $verbose);
     665
     666                next if !$these_results;
     667                push @$results, @$these_results;
     668            }
    663669        }
    664670    }
     
    667673}
    668674
    669 # lookup_runs_by_cam_id_and_coords
    670 # given an ra, dec, and optionally other paramters, find camera runs for exposures
     675# lookup__by_cam_id_and_coords
     676# given an ra, dec, and optionally other parameters, find camera runs for exposures
    671677# that are within some distance of the coordinates
    672 sub lookup_runs_by_cam_id_and_coords {
     678
     679sub lookup_by_cam_id_and_coords {
    673680    my $ipprc      = shift;
    674681    my $imagedb   = shift;
     
    686693
    687694    {
     695        my $search_radius = 1.6; # XXX: this should be camera specific
     696
    688697        my $command = "$camtool -dbname $imagedb -processedexp -pstamp_order";
    689            $command .= " -ra $ra -decl $dec -radius 1.6";
     698           $command .= " -ra $ra -decl $dec -radius $search_radius";
    690699           $command .= " -dateobs_begin $dateobs_begin" if $dateobs_begin;
    691700           $command .= " -dateobs_end   $dateobs_end"   if $dateobs_end  ;
     
    693702           # NOTE: we are applying the data_group to the camera run.
    694703           # If we're looking for chip stage images there is no guarentee that
    695            # chipRun.data_group = camRun.data_group. In practice this is almost
     704           # chipRun.data_group eq camRun.data_group. In practice this is almost
    696705           # always the case. If this turns out to be a problem we can defer
    697706           # the data_group test to when we look up the chipProcessedImfiles
     
    705714        return undef;
    706715    }
    707     my $runs;
     716    my $components;
    708717    my $last_exp_id = 0;
    709718    foreach my $camRun (@$camruns) {
     
    773782
    774783        # build the hash to return
    775         my $run = {
     784        # XXX: very few of the entries in this hash are currently used.
     785        # Used are: id, component
     786        # I had plans to use it for the camRun lookup optimization, but the cache solves the
     787        # problem
     788        my $comp = {
    776789            exp_id    => $camRun->{exp_id},
    777790            exp_name  => $camRun->{exp_name},
    778791            chip_id   => $camRun->{chip_id},
    779792            cam_id    => $camRun->{cam_id},
    780             astrom    => $astrom_resolved,  # XXX: is astrom used?
    781793            class_id  => $class_id,
    782794            component => $class_id
    783795        };
    784796        if ($img_type eq "chip") {
    785             $run->{id} = $camRun->{chip_id};
    786             $run->{state} = $camRun->{chip_state};
    787             $run->{magicked} = $camRun->{chip_magicked};
    788         } else {
    789             $run->{id} = $camRun->{exp_id};
    790             $run->{state} = 'full';
    791             $run->{magicked} = $camRun->{raw_magicked};
    792         }
    793         push @$runs, $run;
    794     }
    795 
    796     return $runs;
     797            $comp->{id} = $camRun->{chip_id};
     798            $comp->{state} = $camRun->{chip_state};
     799            $comp->{magicked} = $camRun->{chip_magicked};
     800        } else {
     801            $comp->{id} = $camRun->{exp_id};
     802            $comp->{state} = 'full';
     803            $comp->{magicked} = $camRun->{raw_magicked};
     804        }
     805        push @$components, $comp;
     806    }
     807
     808    return $components;
    797809}
    798810
  • trunk/pstamp/scripts/pstampparse.pl

    r27993 r28015  
    528528        my $data_state = $image->{data_state};
    529529        $data_state = $run_state if $stage eq 'stack';
    530         if (($run_state eq 'goto_purged') or ($data_state eq 'purged') or
    531             ($run_state eq 'drop') or
    532             ($run_state eq 'error_cleaned') or ($data_state eq 'error_cleaned') or
    533             ($run_state eq 'goto_scrubbed') or ($data_state eq 'scrubbed')) {
     530        if (($run_state =~ /purged/) or ($run_state =~ /scrubbed/)) {
    534531            # image is gone and it's not coming back
    535532            $newState = 'stop';
    536533            $fault = $PSTAMP_GONE;
     534        } elsif (($run_state eq "error_cleaned") or ($data_state eq 'error_cleaned')) {
     535            # if cleanup had an error don't get the user's hopes up
     536            $newState = 'stop';
     537            $fault = $PSTAMP_NOT_AVAILABLE;
    537538        } elsif (($data_state ne 'full') or ($need_magic and ($image->{magicked} < 0))) {
    538539            if ($stage eq 'chip') {
    539540                my $burntool_state = $image->{burntool_state};
    540                 if ($burntool_state and (abs($burntool_state) < 14)) {
     541                # XXX: get value 13 from ppImage recipe
     542                if ($burntool_state and (abs($burntool_state) < 13)) {
    541543                    $newState = 'stop';
    542544                    $fault = $PSTAMP_NOT_AVAILABLE;
     
    708710            my $data_state = $image->{data_state};
    709711            $data_state = $run_state if $stage eq "stack";
    710             if (($run_state eq 'goto_purged') or ($data_state eq 'purged') or
    711                 ($run_state eq 'goto_scrubbed') or ($data_state eq 'scrubbed')) {
     712#            if (($run_state eq 'goto_purged') or ($data_state eq 'purged') or
     713#                ($run_state eq 'goto_scrubbed') or ($data_state eq 'scrubbed')) {
     714            if (($run_state =~ /purged/) or ($run_state =~ /scrubbed/)) {
    712715                # image is gone and it's not coming back
    713716                $newState = 'stop';
    714717                $fault = $PSTAMP_GONE;
     718            } elsif ($run_state eq "error_cleaned") {
     719                # if cleanup had an error don't get the user's hopes up
     720                $newState = 'stop';
     721                $fault = $PSTAMP_NOT_AVAILABLE;
    715722            } elsif (($data_state ne 'full') or ($need_magic and ($image->{magicked} < 0))) {
    716723                # wait for update unless the customer asks us to not to
Note: See TracChangeset for help on using the changeset viewer.