Changeset 28980 for branches/eam_branches/ipp-20100621/ippToPsps/perl
- Timestamp:
- Aug 19, 2010, 6:50:13 PM (16 years ago)
- Location:
- branches/eam_branches/ipp-20100621/ippToPsps/perl
- Files:
-
- 3 edited
- 5 copied
-
checkOdmStatus.pl (copied) (copied from trunk/ippToPsps/perl/checkOdmStatus.pl )
-
convertPhotCodesToXml.pl (copied) (copied from trunk/ippToPsps/perl/convertPhotCodesToXml.pl )
-
ippToPsps/Datastore.pm (copied) (copied from trunk/ippToPsps/perl/ippToPsps/Datastore.pm )
-
ippToPsps/Gpc1Db.pm (modified) (4 diffs)
-
ippToPsps/IppToPspsDb.pm (modified) (18 diffs)
-
ippToPsps_run.pl (modified) (14 diffs)
-
pspsSchema2xml.pl (copied) (copied from trunk/ippToPsps/perl/pspsSchema2xml.pl )
-
removeFromDatastore.pl (copied) (copied from trunk/ippToPsps/perl/removeFromDatastore.pl )
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/ippToPsps/perl/ippToPsps/Gpc1Db.pm
r28794 r28980 28 28 JOIN diffSkyfile USING (diff_id) 29 29 WHERE rawExp.exp_id = $expId AND camRun.magicked 30 31 30 SQL 32 31 … … 37 36 ########################################################################### 38 37 # 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 ########################################################################### 41 sub 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; 53 SQL 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 40 62 # 41 63 ########################################################################### … … 64 86 ########################################################################### 65 87 # 66 # Returns a list of exposure IDs for this survey88 # Returns a list of exposure IDs in a given DVO database 67 89 # 68 90 ########################################################################### 69 sub getExposureListFrom Survey{70 my ($self, $ survey) = @_;91 sub getExposureListFromDvoDb { 92 my ($self, $dvoDb, $exposures) = @_; 71 93 72 94 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; 82 103 SQL 83 84 104 85 105 #AND rawExp.exp_id > 133887 … … 93 113 94 114 $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; 96 125 } 97 126 98 127 ########################################################################### 99 128 # 100 # Returns info for this exposure ID 129 # Returns info for this exposure ID for given DVO Db 101 130 # 102 131 ########################################################################### 103 sub get ExposureListFromExpId{104 my ($self, $ expId) = @_;132 sub getSingleExposureFromDvoDb { 133 my ($self, $dvoDb, $expId, $exposures) = @_; 105 134 106 135 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; 111 143 SQL 112 144 113 145 $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; 115 157 } 116 158 117 118 119 159 1; -
branches/eam_branches/ipp-20100621/ippToPsps/perl/ippToPsps/IppToPspsDb.pm
r28794 r28980 8 8 use ippToPsps::MySQLDb; 9 9 our @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 ########################################################################### 17 sub 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'; 27 SQL 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 ########################################################################### 43 sub 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; 52 SQL 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 } 10 61 11 62 ####################################################################################### … … 56 107 # 57 108 ######################################################################################## 58 sub updateDb { 59 my ($self, $batchId, $expId, $processed, $published, $totalDetections) = @_; 60 61 print "HJHJH '$batchId', '$expId', '$processed', '$published', '$totalDetections'\n"; 109 sub updateBatch { 110 my ($self, $batchId, $expId, $processed, $published, $totalDetections, $minObjId, $maxObjId) = @_; 111 112 if (!$minObjId) {$minObjId = -1;} 113 if (!$maxObjId) {$maxObjId = -1;} 62 114 63 115 if (!$totalDetections) {$totalDetections = -1;} … … 65 117 my $query = $self->{_db}->prepare(<<SQL); 66 118 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 68 125 WHERE batch_id = $batchId 69 126 AND exp_id = $expId; … … 84 141 SELECT COUNT(*) 85 142 FROM batches 86 WHERE exp_id = $expId 143 WHERE exp_id = $expId 144 AND created > '2010-08-12' 87 145 AND processed = 1; 88 146 SQL … … 102 160 # 103 161 ######################################################################################## 104 sub getNewBatchId{105 my ($self, $expId, $surveyType, $batchType ) = @_;162 sub createNewBatch { 163 my ($self, $expId, $surveyType, $batchType, $dvoDb, $datastoreProduct) = @_; 106 164 107 165 my $query = $self->{_db}->prepare(<<SQL); … … 118 176 $batchId++; 119 177 120 my$query = $self->{_db}->prepare(<<SQL);178 $query = $self->{_db}->prepare(<<SQL); 121 179 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) 123 181 VALUES 124 ($batchId, $expId, '$surveyType', '$batchType'); 125 182 ($batchId, $expId, '$surveyType', '$batchType', '$dvoDb', '$datastoreProduct'); 126 183 SQL 127 184 … … 133 190 } 134 191 192 ####################################################################################### 193 # 194 # Updates an existing database record to show datastore status 195 # 196 ####################################################################################### 197 sub 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; 205 SQL 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 ####################################################################################### 215 sub 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; 223 SQL 224 225 $query->execute; # TODO check response of these 226 } 227 228 229 135 230 ########################################################################### 136 231 # … … 142 237 143 238 my $currentRevision = -1; 144 my $latestRevision = 4;239 my $latestRevision = 6; 145 240 146 241 while ($currentRevision != $latestRevision) { 147 242 148 243 $currentRevision = $self->getRevision(); 149 if ($self->{_verbose}) {print "* Current revision = $currentRevision\n";}244 if ($self->{_verbose}) {print "* Current database revision = $currentRevision\n";} 150 245 151 246 if ($currentRevision == 0) {$self->createRevision_1();} … … 153 248 elsif ($currentRevision == 2) {$self->createRevision_3();} 154 249 elsif ($currentRevision == 3) {$self->createRevision_4();} 250 elsif ($currentRevision == 4) {$self->createRevision_5();} 251 elsif ($currentRevision == 5) {$self->createRevision_6();} 155 252 } 156 253 } … … 164 261 my ($self) = @_; 165 262 166 print "* Creating revision 1 of '$ dbname'\n";263 print "* Creating revision 1 of '$self->{_dbName}'\n"; 167 264 168 265 my $query = $self->{_db}->prepare(<<SQL); … … 175 272 $query->execute; 176 273 177 my$query = $self->{_db}->prepare(<<SQL);274 $query = $self->{_db}->prepare(<<SQL); 178 275 CREATE TABLE batches ( 179 276 batch_id BIGINT NOT NULL, … … 192 289 $query->execute; 193 290 194 setRevision(1);291 $self->setRevision(1); 195 292 } 196 293 … … 203 300 my ($self) = @_; 204 301 205 print "* Creating revision 2 of '$ dbname'\n";302 print "* Creating revision 2 of '$self->{_dbName}'\n"; 206 303 207 304 my $query = $self->{_db}->prepare(<<SQL); … … 211 308 $query->execute; 212 309 213 setRevision(2);310 $self->setRevision(2); 214 311 } 215 312 … … 222 319 my ($self) = @_; 223 320 224 print "* Creating revision 3 of '$ dbname'\n";321 print "* Creating revision 3 of '$self->{_dbName}'\n"; 225 322 226 323 my $query = $self->{_db}->prepare(<<SQL); … … 230 327 $query->execute; 231 328 232 setRevision(3);329 $self->setRevision(3); 233 330 } 234 331 … … 241 338 my ($self) = @_; 242 339 243 print "* Creating revision 4 of '$ dbname'\n";340 print "* Creating revision 4 of '$self->{_dbName}'\n"; 244 341 245 342 my $query = $self->{_db}->prepare(<<SQL); … … 249 346 $query->execute; 250 347 251 setRevision(4); 348 $self->setRevision(4); 349 } 350 351 ####################################################################################### 352 # 353 # Create revision 5 of the database 354 # 355 ####################################################################################### 356 sub 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); 363 SQL 364 $query->execute; 365 366 $self->setRevision(5); 367 } 368 369 ####################################################################################### 370 # 371 # Create revision 6 of the database 372 # 373 ####################################################################################### 374 sub 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 385 SQL 386 $query->execute; 387 388 $self->setRevision(6); 252 389 } 253 390 -
branches/eam_branches/ipp-20100621/ippToPsps/perl/ippToPsps_run.pl
r28794 r28980 6 6 use PS::IPP::Config 1.01 qw( :standard ); 7 7 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 8 use Pod::Usage qw( pod2usage );9 8 use IPC::Cmd 0.36 qw( can_run run ); 10 9 use File::Temp qw(tempfile); 11 10 use XML::LibXML; 11 use File::Basename; 12 12 13 13 # local classes 14 14 use ippToPsps::Gpc1Db; 15 15 use ippToPsps::IppToPspsDb; 16 use ippToPsps::Datastore; 16 17 17 18 # globals 18 19 my $camera = 'GPC1'; 19 20 my $batchType = undef; 20 my $survey = undef; 21 my $dvodb = undef; 21 my $dvoLocation = undef; 22 my $dvoDb = undef; 23 my $fullDvoPath = undef; 22 24 my $verbose = undef; 23 25 my $save_temps = undef; 24 my $no_update = undef;25 26 my $output = undef; 26 27 my $singleExpId = undef; … … 34 35 'output|o=s' => \$output, 35 36 'batch|b=s' => \$batchType, 36 'dvodb|d=s' => \$dvodb, 37 'survey|s=s' => \$survey, 37 'dvo|d=s' => \$fullDvoPath, 38 38 'expid|e=s' => \$singleExpId, 39 39 'product|p=s' => \$datastoreProduct, 40 40 'verbose|v' => \$verbose, 41 41 'save_temps|t' => \$save_temps, 42 'no-update|u' => \$no_update,43 42 'force|f' => \$force, 44 43 'tarnzip|z' => \$dontTarNZip, … … 49 48 print "* \n"; 50 49 if (@ARGV) { 51 print "* UNKNKOWN: option: @ARGV\n"; $quit=1;} 50 $quit=1; 51 print "* UNKNKOWN: option @ARGV\n"; 52 } 52 53 if (!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 } 54 57 if (!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 } 61 if (!defined $fullDvoPath) { 62 $quit=1; 63 print "* REQUIRED: need to provide a DVO Db -d <pathToDVO>\n"; 64 } 65 if (!defined $singleExpId) { 66 67 print "* OPTIONAL: a single exposure ID -e <expID> (default = none)\n"; 68 } 61 69 if (!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 } 63 73 if (!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 } 65 77 if (!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 } 69 81 if (!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 } 71 85 if (!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 } 89 print "*\n*******************************************************************************\n"; 74 90 75 91 if ($quit) { exit; } 92 93 # determine PSPS batch 'type' 94 my $pspsBatchType; 95 if ($batchType eq 'init') {$pspsBatchType = "IN";} 96 elsif ($batchType eq 'det') {$pspsBatchType = "P2";} 97 elsif ($batchType eq 'stack') {$pspsBatchType = "ST";} 98 elsif ($batchType eq 'diff') {$pspsBatchType = "OB";} 99 else {$pspsBatchType = "UNKNOWN";} 100 101 # spilt full DVO path into Db and path 102 $fullDvoPath =~ s/\/$//; # strip off trailing '\' 103 ($dvoDb, $dvoLocation) = fileparse($fullDvoPath); 76 104 77 105 my $gpc1Db = new ippToPsps::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser", $verbose, $save_temps); 78 106 my $ippToPspsDb = new ippToPsps::IppToPspsDb("ippToPsps", "ippdb01", "ipp", "ipp", $verbose, $save_temps); 107 my $datastore = undef; 108 if ($datastoreProduct) {$datastore = new ippToPsps::Datastore($datastoreProduct, $verbose, $save_temps);} 79 109 80 110 # check we can run programs and get camera config 81 111 my $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));83 112 my $ipprc = PS::IPP::Config->new($camera) or (warn "Can't get camera configuration" and exit($PS_EXIT_CONFIG_ERROR)); 84 113 85 114 if ($batchType eq "init") {$initBatch = 1;} 86 115 else {$initBatch = 0;} 87 process(); 116 117 if (!process()) {print "* Finished unsuccessfully\n";} 118 else {print "* Finished successfully\n";} 88 119 89 120 ####################################################################################### … … 114 145 my ($resultsFile, $resultsFilePath) = tempfile( "/tmp/ippToPsps_results.XXXX", UNLINK => !$save_temps); 115 146 my $lastExpId = $ippToPspsDb->getLastExpId(); 116 my $ rows = undef;147 my $exposures; 117 148 118 149 my $query; 119 150 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 } 128 165 129 166 my $batchId = 0; … … 132 169 133 170 #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}; 142 174 143 175 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}; 147 179 } 148 180 … … 150 182 if (!$surveyType) {next;} 151 183 152 $batchId = $ippToPspsDb-> getNewBatchId($expId, $surveyType, $batchType);184 $batchId = $ippToPspsDb->createNewBatch($expId, $distGroup, $pspsBatchType, $dvoDb, (defined $datastore) ? $datastoreProduct : "NONE"); 153 185 154 186 # TODO quit here if no sensible batch ID … … 156 188 # generate batch path from batch IDs 157 189 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);} 159 195 mkdir($batchDir, 0777); 196 160 197 $published = 0; 161 198 … … 171 208 if (writeBatchManifest($batchDir, $batch, $batchType, $surveyType, $filename, $minObjId, $maxObjId)) { 172 209 210 # tar n' zip 173 211 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 } 176 219 } 177 220 } 178 221 179 $ippToPspsDb->update Db($batchId, $expId, 1, $published, $totalDetections);222 $ippToPspsDb->updateBatch($batchId, $expId, 1, $published, $totalDetections, $minObjId, $maxObjId); 180 223 } 181 224 … … 330 373 my $timeStamp = sprintf "%4d-%02d-%02d %02d:%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min,$sec; 331 374 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 340 375 # create XML file 341 376 my $writer = new XML::Writer(OUTPUT => $output, DATA_MODE => 1, DATA_INDENT=>2); … … 372 407 $writer->startTag('manifest', 373 408 "name" => "$batch", 374 "type" => $ type,409 "type" => $pspsBatchType, 375 410 "survey" => $pspsSurvey, 376 411 "timestamp" => "$timeStamp", … … 382 417 $writer->startTag('manifest', 383 418 "name" => "$batch", 384 "type" => $ type,419 "type" => $pspsBatchType, 385 420 "timestamp" => "$timeStamp"); 386 421 } … … 404 439 405 440 ####################################################################################### 406 #407 # register new job with the datastore408 #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 command418 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 command427 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 #######################################################################################440 441 # 441 442 # runs ippToPsps to produce init batch … … 457 458 my ($expId, $expName, $surveyType, $outputPath, $resultsFilePath) = @_; 458 459 459 my $nebPath = $gpc1Db->getCameraStageSmf ($expId);460 my $nebPath = $gpc1Db->getCameraStageSmfForThisDvoDb($dvoDb, $expId); 460 461 if (!$nebPath) { return 0; } 461 462 … … 527 528 $command .= " -input $input"; 528 529 $command .= " -output $output"; 529 $command .= " -D CATDIR $ dvodb";530 $command .= " -D CATDIR $fullDvoPath"; 530 531 $command .= " -config ../config"; # TODO 531 $command .= " -expid $expid";532 $command .= " -expid $expid"; 532 533 $command .= " -expname $expName"; 533 534 $command .= " -survey $surveyType";
Note:
See TracChangeset
for help on using the changeset viewer.
