IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35900 for trunk/pstamp


Ignore:
Timestamp:
Aug 7, 2013, 11:10:18 AM (13 years ago)
Author:
bills
Message:

Magic is still dead.

File:
1 edited

Legend:

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

    r35609 r35900  
    8080my $dquery_job_run = can_run('dquery_job_run.pl') or (warn "Can't find dquery_job_run.pl" and $missing_tools = 1);
    8181my $streaksreplace = can_run('streaksreplace')  or (warn "Can't find streaksreplace"  and $missing_tools = 1);
    82 my $magicdstool = can_run('magicdstool')  or (warn "Can't find magicdstool"  and $missing_tools = 1);
    8382my $whichnode = can_run('whichnode') or (warn "can't find whichnode" and $missing_tools = 1);
    8483
     
    10099    # XXX: should we do any other sanity checking?
    101100    my_die("argument list is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString;
    102 
    103     my $nan_masked = 1;
    104     my $muggle = 0;
    105     if (!$params->{magicked}) {
    106         $nan_masked = 0;
    107     } elsif ($params->{magicked} and ($options & ($PSTAMP_REQUEST_UNCENSORED | $PSTAMP_REQUIRE_UNCENSORED))) {
    108         # Attempt to find or create a muggle image
    109         $nan_masked = 0;
    110         $muggle = 1;
    111     }
    112101
    113102    if ($stage eq "raw") {
     
    122111    my @file_list = ($params->{image});
    123112   
    124     if ($nan_masked or ($options & $PSTAMP_SELECT_MASK)) {
     113    if ($options & $PSTAMP_SELECT_MASK) {
    125114        $mask = $params->{mask};
    126115        $fileArgs .= " -mask $mask";
     
    164153    my ($tmpImage, $tmpMask, $tmpVariance, $tmproot);
    165154   
    166     if ($muggle) {
    167         # first see if the original uncensored images are around
    168         if (check_for_backups($params, \$fileArgs)) {
    169             # We're good to go. fileArgs has been edited to contain the paths for the original uncensored images
    170             print "Making stamps from backup images\n";
    171         } elsif (($options & $PSTAMP_REQUIRE_UNCENSORED) and ($stage ne 'chip')) {
    172             # user required uncensored but since stage isn't chip we can't rebuild them
    173             my_die("uncensored inputs not available for job $job_id", $job_id, $PSTAMP_NOT_AVAILABLE, 'stop');
    174         } elsif (($options & $PSTAMP_REQUEST_UNCENSORED) and ($params->{state} ne 'full') and ($stage ne 'chip')) {
    175             # we can only restore pixels for chip stage images if the data has been updated.
    176             # the data will have been updated if the params->{state} the state when the job was queued is not 'full' (
    177             # XXX: we should probably be looking explicitly at the job and checking for a dep_id
    178             print "Run state was $params->{state}: will make stamps from destreaked $stage images.\n";
    179             # make stamps from uncensored images
    180             $muggle = 0;
    181         } else {
    182             # Try and replace the streaks from the recovery images
    183 
    184             my $temp_dir = metadataLookupStr($ipprc->{_siteConfig}, "TEMP.DIR") or &my_die("Unable to find temporary directory in site configuration", $job_id, $PS_EXIT_CONFIG_ERROR);
    185             $tmproot = tempdir("$temp_dir/psjob.$job_id.XXXX", CLEANUP => !$save_temps);
    186             my $muggle_command = "$streaksreplace -stage $stage -tmproot $tmproot";
    187             # find the "directory" of the input path_base
    188             my $inputdir = dirname($image);
    189             my $base = basename($image);
    190             $tmpImage = "$tmproot/$base";
    191 
    192             @file_list = ();
    193 
    194             # XXX: We should get the recovery_path_base from the magicDSFile but that requires a bunch of file rule and
    195             # stage work. Import the rule here.
    196             my $recImage = "$inputdir/REC_$base";
    197             my $newFileArgs = " -file $tmpImage";
    198             $muggle_command .= " -image $image -recimage $recImage";
    199             push @file_list, $recImage;
    200 
    201             if ($mask) {
    202                 $base = basename($mask);
    203                 $tmpMask = "$tmproot/$base";
    204                 $newFileArgs .= " -mask $tmpMask";
    205                 my $recMask = "$inputdir/REC_$base";
    206                 $muggle_command .= " -mask $mask -recmask $recMask";
    207                 push @file_list, $recMask;
    208             }
    209 
    210             if ($variance) {
    211                 $base = basename($variance);
    212                 $tmpVariance = "$tmproot/$base";
    213                 $newFileArgs .= " -variance $tmpVariance";
    214                 my $recVariance = "$inputdir/REC_$base";
    215                 $muggle_command .= " -weight $variance -recweight $recVariance";
    216                 push @file_list, $recVariance;
    217             }
    218             if (check_files(0, @file_list)) {
    219                 # recovery files exist and are accessible restore the excised pixels
    220 
    221                 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    222                     run(command => $muggle_command, verbose => $verbose);
    223                 unless ($success) {
    224                     my $exitStatus = WEXITSTATUS($error_code);
    225                     my_die( "streaksreplace failed with error code: $exitStatus", $job_id, $exitStatus);
    226                 }
    227 
    228                 # set the ppstamp file arguments
    229                 $fileArgs = $newFileArgs;
    230             } else {
    231                 if ($options & $PSTAMP_REQUIRE_UNCENSORED) {
    232                     my_die( "unable to restore uncensored images", $job_id, $PSTAMP_NOT_AVAILABLE);
    233                 }
    234                 # just make stamps from the censored images
    235                 print "Unable to restore uncensored images, will extract stamps from censored images\n";
    236                 # these files won't be used so zap them
    237                 ($tmpImage, $tmpMask, $tmpVariance, $tmproot) = (undef, undef, undef, undef);
    238             }
    239         }
    240     }
    241 
    242     # MAGIC IS DEAD
    243     $nan_masked = 0;
    244 
    245155    my $command = "$ppstamp $outputBase $argString $fileArgs";
    246156    $command .= " -write_jpeg" if ($options & $PSTAMP_SELECT_JPEG);
    247157    $command .= " -nocompress" if ($options & $PSTAMP_SELECT_UNCOMPRESSED);
    248158    $command .= " -stage $stage";
    249     $command .= " -censor_masked" if $nan_masked;
    250159    $command .= " -dbname $dbname" if $dbname;
    251160    $command .= " -dbserver $dbserver" if $dbserver;
     
    523432}
    524433
    525 sub check_for_backups {
    526     my $params = shift;
    527     my $r_fileArgs = shift;
    528 
    529     my $command = "$magicdstool -destreakedfile -stage $params->{stage} -stage_id $params->{stage_id} -component $params->{component} -dbname $params->{imagedb}";
    530     my $results = runToolAndParse($command, $verbose);
    531     my $dsComponent  = $results->[0];
    532 
    533     if ($dsComponent and ($dsComponent->{data_state} eq 'full')) {
    534 
    535         print "magicDSFile state is full. Backup images should exist\n";
    536 
    537         # replace the file names with the backup paths
    538         # fileArgs has the form:  -file imagename [-mask maskname] [-weight weightname]
    539         my @args = split " ", $$r_fileArgs;
    540 
    541         my $newFileArgs;
    542         while (@args) {
    543             my $a = shift @args;
    544             my $f = shift @args;
    545             my_die( "unexpected fileArg list $$r_fileArgs", $job_id, $PS_EXIT_PROG_ERROR, 'run') if !$a or !$f;
    546 
    547             my $backup_image_name = $ipprc->destreaked_filename($f);
    548             my_die( "failed to extract backup image name from $f", $job_id, $PS_EXIT_PROG_ERROR, 'run') if !$backup_image_name;
    549             $newFileArgs .= " $a $backup_image_name";
    550         }
    551         $$r_fileArgs = $newFileArgs;
    552 
    553         return 1;
    554     }
    555 
    556     return 0;
    557 }
    558 
    559434my $neb;
    560435sub storage_object_exists
Note: See TracChangeset for help on using the changeset viewer.