- Timestamp:
- May 18, 2010, 5:06:01 PM (16 years ago)
- Location:
- branches/czw_branch/20100427
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
pstamp/scripts/pstampparse.pl (modified) (32 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20100427
- Property svn:mergeinfo changed
-
branches/czw_branch/20100427/pstamp/scripts/pstampparse.pl
r27783 r28017 17 17 use Carp; 18 18 use POSIX; 19 use DateTime;19 use Time::HiRes qw(gettimeofday); 20 20 21 21 my $verbose; … … 25 25 my $request_file_name; 26 26 my $mode = "list_uri"; 27 my $out _dir;27 my $outdir; 28 28 my $product; 29 29 my $label; … … 34 34 'file=s' => \$request_file_name, 35 35 'req_id=s' => \$req_id, 36 'out _dir=s' => \$out_dir,36 'outdir=s' => \$outdir, 37 37 'product=s' => \$product, 38 38 'label=s' => \$label, … … 50 50 if ($mode ne "list_uri") { 51 51 die "req_id is required" if !$req_id; 52 die "out _dir is required" if !$out_dir;52 die "outdir is required" if !$outdir; 53 53 die "product is required" if !$product; 54 54 } … … 129 129 # update the database with the request name. This will be used as the 130 130 # the output data store's product name 131 my $command = "$pstamptool -updatereq -req_id $req_id - name $req_name";132 $command .= " - outProduct $product";131 my $command = "$pstamptool -updatereq -req_id $req_id -set_name $req_name"; 132 $command .= " -set_outProduct $product"; 133 133 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 134 134 run(command => $command, verbose => $verbose); … … 147 147 my $rows; 148 148 { 149 my $start_request_file = gettimeofday(); 149 150 my $command = "$pstampdump $request_file_name"; 150 151 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 154 155 } 155 156 if (@$stdout_buf) { 156 my $table = $mdcParser->parse(join "", @$stdout_buf) or157 my_die("Unable to parse metdata config doc", $PS_EXIT_UNKNOWN_ERROR);158 $rows = parse_md_list($table);159 }157 $rows = parse_md_fast($mdcParser, join "", @$stdout_buf); 158 } 159 my $dtime_request_file = gettimeofday() - $start_request_file; 160 print "Time to read and parse request file: $dtime_request_file\n"; 160 161 161 162 } … … 223 224 my $rownum = $row->{ROWNUM}; 224 225 if (!validID($rownum)) { 225 print STDERR "$rownum is not a valid ROWNUM\n" if $verbose;226 print STDERR "$rownum is not a valid ROWNUM\n"; 226 227 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 227 228 return 0; … … 229 230 my $job_type = $row->{JOB_TYPE}; 230 231 if (($job_type ne "stamp") and ($job_type ne "get_image")) { 231 print STDERR "$job_type is not a valid JOB_TYPE\n" if $verbose;232 print STDERR "$job_type is not a valid JOB_TYPE\n"; 232 233 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 233 234 return 0; … … 237 238 if (($req_type ne "byid") and ($req_type ne "bycoord") and ($req_type ne "byexp") and 238 239 ($req_type ne "byskycell") and ($req_type ne "bydiff")) { 239 print STDERR "$req_type is not a valid REQ_TYPE\n" if $verbose;240 print STDERR "$req_type is not a valid REQ_TYPE\n"; 240 241 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 241 242 return 0; 242 243 } 244 if ($job_type eq 'get_image') { 245 unless ($req_type eq 'byid' or $req_type eq 'byexp') { 246 print STDERR "REQ_TYPE must be 'byid' or 'byexp' for JOB_TYPE 'get_image'\n"; 247 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 248 return 0; 249 } 250 } 243 251 244 252 245 253 my $component = $row->{COMPONENT}; 246 254 if (!defined $component or (lc($component) eq "null") or (lc($component) eq "all")) { 247 $row->{COMPONENT} = $component = ""; 255 if ($job_type eq 'get_image') { 256 $row->{COMPONENT} = 'all'; 257 } else { 258 $row->{COMPONENT} = $component = ""; 259 } 248 260 } 249 261 $row->{TESS_ID} = "" if !defined $row->{TESS_ID}; … … 258 270 my $mjd_min = $row->{MJD_MIN}; 259 271 if (defined($mjd_min) and !validNumber($mjd_min)) { 260 print STDERR "$mjd_min is not a valid MJD_MIN\n" if $verbose;272 print STDERR "$mjd_min is not a valid MJD_MIN\n"; 261 273 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 262 274 return 0; … … 264 276 my $mjd_max = $row->{MJD_MAX}; 265 277 if (defined($mjd_max) and !validNumber($mjd_max)) { 266 print STDERR "$mjd_max is not a valid MJD_MAX\n" if $verbose;278 print STDERR "$mjd_max is not a valid MJD_MAX\n"; 267 279 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 268 280 return 0; … … 288 300 289 301 if (!$skycenter and !$component) { 290 print STDERR "COMPONENT must be specified for pixel coordinate ROI center\n" if $verbose;302 print STDERR "COMPONENT must be specified for pixel coordinate ROI center\n"; 291 303 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 292 304 return 0; … … 295 307 my $stage = $row->{IMG_TYPE}; 296 308 if (!check_image_type($stage)) { 297 print STDERR "invalid IMG_TYPE for row $rownum\n" if $verbose;309 print STDERR "invalid IMG_TYPE for row $rownum\n"; 298 310 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 299 311 return 0; … … 301 313 302 314 if ((($job_type eq "stamp") or ($req_type eq "bycoord")) and ! validROI($row)) { 303 print STDERR "invalid ROI for row $rownum\n" if $verbose;315 print STDERR "invalid ROI for row $rownum\n"; 304 316 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 305 317 return 0; … … 307 319 308 320 if (($req_type eq "byexp") and ($stage eq "stack")) { 309 print STDERR "byexp not implemented for stack stage. row: $rownum\n" if $verbose;321 print STDERR "byexp not implemented for stack stage. row: $rownum\n"; 310 322 insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED); 311 323 return 0; … … 319 331 if ($req_type eq "bycoord") { 320 332 if (!$skycenter) { 321 print STDERR "center must be specified in sky coordintes for bycoord" if $verbose;333 print STDERR "center must be specified in sky coordintes for bycoord"; 322 334 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 323 335 return 0; … … 327 339 if (($req_type eq "byid") or ($req_type eq "bydiff")) { 328 340 if (!validID($row->{ID})) { 329 print STDERR "ID must be a positive integer for req_type $req_type\n" if $verbose;341 print STDERR "ID must be a positive integer for req_type $req_type\n"; 330 342 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 331 343 return 0 … … 349 361 my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver); 350 362 if (!$proj_hash) { 351 print STDERR "project $project not found\n" if $verbose;363 print STDERR "project $project not found\n" ; 352 364 foreach $row (@$rowList) { 353 365 insertFakeJobForRow($row, 1, $PSTAMP_UNKNOWN_PRODUCT); … … 383 395 } 384 396 } 397 398 $need_magic = 0 if $stage eq 'stack'; 385 399 386 400 my $numRows = scalar @$rowList; 387 388 # $tess_id = "" if !defined $tess_id;389 # $component = "" if !defined $component;390 401 391 402 print "Collected $numRows rows beginning with row $rownum. $req_type $stage $id $tess_id $component\n"; … … 393 404 # Call PS::IPP::PStamp::Job locate_images subroutine to get the images for this 394 405 # request specification. An array reference is returned. 395 my $start_locate = DateTime->now->mjd;406 my $start_locate = gettimeofday(); 396 407 397 408 # XXX: perhaps we should get rid of most of this argument list. … … 402 413 $option_mask, $need_magic, $mjd_min, $mjd_max, $filter, $data_group, $verbose); 403 414 404 # XXX: why use mjd? It doesn't have great precision. 405 my $dtime_locate = (DateTime->now->mjd - $start_locate) * 86400.; 415 my $dtime_locate = gettimeofday() - $start_locate; 406 416 print "Time to locate_images for row $rownum $dtime_locate\n"; 407 417 408 if (!$imageList or !@$imageList) { 409 print STDERR "no matching images found for row $rownum\n" if $verbose; 410 # note in this case queueJobs inserts the fake job for these rows 411 } 412 # handle this 418 # handle this XXX: what did I mean by this comment 413 419 $row->{need_magic} = $need_magic; 414 420 … … 502 508 $image->{job_args} = $args; 503 509 504 # XXX: we can get rid of the following everything that we need is505 # in the params file506 507 $args .= " -file $imagefile";508 509 if (($option_mask & $PSTAMP_SELECT_MASK) && $image->{mask} ) {510 $args .= " -mask $image->{mask}";511 }512 if (($option_mask & $PSTAMP_SELECT_WEIGHT) and $image->{weight} ) {513 $args .= " -variance $image->{weight}";514 }515 516 510 my $base = basename($image->{image}); 517 511 if (! $base =~ /.fits$/ ) { … … 520 514 $base =~ s/.fits$//; 521 515 522 my $output_base = "$out_dir/${rownum}_${job_num}_${base}"; 523 my $argslist = "${output_base}.args"; 524 525 # copy the argument list to a file 526 open ARGSLIST, ">$argslist" or my_die("failed to open $argslist", $PS_EXIT_UNKNOWN_ERROR); 527 print ARGSLIST "$args\n"; 528 close ARGSLIST or my_die("failed to close $argslist", $PS_EXIT_UNKNOWN_ERROR); 529 516 my $output_base = "$outdir/${rownum}_${job_num}_${base}"; 530 517 write_params($output_base, $image); 531 518 … … 536 523 # XXX: this code is repeated in queueGetImageJobs we should encapsulate it in a subroutine and share it 537 524 if ($stage ne 'raw') { 538 # not ready to handle diff update yet. May never support stack539 my $allow_wait_for_update = ( ($stage ne 'stack') and ($stage ne 'diff'));525 # updates for stack stage not supported yet 526 my $allow_wait_for_update = ($stage ne 'stack'); 540 527 my $run_state = $image->{state}; 541 528 my $data_state = $image->{data_state}; … … 548 535 $newState = 'stop'; 549 536 $fault = $PSTAMP_GONE; 550 } elsif ($allow_wait_for_update and 551 (($data_state ne 'full') or ($need_magic and ($image->{magicked} < 0)))) { 537 } elsif (($data_state ne 'full') or ($need_magic and ($image->{magicked} < 0))) { 552 538 if ($stage eq 'chip') { 553 539 my $burntool_state = $image->{burntool_state}; … … 556 542 $fault = $PSTAMP_NOT_AVAILABLE; 557 543 } 544 } 545 if (!$allow_wait_for_update) { 546 print STDERR "wait for update not supported for stage $stage yet\n"; 547 $newState = 'stop'; 548 $fault = $PSTAMP_NOT_AVAILABLE; 558 549 } 559 550 if (!$fault) { … … 658 649 } 659 650 660 # $num_jobs = queueGetImageJobs($firstRow, $imageList, $stage, $need_magic, $mode);661 651 sub queueGetImageJobs 662 652 { … … 706 696 my $exp_id = $image->{exp_id}; 707 697 708 my $output_base = "$out _dir/${rownum}_${job_num}";698 my $output_base = "$outdir/${rownum}_${job_num}"; 709 699 710 700 write_params($output_base, $image); … … 731 721 # cause the image to be re-made 732 722 # set up to queue an update run 733 queue_update_run(\$newState, \$fault, \$dep_id, $image->{image _db},723 queue_update_run(\$newState, \$fault, \$dep_id, $image->{imagedb}, 734 724 $run_state, $stage, $image->{stage_id}, $image->{component}, $need_magic); 735 725 } … … 878 868 my ($r_jobState, $r_fault, $r_dep_id, $imagedb, $state, $stage, $stage_id, $component, $need_magic) = @_; 879 869 870 # XXX: The update process for warp and subsequent stages requires 871 # destreaking to run because the -pending queries require it when magicked > 0 872 # queries. 873 # The case of stack-stack diffs is taken care of in pstamp_checkdependent 874 $need_magic = 1 if $imagedb eq 'gpc1'; 875 880 876 if (($state ne 'cleaned') and ($state ne 'update') and ($state ne 'goto_cleaned')) { 881 877 my_die("$stage $stage_id is in unexpected state $state", $PS_EXIT_PROG_ERROR); … … 883 879 884 880 my $dep_id; 885 my $command = "$pstamptool -getdependent -stage $stage -stage_id $stage_id -imagedb $imagedb -component $component ";881 my $command = "$pstamptool -getdependent -stage $stage -stage_id $stage_id -imagedb $imagedb -component $component -outdir $outdir"; 886 882 $command .= " -need_magic" if $need_magic; 887 883
Note:
See TracChangeset
for help on using the changeset viewer.
