IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 7, 2009, 5:55:23 PM (17 years ago)
Author:
bills
Message:

Change file list from a hash to an array of hashes to support bundling camRuns.
Get rid of the legacy file list the system can't runs made with old configs anyways.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/dist_component.pl

    r23728 r23743  
    124124my $file_list = get_file_list($stage, $component, $path_base);
    125125
    126 # If the file list is empty it is an error because we should at least get a config dump file
    127 # XXX: is this true? what about fake?
    128 
    129 &my_die("empty file list", $dist_id, $component, $PS_EXIT_CONFIG_ERROR) if (!scalar keys %$file_list);
     126if ($stage ne 'fake') {
     127    # If the file list is empty it is an error because we should at least get a config dump file
     128    # except for fake stage which doesn't do anything yet
     129    &my_die("empty file list", $dist_id, $component, $PS_EXIT_CONFIG_ERROR) if (!scalar @$file_list);
     130}
    130131
    131132# set up directory for temporary files
     
    149150#   2. magic is not required for this distRun
    150151#   3. the processing for the component produced no images (warp or diff with bad quality for example)
    151 my $nan_masked_pixels = ! ($clean || $no_magic || $poor_quality);
     152my $nan_masked_pixels = ! ($clean || (($stage eq "camera") || ($stage eq 'fake') || ($stage eq 'stack')) || $no_magic || $poor_quality);
    152153
    153154my ($image, $mask, $variance);
    154155
    155 foreach my $file_rule (keys %$file_list) {
     156# foreach my $file_rule (keys %$file_list) {
     157foreach my $file (@$file_list) {
    156158    # check whether this file rule refers to an image, mask, or variance fits image
     159    my $file_rule = $file->{file_rule};
    157160    my $image_type = get_image_type($stage, $file_rule);
    158161
     
    164167            or ($file_rule =~ /.JPEG2/));
    165168
    166     my $file_name = $file_list->{$file_rule};
     169    my $file_name = $file->{name};
    167170    my $base = basename($file_name);
    168171    my $path = $ipprc->file_resolve($file_name);
     
    248251my $bytes;
    249252my $md5sum;
     253if ($stage eq 'fake') {
     254    open DUMMY, ">$tmpdir/fake.$component" or &my_die("Unable to create placeholder for fake component",
     255        $dist_id, $component, $PS_EXIT_CONFIG_ERROR);
     256    print DUMMY "This file is a placeholder\n";
     257    close DUMMY;
     258}
    250259# create the tarfile
    251260{
     
    352361    my $path_base = shift;
    353362
    354     my %file_list;
     363    my @file_list;
    355364    if ($stage eq "raw") {
    356365        # XXX: TODO for now disttool sets path_base is set to the uri of the file
    357366        # eventually rawImfile will have a path_base that we'll need to add '.fits'
    358367        # XXX do we want to distribute the registration log files?
    359         $file_list{"RAW.IMAGE"} = $path_base;
    360         return \%file_list;
     368        my %file;
     369        $file{file_rule} = "RAW.IMAGE";
     370        $file{name} = $path_base;
     371        push @file_list, \%file;
     372        return \@file_list;
    361373    }
    362374
     
    368380    } elsif ($stage eq "camera") {
    369381        $config_file_rule = "PSASTRO.CONFIG";
     382        $component = "";
     383    } elsif ($stage eq 'fake') {
     384        # XXX: fake is a no op now return an emtpy list
     385        return \@file_list;
    370386    } elsif ($stage eq "warp") {
    371387        $config_file_rule = "PSWARP.CONFIG";
     
    381397                    $PS_EXIT_CONFIG_ERROR);
    382398
     399    my %config_file_hash;
     400
    383401    # add the configuration file to the list
    384     $file_list{$config_file_rule} = $config_file;
     402    $config_file_hash{file_rule} = $config_file_rule;
     403    $config_file_hash{name} = $config_file;
     404    push @file_list, \%config_file_hash;
    385405
    386406    my $resolved = $ipprc->file_resolve($config_file);
     
    400420        }
    401421    }
    402 
    403     if ($line) {
    404         # this is a new style config dump that contains the list of files
    405 
    406         my %files;
    407         while ($line = <$in>) {
    408             chomp $line;
    409             my ($key, $type, $val) = split " ", $line;
    410             # skip blank lines
    411             next if !$key;
    412             # we're done when we find END
    413             last if $key eq "END";
    414             # skip multi and other lines
    415             next if ($type ne "STR");
    416 
    417             # printf "%-32.32s   %s\n", $key, $val;
    418 
    419             &my_die("no value found for file rule $key in $resolved", $dist_id, $component,
    420                     $PS_EXIT_CONFIG_ERROR) if (!$val);
    421 
    422             $file_list{$key} = $val;
    423         }
    424         close $in;
    425     } else {
    426         # did not find FILES.OUTPUT in the config file, assume we have an old style file
    427         # and build the distro from the static list which is at the end of this script
    428         my $clean_mdc = get_legacy_file_mdc();
    429 
    430         my $mdlist = $mdcParser->parse($clean_mdc) or
    431                 &my_die("failed to parse legacy file mdc", $dist_id, $component, $PS_EXIT_UNKNOWN_ERROR);
    432 
    433         my $product_lists = parse_md_list($mdlist) or
    434                 &my_die("failed to parse metadata list", $dist_id, $component, $PS_EXIT_UNKNOWN_ERROR);
    435 
    436 
    437         my $product_list;
    438         foreach my $list (@$product_lists) {
    439 
    440             my $list_name = $list->{STAGE};
    441             if (lc ($list_name) eq lc($stage) ) {
    442                 $product_list = $list;
    443             }
    444         }
    445         &my_die("failed to parse find product list for stage $stage", $dist_id, $component, $PS_EXIT_UNKNOWN_ERROR) if !$product_list;
    446 
    447         # resolve each file rule and add it to the file_list
    448         foreach my $rule (keys %$product_list) {
    449             next if $rule eq "STAGE";
    450             my $fn = $ipprc->filename($rule, $path_base, $component) or
    451                 &my_die("Missing entry from camera config: $rule", $dist_id, $component,
    452                     $PS_EXIT_CONFIG_ERROR);
    453             #        printf "%-16.16s\t%s\t%s\n",  $rule, $clean, $fn;
    454 
    455             $file_list{$rule} = $fn;
    456         }
    457     }
    458 
    459     return \%file_list;
     422    &my_die("config dump file does not contain FILES.OUTPUT: $config_file", $dist_id, $component,
     423                    $PS_EXIT_CONFIG_ERROR) if (!$line);
     424
     425    while ($line = <$in>) {
     426        chomp $line;
     427        my ($key, $type, $val) = split " ", $line;
     428        # skip blank lines
     429        next if !$key;
     430        # we're done when we find END
     431        last if $key eq "END";
     432        # skip multi and other lines
     433        next if ($type ne "STR");
     434
     435        # printf "%-32.32s   %s\n", $key, $val;
     436
     437        &my_die("no value found for file rule $key in $resolved", $dist_id, $component,
     438                $PS_EXIT_CONFIG_ERROR) if (!$val);
     439
     440        my %file;
     441        $file{file_rule} = $key;
     442        $file{name} = $val;
     443        push @file_list, \%file;
     444    }
     445    close $in;
     446
     447    return \@file_list;
    460448}
    461449
     
    509497}
    510498
    511 # list of output data products for runs that were made before the configuration re-work
    512 sub get_legacy_file_mdc
    513 {
    514     my $list =
    515 "
    516 #
    517 # interesting things we might want to save in this file
    518 #   1. whether file is to be distributed in 'clean' mode
    519 #   2. whether file is to be cleaned (this should be the same thing)
    520 #   3. type of file 'no, not our business, precious'
    521 
    522 # this data should probably be computed by the relevant program and saved as part
    523 # of the configuration dump that is output.
    524 
    525 
    526 PROD_LIST MULTI
    527 
    528 PROD_LIST   METADATA
    529         STAGE                    STR     RAW
    530     # there is isn't really a file rule for raw images
    531         RAW.IMAGE               BOOL    F
    532 END
    533 
    534 # list of data products for a gpc1 chipProcessedImfile  (made by ppImage)
    535 PROD_LIST   METADATA
    536         STAGE                    STR     CHIP
    537         PPIMAGE.CONFIG          BOOL    T
    538         PPIMAGE.CHIP            BOOL    F
    539         PPIMAGE.CHIP.MASK       BOOL    F
    540         PPIMAGE.CHIP.VARIANCE   BOOL    F
    541 #       PPIMAGE.BIN1            BOOL    T
    542 #       PPIMAGE.BIN2            BOOL    T
    543         PSPHOT.OUT.CMF.SPL      BOOL    T
    544         PSPHOT.BACKMDL          BOOL    T
    545         PPIMAGE.STATS           BOOL    T
    546         LOG.IMFILE              BOOL    T
    547         TRACE.IMFILE            BOOL    T
    548     # where do we put exposure level data such as LOG.EXP ?
    549 END
    550 # exposure level output products from camera processing made by psastro and ppImage (jpegs)
    551 PROD_LIST   METADATA
    552         STAGE                    STR     CAM
    553         PSASTRO.CONFIG          BOOL    T
    554         PSASTRO.OUTPUT          BOOL    T
    555         PSASTRO.STATS           BOOL    T
    556 #       PPIMAGE.JPEG1           BOOL    T
    557 #       PPIMAGE.JPEG2           BOOL    T
    558         LOG.EXP                 BOOL    T
    559         TRACE.EXP               BOOL    T
    560 END
    561 # chip lelel output products from camera processing made by psastro
    562 PROD_LIST   METADATA
    563         STAGE                    STR CAM_CHIP
    564         PSASTRO.OUTPUT.MASK     BOOL    F
    565 END
    566 PROD_LIST   METADATA
    567         STAGE                    STR     FAKE
    568         PPSIM.OUTPUT            BOOL    F
    569 END
    570 # list of data products for a gpc1 warpSkyfile (pswarp)
    571 PROD_LIST   METADATA
    572         STAGE                    STR     WARP
    573         PSWARP.CONFIG           BOOL    T
    574         PSWARP.OUTPUT           BOOL    F
    575         PSWARP.OUTPUT.MASK      BOOL    F
    576         PSWARP.OUTPUT.VARIANCE  BOOL    F
    577         PSWARP.OUTPUT.SOURCES   BOOL    T
    578         PSPHOT.BACKMDL.MEF      BOOL    T
    579         PSPHOT.PSF.SKY.SAVE     BOOL    T
    580         SKYCELL.STATS           BOOL    T
    581         SKYCELL.TEMPLATE        BOOL    T
    582         LOG.EXP                 BOOL    T
    583         TRACE.EXP               BOOL    T
    584 END
    585 # outputs from diffRun (ppSub)
    586 PROD_LIST   METADATA
    587         STAGE                    STR     DIFF
    588         PPSUB.CONFIG            BOOL    T
    589         PPSUB.OUTPUT            BOOL    F
    590         PPSUB.OUTPUT.MASK       BOOL    F
    591         PPSUB.OUTPUT.VARIANCE   BOOL    F
    592         PPSUB.OUTPUT.KERNELS    BOOL    T
    593 #       PPSUB.OUTPUT.JPEG1      BOOL    T
    594 #       PPSUB.OUTPUT.JPEG2      BOOL    T
    595         PSPHOT.OUT.CMF.MEF      BOOL    T
    596         PSPHOT.BACKMDL.MEF      BOOL    T
    597         SKYCELL.STATS           BOOL    T
    598         LOG.EXP                 BOOL    T
    599         TRACE.EXP               BOOL    T
    600 END
    601 PROD_LIST   METADATA
    602         STAGE                    STR     STACK
    603         PPSTACK.CONFIG          BOOL    T
    604         PPSTACK.OUTPUT          BOOL    F
    605         PPSTACK.OUTPUT.MASK     BOOL    F
    606         PPSTACK.OUTPUT.VARIANCE BOOL    F
    607         PPSTACK.TARGET.PSF      BOOL    T
    608         PSPHOT.OUT.CMF.MEF      BOOL    T
    609         PSPHOT.BACKMDL.MEF      BOOL    T
    610         SKYCELL.STATS           BOOL    T
    611 #       PPSTACK.OUTPUT.JPEG1    BOOL    T
    612 #       PPSTACK.OUTPUT.JPEG2    BOOL    T
    613         LOG.EXP                 BOOL    T
    614         TRACE.EXP               BOOL    T
    615 END
    616 ";
    617     return $list;
    618 }
    619 
    620 
    621499__END__
Note: See TracChangeset for help on using the changeset viewer.