IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 19, 2010, 6:50:13 PM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/eam_branches/ipp-20100621/ippToPsps/perl
Files:
3 edited
5 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100621/ippToPsps/perl/ippToPsps/Gpc1Db.pm

    r28794 r28980  
    2828        JOIN diffSkyfile USING (diff_id)
    2929        WHERE rawExp.exp_id = $expId AND camRun.magicked
    30 
    3130SQL
    3231
     
    3736###########################################################################
    3837#
    39 # Returns camera-stage smf files for this exposure
     38# Returns camera-stage smf file for this exposure as used in the provided DVO Db
     39#
     40###########################################################################
     41sub getCameraStageSmfForThisDvoDb {
     42    my ($self, $dvoDb, $expId) = @_;
     43
     44    my $query = $self->{_db}->prepare(<<SQL);
     45    SELECT path_base
     46        FROM camProcessedExp
     47        JOIN addRun USING(cam_id)   
     48        JOIN camRun USING(cam_id) 
     49        JOIN chipRun USING(chip_id)   
     50        JOIN rawExp USING(exp_id)   
     51        WHERE addRun.dvodb LIKE '$dvoDb'
     52        AND exp_id = $expId;
     53SQL
     54
     55    $query->execute;
     56    return $query->fetchrow_array();
     57}
     58
     59###########################################################################
     60#
     61# Returns latest processed camera-stage smf file for this exposure ID
    4062#
    4163###########################################################################
     
    6486###########################################################################
    6587#
    66 # Returns a list of exposure IDs for this survey
     88# Returns a list of exposure IDs in a given DVO database 
    6789#
    6890###########################################################################
    69 sub getExposureListFromSurvey {
    70     my ($self, $survey) = @_;
     91sub getExposureListFromDvoDb {
     92    my ($self, $dvoDb, $exposures) = @_;
    7193
    7294    my $query = $self->{_db}->prepare(<<SQL);
    73 
    74     SELECT rawExp.exp_id, rawExp.exp_name, camRun.dist_group
    75         FROM camRun, chipRun, rawExp
    76         WHERE camRun.state = 'full'
    77         AND camRun.chip_id = chipRun.chip_id
    78         AND chipRun.exp_id = rawExp.exp_id
    79         AND camRun.dist_group = '$survey'   
    80         GROUP BY  rawExp.exp_id
    81         ORDER BY rawExp.exp_id ASC;
     95    SELECT exp_id, exp_name, camRun.dist_group
     96        FROM addRun
     97        JOIN camRun USING(cam_id)
     98        JOIN chipRun USING(chip_id)
     99        JOIN rawExp USING(exp_id)
     100        WHERE addRun.dvodb LIKE '$dvoDb'
     101        AND addRun.state = 'full'
     102        ORDER BY exp_id ASC;
    82103SQL
    83 
    84104
    85105    #AND rawExp.exp_id > 133887
     
    93113
    94114    $query->execute;
    95     return $query->fetchall_arrayref();
     115    ${$exposures} = $query->fetchall_arrayref();
     116    my $numOfExposures = scalar @{${$exposures}};
     117    if ($numOfExposures > 0) {
     118   
     119        print "* Found $numOfExposures exposures in DVO Db '$dvoDb'\n";
     120        return 1;
     121    }
     122
     123    print "* No exposures found in DVO Db '$dvoDb'\n";
     124    return 0;
    96125}
    97126
    98127###########################################################################
    99128#
    100 # Returns info for this exposure ID
     129# Returns info for this exposure ID for given DVO Db
    101130#
    102131###########################################################################
    103 sub getExposureListFromExpId {
    104     my ($self, $expId) = @_;
     132sub getSingleExposureFromDvoDb {
     133    my ($self, $dvoDb, $expId, $exposures) = @_;
    105134
    106135    my $query = $self->{_db}->prepare(<<SQL);
    107     SELECT DISTINCT rawExp.exp_id,  rawExp.exp_name, dist_group
    108         FROM rawExp, chipRun
    109         WHERE chipRun.exp_id = rawExp.exp_id
    110         AND rawExp.exp_id = $expId
     136    SELECT exp_id, exp_name, camRun.dist_group
     137        FROM addRun
     138        JOIN camRun USING(cam_id)
     139        JOIN chipRun USING(chip_id)
     140        JOIN rawExp USING(exp_id)
     141        WHERE addRun.dvodb LIKE '$dvoDb'
     142        AND exp_id = $expId;
    111143SQL
    112144
    113145    $query->execute;
    114     return $query->fetchall_arrayref();
     146
     147    ${$exposures} = $query->fetchall_arrayref();
     148
     149    if (scalar @{${$exposures}} > 0) {
     150   
     151        print "* Found exposure $expId in DVO Db '$dvoDb'\n";
     152        return 1;
     153    }
     154
     155    print "* Exposure $expId NOT found in DVO Db '$dvoDb'\n";
     156    return 0;
    115157}
    116158
    117 
    118 
    1191591;
  • branches/eam_branches/ipp-20100621/ippToPsps/perl/ippToPsps/IppToPspsDb.pm

    r28794 r28980  
    88use ippToPsps::MySQLDb;
    99our @ISA = qw(ippToPsps::MySQLDb);    # inherits from MySQLDb
     10
     11
     12###########################################################################
     13#
     14# Returns a list of batches that have been processed and loaded to datastore
     15#
     16###########################################################################
     17sub getBatchList {
     18    my ($self, $exposures, $fromTime, $toTime) = @_;
     19
     20    my $query = $self->{_db}->prepare(<<SQL);
     21    SELECT created, exp_id, batch_id, survey_id, deleted
     22        FROM batches
     23        WHERE processed = 1
     24        AND on_datastore = 1
     25        AND created >= '$fromTime'
     26        AND created <= '$toTime';
     27SQL
     28
     29    # TODO remove date restriction
     30    $query->execute;
     31    ${$exposures} = $query->fetchall_arrayref();
     32    my $count = scalar @{${$exposures}};
     33
     34   printf( "* Found %d batch%s\n", $count, ($count==1) ? "" : "es");
     35   return $count;
     36}
     37
     38###########################################################################
     39#
     40# Returns a info about one particular batch
     41#
     42###########################################################################
     43sub getSingleBatch{
     44    my ($self, $batch_id, $exposures) = @_;
     45
     46    my $query = $self->{_db}->prepare(<<SQL);
     47    SELECT created, exp_id, batch_id, survey_id, deleted
     48        FROM batches
     49        WHERE batch_id = $batch_id
     50        AND processed = 1
     51        AND on_datastore = 1;
     52SQL
     53 
     54    $query->execute;
     55    ${$exposures} = $query->fetchall_arrayref();
     56    my $count = scalar @{${$exposures}};
     57
     58   printf( "* Found %d batch%s\n", $count, ($count==1) ? "" : "es");
     59   return $count;
     60}
    1061
    1162#######################################################################################
     
    56107#
    57108########################################################################################
    58 sub updateDb {
    59     my ($self, $batchId, $expId, $processed, $published, $totalDetections) = @_;
    60 
    61 print "HJHJH '$batchId', '$expId', '$processed', '$published', '$totalDetections'\n";
     109sub updateBatch {
     110    my ($self, $batchId, $expId, $processed, $published, $totalDetections, $minObjId, $maxObjId) = @_;
     111
     112    if (!$minObjId) {$minObjId = -1;}
     113    if (!$maxObjId) {$maxObjId = -1;}
    62114
    63115if (!$totalDetections) {$totalDetections = -1;}
     
    65117    my $query = $self->{_db}->prepare(<<SQL);
    66118    UPDATE batches
    67         SET processed = $processed, on_datastore = $published, total_detections = $totalDetections
     119        SET
     120          processed = $processed,
     121          on_datastore = $published,
     122          total_detections = $totalDetections,
     123          min_obj_id = $minObjId,
     124          max_obj_id = $maxObjId
    68125        WHERE batch_id = $batchId
    69126        AND exp_id = $expId;
     
    84141    SELECT COUNT(*)
    85142        FROM batches
    86         WHERE exp_id = $expId
     143        WHERE exp_id = $expId
     144        AND created > '2010-08-12'
    87145        AND processed = 1;
    88146SQL
     
    102160#
    103161########################################################################################
    104 sub getNewBatchId {
    105     my ($self, $expId, $surveyType, $batchType) = @_;
     162sub createNewBatch {
     163    my ($self, $expId, $surveyType, $batchType, $dvoDb, $datastoreProduct) = @_;
    106164
    107165    my $query = $self->{_db}->prepare(<<SQL);
     
    118176    $batchId++;
    119177
    120     my $query = $self->{_db}->prepare(<<SQL);
     178    $query = $self->{_db}->prepare(<<SQL);
    121179    INSERT INTO batches
    122         (batch_id, exp_id, survey_id, batch_type)
     180        (batch_id, exp_id, survey_id, batch_type, dvo_db, datastore_product)
    123181        VALUES
    124         ($batchId, $expId, '$surveyType', '$batchType');
    125 
     182        ($batchId, $expId, '$surveyType', '$batchType', '$dvoDb', '$datastoreProduct');
    126183SQL
    127184
     
    133190}
    134191
     192#######################################################################################
     193#
     194# Updates an existing database record to show datastore status
     195#
     196#######################################################################################
     197sub setBatchAsDeleted {
     198    my ($self,$batchId, $expId) = @_;
     199
     200    my $query = $self->{_db}->prepare(<<SQL);
     201    UPDATE batches
     202        SET deleted = 1
     203        WHERE batch_id = $batchId
     204        AND exp_id = $expId;
     205SQL
     206
     207        $query->execute; # TODO check response of these
     208}
     209
     210#######################################################################################
     211#
     212# Updates an existing database record with info from ODM
     213#
     214#######################################################################################
     215sub updateODMStatus {
     216    my ($self,$batchId, $expId, $loadedToOdm, $mergeWorthy, $mergeCompleted) = @_;
     217
     218    my $query = $self->{_db}->prepare(<<SQL);
     219    UPDATE batches
     220        SET loaded_to_ODM = $loadedToOdm, merge_worthy = $mergeWorthy, merged = $mergeCompleted
     221        WHERE batch_id = $batchId
     222        AND exp_id = $expId;
     223SQL
     224
     225        $query->execute; # TODO check response of these
     226}
     227
     228
     229
    135230###########################################################################
    136231#
     
    142237
    143238    my $currentRevision = -1;
    144     my $latestRevision = 4;
     239    my $latestRevision = 6;
    145240
    146241    while ($currentRevision != $latestRevision) {
    147242
    148243        $currentRevision = $self->getRevision();
    149         if ($self->{_verbose}) {print "* Current revision = $currentRevision\n";}
     244        if ($self->{_verbose}) {print "* Current database revision = $currentRevision\n";}
    150245
    151246        if ($currentRevision == 0) {$self->createRevision_1();}
     
    153248        elsif ($currentRevision == 2) {$self->createRevision_3();}
    154249        elsif ($currentRevision == 3) {$self->createRevision_4();}
     250        elsif ($currentRevision == 4) {$self->createRevision_5();}
     251        elsif ($currentRevision == 5) {$self->createRevision_6();}
    155252    }
    156253}
     
    164261    my ($self) = @_;
    165262
    166     print "* Creating revision 1 of '$dbname'\n";
     263    print "* Creating revision 1 of '$self->{_dbName}'\n";
    167264
    168265    my $query = $self->{_db}->prepare(<<SQL);
     
    175272        $query->execute;
    176273
    177     my $query = $self->{_db}->prepare(<<SQL);
     274    $query = $self->{_db}->prepare(<<SQL);
    178275    CREATE TABLE batches (
    179276            batch_id BIGINT NOT NULL,
     
    192289        $query->execute;
    193290
    194     setRevision(1);
     291    $self->setRevision(1);
    195292}
    196293
     
    203300    my ($self) = @_;
    204301
    205     print "* Creating revision 2 of '$dbname'\n";
     302    print "* Creating revision 2 of '$self->{_dbName}'\n";
    206303
    207304    my $query = $self->{_db}->prepare(<<SQL);
     
    211308        $query->execute;
    212309
    213     setRevision(2);
     310    $self->setRevision(2);
    214311}
    215312
     
    222319    my ($self) = @_;
    223320
    224     print "* Creating revision 3 of '$dbname'\n";
     321    print "* Creating revision 3 of '$self->{_dbName}'\n";
    225322
    226323    my $query = $self->{_db}->prepare(<<SQL);
     
    230327        $query->execute;
    231328
    232     setRevision(3);
     329    $self->setRevision(3);
    233330}
    234331
     
    241338    my ($self) = @_;
    242339
    243     print "* Creating revision 4 of '$dbname'\n";
     340    print "* Creating revision 4 of '$self->{_dbName}'\n";
    244341
    245342    my $query = $self->{_db}->prepare(<<SQL);
     
    249346        $query->execute;
    250347
    251     setRevision(4);
     348    $self->setRevision(4);
     349}
     350
     351#######################################################################################
     352#
     353# Create revision 5 of the database
     354#
     355#######################################################################################
     356sub createRevision_5 {
     357    my ($self) = @_;
     358
     359    print "* Creating revision 5 of '$self->{_dbName}'\n";
     360
     361    my $query = $self->{_db}->prepare(<<SQL);
     362         CREATE INDEX batchesIndex ON batches (batch_id);
     363SQL
     364    $query->execute;
     365
     366    $self->setRevision(5);
     367}
     368
     369#######################################################################################
     370#
     371# Create revision 6 of the database
     372#
     373#######################################################################################
     374sub createRevision_6 {
     375    my ($self) = @_;
     376
     377    print "* Creating revision 6 of '$self->{_dbName}'\n";
     378
     379    my $query = $self->{_db}->prepare(<<SQL);
     380    ALTER TABLE batches
     381        ADD COLUMN dvo_db VARCHAR(50) DEFAULT "UNKNOWN",
     382        ADD COLUMN datastore_product VARCHAR(50)  DEFAULT "UNKNOWN",
     383        ADD COLUMN min_obj_id BIGINT DEFAULT 0,
     384        ADD COLUMN max_obj_id BIGINT DEFAULT 0
     385SQL
     386    $query->execute;
     387
     388    $self->setRevision(6);
    252389}
    253390
  • branches/eam_branches/ipp-20100621/ippToPsps/perl/ippToPsps_run.pl

    r28794 r28980  
    66use PS::IPP::Config 1.01 qw( :standard );
    77use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    8 use Pod::Usage qw( pod2usage );
    98use IPC::Cmd 0.36 qw( can_run run );
    109use File::Temp qw(tempfile);
    1110use XML::LibXML;
     11use File::Basename;
    1212
    1313# local classes
    1414use ippToPsps::Gpc1Db;
    1515use ippToPsps::IppToPspsDb;
     16use ippToPsps::Datastore;
    1617
    1718# globals
    1819my $camera = 'GPC1';
    1920my $batchType = undef;
    20 my $survey = undef;
    21 my $dvodb = undef;
     21my $dvoLocation = undef;
     22my $dvoDb = undef;
     23my $fullDvoPath = undef;
    2224my $verbose = undef;
    2325my $save_temps = undef;
    24 my $no_update = undef;
    2526my $output = undef;
    2627my $singleExpId = undef;
     
    3435        'output|o=s' => \$output,
    3536        'batch|b=s' => \$batchType,
    36         'dvodb|d=s' => \$dvodb,
    37         'survey|s=s' => \$survey,
     37        'dvo|d=s' => \$fullDvoPath,
    3838        'expid|e=s' => \$singleExpId,
    3939        'product|p=s' => \$datastoreProduct,
    4040        'verbose|v' => \$verbose,
    4141        'save_temps|t' => \$save_temps,
    42         'no-update|u' => \$no_update,
    4342        'force|f' => \$force,
    4443        'tarnzip|z' => \$dontTarNZip,
     
    4948print "* \n";
    5049if (@ARGV) {
    51     print "* UNKNKOWN: option:                         @ARGV\n"; $quit=1;}
     50    $quit=1;
     51    print "* UNKNKOWN: option                          @ARGV\n";
     52}
    5253if (!defined $output) {
    53     print "* REQUIRED: need to provide an output path: -o <path>\n"; $quit=1;}
     54    $quit=1;
     55    print "* REQUIRED: need to provide an output path  -o <path>\n";
     56}
    5457if (!defined $batchType) {
    55     print "* REQUIRED: need to define a batch type:    -b <init|det|diff|stack>\n"; $quit=1;}
    56 if (!defined $dvodb) {
    57     print "* REQUIRED: need to provide a DVO Db path:  -d <path>\n"; $quit=1;}
    58 if (!defined $survey and !defined $singleExpId) {
    59     print "* REQUIRED: need to provide a survey type:  -s <ThreePi|STS|SAS|M31|MD01|MD02|etc> ***OR***\n";
    60     print "*           an exposure ID                  -e <expID>\n"; $quit=1;}
     58    $quit=1;
     59    print "* REQUIRED: need to define a batch type     -b <init|det|diff|stack>\n";
     60}
     61if (!defined $fullDvoPath) {
     62    $quit=1;
     63    print "* REQUIRED: need to provide a DVO Db        -d <pathToDVO>\n";
     64}
     65if (!defined $singleExpId) {
     66
     67    print "* OPTIONAL: a single exposure ID            -e <expID>           (default = none)\n";
     68}
    6169if (!defined $datastoreProduct) {
    62     print "* OPTIONAL: datastore product:              -p <product>\n";}
     70
     71    print "* OPTIONAL: datastore product               -p <product>         (default = none, i.e. data will not be published)\n";
     72}
    6373if (!defined $verbose) {
    64     print "* OPTIONAL: run in verbose mode:            -v\n"; $verbose = 0;}
     74    $verbose = 0;
     75    print "* OPTIONAL: run in verbose mode             -v                   (default = $verbose)\n";
     76}
    6577if (!defined $save_temps) {
    66     print "* OPTIONAL: keep temp files:                -t\n"; $save_temps = 0;}
    67 if (!defined $no_update) {
    68     print "* OPTIONAL: don't update database:          -u\n"; $no_update = 0;}
     78    $save_temps = 0;
     79    print "* OPTIONAL: keep temp files                 -t                   (default = $save_temps)\n";
     80}
    6981if (!defined $force) {
    70     print "* OPTIONAL: force if already processed :    -f\n"; $force = 0;}
     82    $force = 0;
     83    print "* OPTIONAL: force if already processed      -f                   (default = $force)\n";
     84}
    7185if (!defined $dontTarNZip) {
    72     print "* OPTIONAL: don't tar and zip output :      -z\n"; $dontTarNZip = 0;}
    73     print "*\n*******************************************************************************\n";
     86    $dontTarNZip = 0;
     87    print "* OPTIONAL: don't tar and zip output        -z                   (default = $dontTarNZip)\n";
     88}
     89print "*\n*******************************************************************************\n";
    7490
    7591if ($quit) { exit; }
     92
     93# determine PSPS batch 'type'
     94my $pspsBatchType;
     95if ($batchType eq 'init') {$pspsBatchType = "IN";}
     96elsif ($batchType eq 'det') {$pspsBatchType = "P2";}
     97elsif ($batchType eq 'stack') {$pspsBatchType = "ST";}
     98elsif ($batchType eq 'diff') {$pspsBatchType = "OB";}
     99else {$pspsBatchType = "UNKNOWN";}
     100
     101# spilt full DVO path into Db and path
     102$fullDvoPath =~ s/\/$//; # strip off trailing '\'
     103($dvoDb, $dvoLocation) = fileparse($fullDvoPath);
    76104
    77105my $gpc1Db = new ippToPsps::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser", $verbose, $save_temps);
    78106my $ippToPspsDb = new ippToPsps::IppToPspsDb("ippToPsps", "ippdb01", "ipp", "ipp", $verbose, $save_temps);
     107my $datastore = undef;
     108if ($datastoreProduct) {$datastore = new ippToPsps::Datastore($datastoreProduct, $verbose, $save_temps);}
    79109
    80110# check we can run programs and get camera config
    81111my $ippToPsps = can_run('ippToPsps') or (warn "Can't find 'ippToPsps' program" and exit($PS_EXIT_CONFIG_ERROR));
    82 my $dsreg = can_run('dsreg') or (warn "Can't find 'dsreg' program" and exit($PS_EXIT_CONFIG_ERROR));
    83112my $ipprc = PS::IPP::Config->new($camera) or (warn "Can't get camera configuration" and exit($PS_EXIT_CONFIG_ERROR));
    84113
    85114if ($batchType eq "init") {$initBatch = 1;}
    86115else {$initBatch = 0;}
    87 process();
     116
     117if (!process()) {print "* Finished unsuccessfully\n";}
     118else {print "* Finished successfully\n";}
    88119
    89120#######################################################################################
     
    114145    my ($resultsFile, $resultsFilePath) = tempfile( "/tmp/ippToPsps_results.XXXX", UNLINK => !$save_temps);
    115146    my $lastExpId = $ippToPspsDb->getLastExpId();
    116     my $rows = undef;
     147    my $exposures;
    117148
    118149    my $query;
    119150    if ($initBatch) {
    120    
    121         my @row = (0, 'NULL', 'ThreePi');
    122         @{$rows} = (\@row);
    123     }
    124     elsif ($singleExpId) { $rows = $gpc1Db->getExposureListFromExpId($singleExpId); }
    125     else { $rows = $gpc1Db->getExposureListFromSurvey($survey); }
    126 
    127 # TODO check if there are no exposures and give a warning
     151
     152        my @exposure = (0, 'NULL', 'ThreePi');
     153        @{$exposures} = (\@exposure);
     154    }
     155    # get single exposure
     156    elsif ($singleExpId) {
     157       
     158        if (!$gpc1Db->getSingleExposureFromDvoDb($dvoDb, $singleExpId, \$exposures)) {return 0;}
     159    }
     160    # get all exposures in this DVO Db
     161    else {
     162       
     163        if (!$gpc1Db->getExposureListFromDvoDb($dvoDb, \$exposures)) {return 0;}
     164    }
    128165
    129166    my $batchId = 0;
     
    132169
    133170    #my $batchId = -1;
    134     my $row;
    135     foreach $row ( @{$rows} ) {
    136         my ($expId, $expName, $distGroup) = @{$row};
    137     #        print "JHGHGHGHGH2 $expId, $expName, $distGroup\n";
    138 
    139     # loop round exposures
    140     #while (my @row = $query->fetchrow_array()) {
    141      #   my ($expId, $expName, $distGroup) = @row;
     171    my $exposure;
     172    foreach $exposure ( @{$exposures} ) {
     173        my ($expId, $expName, $distGroup) = @{$exposure};
    142174
    143175        if (!$initBatch && $ippToPspsDb->isExposureAlreadyProcessed($expId)) {
    144                
    145                 if ($force) {print "* Forcing....\n";}
    146                 else {next};
     176
     177            if ($force) {print "* Forcing....\n";}
     178            else {next};
    147179        }
    148180
     
    150182        if (!$surveyType) {next;}
    151183
    152         $batchId = $ippToPspsDb->getNewBatchId($expId, $surveyType, $batchType);
     184        $batchId = $ippToPspsDb->createNewBatch($expId, $distGroup, $pspsBatchType, $dvoDb, (defined $datastore) ? $datastoreProduct : "NONE");
    153185
    154186        # TODO quit here if no sensible batch ID
     
    156188        # generate batch path from batch IDs
    157189        my $batch = sprintf("B%08d", $batchId);
    158         my $batchDir = sprintf("$output/$batch");
     190        my $dvoDir = "$output/$dvoDb";
     191        my $batchDir = "$dvoDir/$batch";
     192
     193        # make directories
     194        unless(-d $dvoDir) {mkdir($dvoDir, 0777);}
    159195        mkdir($batchDir, 0777);
     196
    160197        $published = 0;
    161198
     
    171208            if (writeBatchManifest($batchDir, $batch, $batchType, $surveyType, $filename, $minObjId, $maxObjId)) {
    172209
     210                # tar n' zip
    173211                if (!$dontTarNZip) {
    174                     my $tarball = tarAndZipBatch($output, $batch);
    175                     if ($tarball && $datastoreProduct && publishToDatastore($batch, $output, $tarball)) {$published = 1;}
     212                    my $tarball = tarAndZipBatch($dvoDir, $batch);
     213
     214                    # and publish
     215                    if ($tarball && defined $datastore ) {
     216                       
     217                        $published = $datastore->register($batch, $dvoDir, $tarball, "IPP_PSPS", "tgz");
     218                    }
    176219                }
    177220            }
    178221
    179             $ippToPspsDb->updateDb($batchId, $expId, 1, $published, $totalDetections);
     222            $ippToPspsDb->updateBatch($batchId, $expId, 1, $published, $totalDetections, $minObjId, $maxObjId);
    180223        }
    181224
     
    330373    my $timeStamp = sprintf "%4d-%02d-%02d %02d:%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min,$sec;
    331374
    332     # determine batch 'type'
    333     my $type;
    334     if ($batchType eq 'init') {$type = "IN";}
    335     elsif ($batchType eq 'det') {$type = "P2";}
    336     elsif ($batchType eq 'stack') {$type = "ST";}
    337     elsif ($batchType eq 'diff') {$type = "OB";}
    338     else {$type = "UNKNOWN";}
    339 
    340375    # create XML file
    341376    my $writer = new XML::Writer(OUTPUT => $output, DATA_MODE => 1, DATA_INDENT=>2);
     
    372407                $writer->startTag('manifest',
    373408                        "name" => "$batch",
    374                         "type" => $type,
     409                        "type" => $pspsBatchType,
    375410                        "survey" => $pspsSurvey,
    376411                        "timestamp" => "$timeStamp",
     
    382417                $writer->startTag('manifest',
    383418                        "name" => "$batch",
    384                         "type" => $type,
     419                        "type" => $pspsBatchType,
    385420                        "timestamp" => "$timeStamp");
    386421            }
     
    404439
    405440#######################################################################################
    406 #
    407 # register new job with the datastore
    408 #
    409 ########################################################################################
    410 sub publishToDatastore {
    411     my ($batch, $path, $tarball) = @_;
    412 
    413     my ($tempFile, $tempName) = tempfile( "/tmp/ippToPsps_dsregList.XXXX", UNLINK => !$save_temps);
    414 
    415     print $tempFile $tarball . '|||tgz' . "\n";
    416 
    417     # build dsreg command command
    418     my $command  = "$dsreg";
    419     $command .= " --add $batch";
    420     $command .= " --copy";
    421     $command .= " --datapath $path";
    422     $command .= " --type IPP_PSPS";
    423     $command .= " --product $datastoreProduct";
    424     $command .= " --list $tempName";
    425 
    426     # run command
    427     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    428         run(command => $command, verbose => $verbose);
    429 
    430     if (!$success) { print "* Unable to publish $tarball to datastore\n" and return 0 };
    431 
    432     print "* Successfully published $tarball to datastore\n";
    433 
    434     close($tempFile);
    435 
    436     return 1;
    437 }
    438 
    439 #######################################################################################
    440441#
    441442# runs ippToPsps to produce init batch
     
    457458    my ($expId, $expName, $surveyType, $outputPath, $resultsFilePath) = @_;
    458459
    459     my $nebPath = $gpc1Db->getCameraStageSmf($expId);
     460    my $nebPath = $gpc1Db->getCameraStageSmfForThisDvoDb($dvoDb, $expId);
    460461    if (!$nebPath) { return 0; }
    461462
     
    527528    $command .= " -input $input";
    528529    $command .= " -output $output";
    529     $command .= " -D CATDIR $dvodb";
     530    $command .= " -D CATDIR $fullDvoPath";
    530531    $command .= " -config ../config"; # TODO
    531     $command .= " -expid $expid";
     532        $command .= " -expid $expid";
    532533    $command .= " -expname $expName";
    533534    $command .= " -survey $surveyType";
Note: See TracChangeset for help on using the changeset viewer.