IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2010, 5:06:01 PM (16 years ago)
Author:
watersc1
Message:

Almost working version of the mask-stats/software revision code.

Almost.

Location:
branches/czw_branch/20100427
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20100427

  • branches/czw_branch/20100427/ippToPsps/scripts/ippToPsps_run.pl

    r27729 r28017  
    1212
    1313# globals
    14 my ($verbose, $save_temps, $no_op, $no_update, $camera, $product, $output, $dvodb, $datastoreProduct, $label, $singleExpId, $no_publish);
     14my ($verbose, $save_temps, $no_op, $no_update, $camera, $batchType, $output, $dvodb, $datastoreProduct, $label, $singleExpId, $no_publish);
    1515
    1616# TODO temporary until we use database to store current jobid
     
    3131GetOptions(
    3232        'output|o=s' => \$output,
    33         'product|p=s' => \$product,
     33        'batch|b=s' => \$batchType,
    3434        'dvodb|d=s' => \$dvodb,
    3535        'label|l=s' => \$label,
    3636        'expid|e=s' => \$singleExpId,
    37         'dsproduct|s=s' => \$datastoreProduct,
     37        'product|p=s' => \$datastoreProduct,
    3838        'no_publish' => \$no_publish,
    3939        'verbose|v' => \$verbose,
     
    4848pod2usage(
    4949        -msg => "\n   Required options:\n\n".
    50         "--product <init|det|diff|stack>\n".
     50        "--batch <init|det|diff|stack>\n".
    5151        "--output <path>\n".
    52         "--label <label> | --expid <expid>\n" .
    53         "--dvodb <path>\n\n",
     52        "--label <label> or --expid <expid>\n" .
     53        "--dvodb <path>\n".
     54        "\n   Optional:\n\n".
     55        "--product <datastoreProduct>\n".
     56        "--no_publish - won't publish to datastore\n".
     57        "--save_temps - will save temporary files\n".
     58        "--no-op - ?\n".
     59        "--no-update - will not update database\n",
    5460        -exitval => 3
    5561        ) unless
    56 defined $product and
     62defined $batchType and
    5763defined $output and
    5864defined $dvodb and
     
    128134            WHERE camRun.chip_id = chipRun.chip_id
    129135            AND chipRun.exp_id = rawExp.exp_id
    130             AND camRun.label like '%$label%'
     136            AND camRun.label LIKE '%$label%'
    131137            ORDER BY rawExp.exp_id ASC
    132138SQL
     139            #AND rawExp.exp_id > 136561
    133140            #AND camRun.dist_group LIKE 'sas'
    134141            #AND rawExp.decl >= '-0.157079633' AND rawExp.decl <= '0.157079633' Jims Dec range
     
    138145        $query = $db->prepare(<<SQL);
    139146
    140         SELECT DISTINCT exp_id FROM rawExp WHERE rawExp.exp_id = $singleExpId
     147        SELECT DISTINCT rawExp.exp_id, dist_group FROM rawExp, chipRun WHERE chipRun.exp_id = rawExp.exp_id AND rawExp.exp_id = $singleExpId
    141148SQL
    142149    }
     
    176183        my $batchOutputPath = sprintf("$jobOutputPath/%s", $batchDir);
    177184
    178         print "* Preparing exposure as job '$job'...\n";
     185        print "* Preparing exposure $expId as job '$job'...\n";
    179186
    180187        # make directories
    181188        mkdir($jobOutputPath, 0777);
    182189        mkdir($batchOutputPath, 0777);
     190        setJobId($jobId);
    183191
    184192        # run IppToPsps program
    185         if (runIppToPsps($db, $expId, $batchOutputPath, $product)) {
     193        if (runIppToPsps($db, $expId, $batchOutputPath, $batchType)) {
    186194
    187195            # write batch manifest and tar and zip up
    188             if (writeBatchManifest($batchOutputPath, $batchDir, $product)) {
     196            if (writeBatchManifest($batchOutputPath, $batchDir, $batchType)) {
    189197
    190198                if (tarAndZipDirectory($jobOutputPath, $batchDir)) {
     
    207215                }
    208216
    209                 setJobId($jobId);
    210217                $jobId++;
    211218                $batchId = 0;
     
    218225        }
    219226
    220         if ($product eq "init" ) {print "* Wrote initialisation batch\n"; last;}
     227        if ($batchType eq "init" ) {print "* Wrote initialisation batch\n"; last;}
    221228
    222229
     
    271278#######################################################################################
    272279sub runIppToPsps {
    273     my ($db, $expId, $batchOutputPath, $product) = @_;
     280    my ($db, $expId, $batchOutputPath, $batchType) = @_;
    274281
    275282    my $success = 0;
    276283
    277284    # before anything else, we can publish the init batch
    278     if ($product =~ /init/) {
     285    if ($batchType =~ /init/) {
    279286        $success = produceInit($batchOutputPath);
    280287    }
    281     elsif ($product =~ /det/) {
     288    elsif ($batchType =~ /det/) {
    282289        $success = produceDetections($db, $expId, $batchOutputPath);
    283290    }
    284     elsif ($product =~ /diff/) {
     291    elsif ($batchType =~ /diff/) {
    285292        $success = produceDiffs($db, $expId, $batchOutputPath);
    286293    }
     
    337344sub writeBatchManifest {
    338345
    339     my ($path,$batch,$product) = @_;
     346    my ($path,$batch,$batchType) = @_;
    340347
    341348    use XML::Writer;
     
    352359    # determine batch 'type'
    353360    my $type;
    354     if($product eq 'init') {$type = "IN";}
    355     elsif($product eq 'det') {$type = "P2";}
    356     elsif ($product eq 'stack') {$type = "ST";}
    357     elsif ($product eq 'diff') {$type = "OB";}
     361    if($batchType eq 'init') {$type = "IN";}
     362    elsif($batchType eq 'det') {$type = "P2";}
     363    elsif ($batchType eq 'stack') {$type = "ST";}
     364    elsif ($batchType eq 'diff') {$type = "OB";}
    358365    else {$type = "UNKNOWN";}
    359366
     
    366373    my $maxObjId;
    367374    my $filename;
    368     if($product eq 'det') {
     375    if($batchType eq 'det') {
    369376
    370377        while (<MYFILE>) {
     
    403410
    404411            # write manifest element TODO untidy
    405             if($product eq 'det' && $filename eq $f) {
     412            if($batchType eq 'det' && $filename eq $f) {
    406413
    407414                $writer->startTag('manifest',
     
    430437            #$writer->startTag('md5'); $writer->characters("$md5sum"); $writer->endTag();
    431438
    432             #if($product eq 'det' && $filename eq $f) {
     439            #if($batchType eq 'det' && $filename eq $f) {
    433440
    434441                #    $writer->startTag('minObjId'); $writer->characters("$minObjId"); $writer->endTag();
     
    577584    my ($outputPath) = @_;
    578585
    579     my $success = runProgram( "NULL", $outputPath, 0, $product);
     586    my $success = runProgram( "NULL", $outputPath, 0, $batchType);
    580587    return $success;
    581588}
     
    621628        close $tempFile;
    622629
    623         $success = runProgram($tempName, $outputPath, $expId, $product);
     630        $success = runProgram($tempName, $outputPath, $expId, $batchType);
    624631        return $success;
    625632    }
     
    670677    }
    671678
    672     my $ret = runProgram($tempName, $outputPath, $expId, $product);
     679    my $ret = runProgram($tempName, $outputPath, $expId, $batchType);
    673680
    674681    close $tempFile;
     
    683690#######################################################################################
    684691sub runProgram {
    685     my ($input, $output, $expid, $product) = @_;
     692    my ($input, $output, $expid, $batchType) = @_;
    686693
    687694    # build command
     
    692699    $command .= " -config config"; # TODO
    693700    $command .= " -expid $expid";
    694     $command .= " -product $product";
     701    $command .= " -batch $batchType";
    695702    $command .= " -results $resultsFileName";
    696703
Note: See TracChangeset for help on using the changeset viewer.