Changeset 35384 for trunk/pstamp/scripts/pstampparse.pl
- Timestamp:
- Apr 9, 2013, 2:08:27 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstampparse.pl (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstampparse.pl
r35380 r35384 211 211 print "\n$nRows rows read from request file\n"; 212 212 213 # If this is a big request and it came from the upload page and doesn't have a specific label assigned 214 # change it to the generic one that has lower with lower priority 215 216 # 217 # Loop over rows in the request file collecting consecutive rows that have the "same images of interest" 218 # in the sense that their selection parameters will yield the same target "Runs". 219 # Process the groups of rows together to reduce lookup time and to potentially make multiple 220 # stamps from the same ppstamp process. 221 222 my @rowList; 213 223 214 my $num_jobs = 0; 224 215 my $imageList; 225 216 my $stage; 226 my $need_magic;227 217 foreach my $row (@$rows) { 218 228 219 if ($label eq 'WEB.UP' and ($nRows > 500 or $num_jobs > 500) and $req_id and !$no_update) { 220 # this is a big request and it came from the upload page and doesn't have a specific label assigned 221 # change it to the generic one that has lower with lower priority 229 222 $label = 'WEB.BIG'; 230 223 print "\nChanging label for big WEB.UP request to $label\n"; … … 237 230 } 238 231 } 239 # sanity check the paramaters 232 233 # validate the paramaters 240 234 if (!checkRow($row)) { 241 235 # when it enconters an error checkRow adds a fake job with an appropriate error code to the database … … 247 241 $row->{error_code} = 0; 248 242 249 if (scalar @rowList == 0) { 250 push @rowList, $row; 251 next; 252 } 253 254 my $firstRow = $rowList[0]; 255 if (same_images_of_interest($firstRow, $row)) { 256 # add this row to the list and move on 257 push @rowList, $row; 258 next; 259 } 260 261 # the images of interest for this new row doesn't match the list. 262 # process the list ... 263 $num_jobs += processRows($action, \@rowList); 264 265 # and reset the list to contain just the new row 266 @rowList = ($row); 267 } 268 269 # out of rows process the list 270 if (scalar @rowList > 0) { 271 $num_jobs += processRows($action, \@rowList); 243 $num_jobs += processRow($action, $row); 272 244 } 273 245 … … 283 255 my $row = shift; 284 256 257 # check validity of the paramters in a request specification 285 258 # If we encounter an error for a particular row add a job with the proper fault code. 259 # also adjust some paramterers like filter and set defaults for some others 286 260 287 261 my $stage = $row->{IMG_TYPE}; … … 315 289 } 316 290 317 318 291 my $component = $row->{COMPONENT}; 319 292 if (!defined $component or (lc($component) eq "null") or (lc($component) eq "all")) { … … 345 318 return 0; 346 319 } 320 321 my $fwhm_min = $row->{FWHM_MIN}; 322 if (!defined $fwhm_min) { 323 $row->{FWHM_MIN} = 0; 324 } elsif (!validNumber($fwhm_min)) { 325 print STDERR "$fwhm_min is not a valid FWHM_MIN\n"; 326 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 327 return 0; 328 } 329 my $fwhm_max = $row->{FWHM_MAX}; 330 if (!defined $fwhm_max) { 331 $row->{FWHM_MAX} = 0; 332 } elsif (!validNumber($fwhm_max)) { 333 print STDERR "$fwhm_max is not a valid FWHM_MAX\n"; 334 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 335 return 0; 336 } 337 347 338 my $data_group = $row->{DATA_GROUP}; 348 339 if (!defined $data_group) { … … 410 401 } 411 402 403 412 404 return 1; 413 405 } … … 418 410 419 411 $num_jobs = 1; 412 return $num_jobs; 413 } 414 415 sub processRow { 416 my $action = shift; 417 my $row = shift; 418 419 my $num_jobs = 0; 420 421 my $project = $row->{PROJECT}; 422 423 # note: resolve_project avoids running pstamptool every time by remembering the 424 # last project resolved 425 my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver); 426 if (!$proj_hash) { 427 insertFakeJobForRow($row, 1, $PSTAMP_UNKNOWN_PROJECT); 428 $num_jobs++; 429 return $num_jobs; 430 } 431 my $image_db = $proj_hash->{dbname}; 432 my $camera = $proj_hash->{camera}; 433 434 my $req_type = $row->{REQ_TYPE}; 435 my $rownum = $row->{ROWNUM}; 436 437 # Since user can get unmagicked data "by coordinate" requests can go back in time 438 # to dredge unusable data from the "dark days"... 439 if ($req_type eq 'bycoord' and $row->{MJD_MIN} == 0) { 440 # ... so unless the user sets mjd_min clamp it to 2009-04-01 441 # XXX: This value should live in the pstampProject table not be hardcoded here 442 $row->{MJD_MIN} = 54922; 443 } 444 445 if (($req_type eq 'byskycell') or ($req_type eq 'bycoord')) { 446 # avoid error from print below if $id isn't needed 447 $row->{ID} = "" if !$row->{ID}; 448 } 449 450 # Call PS::IPP::PStamp::Job locate_images subroutine to get the images for this 451 # request specification. An array reference is returned. 452 my $start_locate = gettimeofday(); 453 454 print "\nCalling new_locate_images for row: $rownum\n"; 455 456 $imageList = new_locate_images($ipprc, $image_db, $camera, $row, $verbose); 457 458 my $dtime_locate = gettimeofday() - $start_locate; 459 print "Time to locate_images for row $rownum $dtime_locate\n"; 460 461 my @rowList = ($row); 462 $num_jobs += queueJobs($action, \@rowList, $imageList); 463 464 # if this row slipped through without a job being added add one. 465 if ($row->{job_num} == 0) { 466 print "row $row->{ROWNUM} produced no jobs\n"; 467 print STDERR "row $row->{ROWNUM} produced no jobs\n"; 468 my $error_code = $row->{error_code}; 469 $error_code = $PSTAMP_NO_IMAGE_MATCH if !$error_code; 470 insertFakeJobForRow($row, ++$row->{job_num}, $error_code); 471 } 472 420 473 return $num_jobs; 421 474 } … … 447 500 } 448 501 my $req_type = $row->{REQ_TYPE}; 449 $stage= $row->{IMG_TYPE};502 my $stage = $row->{IMG_TYPE}; 450 503 my $id = $row->{ID}; 451 504 my $component = $row->{COMPONENT}; … … 463 516 my $image_db = $proj_hash->{dbname}; 464 517 my $camera = $proj_hash->{camera}; 465 $need_magic = $proj_hash->{need_magic};518 my $need_magic = $proj_hash->{need_magic}; 466 519 # Since user can get unmagicked data "by coordinate" requests can go back in time 467 520 # to dredge unusable data from the "dark days"... … … 523 576 # information required is contained there 524 577 525 $imageList = locate_images($ipprc, $image_db, \@rowList, $req_type, $stage, $id, $tess_id, $component,578 $imageList = locate_images($ipprc, $image_db, $rowList, $req_type, $stage, $id, $tess_id, $component, 526 579 $option_mask, $need_magic, $mjd_min, $mjd_max, $filter, $data_group, $verbose); 527 580 … … 533 586 $row->{need_magic} = $need_magic; 534 587 535 $num_jobs += queueJobs($action, \@rowList, $imageList);588 $num_jobs += queueJobs($action, $rowList, $imageList); 536 589 537 590 # if a row slipped through with no jobs add a faulted one 538 foreach my $row (@ rowList) {591 foreach my $row (@$rowList) { 539 592 if ($row->{job_num} == 0) { 540 593 print "row $row->{ROWNUM} produced no jobs\n"; … … 675 728 my $imageList = shift; 676 729 677 my $firstRow = $rowList [0];730 my $firstRow = $rowList->[0]; 678 731 my $stage = $firstRow->{IMG_TYPE}; 679 732 my $job_type = $firstRow->{JOB_TYPE}; … … 1004 1057 my $r_fault = shift; 1005 1058 my $r_dep_id = shift; 1059 1060 my $need_magic = 0; 1006 1061 1007 1062 if ($stage ne 'raw') {
Note:
See TracChangeset
for help on using the changeset viewer.
