- Timestamp:
- Aug 30, 2013, 4:48:58 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130711/pstamp/scripts
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
pstampparse.pl (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130711/pstamp/scripts
- Property svn:mergeinfo changed
/trunk/pstamp/scripts (added) merged: 35827-35828,35892,35900-35903,35911,35932,35937,36010-36011,36017-36018,36048,36059,36061
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20130711/pstamp/scripts/pstampparse.pl
r35504 r36071 51 51 52 52 die "invalid mode '$mode'" unless ($mode eq "list_uri") or ($mode eq "queue_job"); 53 die "--file is required" if !defined($request_file_name);53 die "--file is required" unless defined($request_file_name); 54 54 55 55 if ($mode ne "list_uri") { 56 die "req_id is required" if !$req_id;56 die "req_id is required" if !$req_id; 57 57 die "outdir is required" if !$outdir; 58 die "product is required" if !$product;58 die "product is required" if !$product; 59 59 } else { 60 $req_id = 0; 61 $outdir = "nowhere"; 60 # mode eq 'list_uri' (used for parser testing) 61 # these values won't be used for anything but should be defined to avoid errors 62 $req_id = 0; 63 $outdir = "nowhere"; 62 64 $product = "dummy"; 63 65 } … … 76 78 my $pstamptool = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools = 1); 77 79 my $pstampdump = can_run('pstampdump') or (warn "Can't find pstampdump" and $missing_tools = 1); 78 my $fields = can_run('fields') or (warn "Can't find fields" and $missing_tools = 1);80 my $fields = can_run('fields') or (warn "Can't find fields" and $missing_tools = 1); 79 81 80 82 if ($missing_tools) { … … 116 118 if ($extver >= 2) { 117 119 # We have a version 2 file. Require that the new keywords be supplied. 118 my_die("action not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) unless defined $action; 119 120 my_die("invalid action: $action supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) unless (uc($action) eq 'PROCESS' or uc($action) eq 'PREVIEW'); 121 122 my_die("email not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) unless $email; 120 my_die("action not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) 121 unless defined $action; 122 123 my_die("invalid action: $action supplied in version $extver request file $request_file_name\n", 124 $PSTAMP_INVALID_REQUEST) 125 unless (uc($action) eq 'PROCESS' or uc($action) eq 'PREVIEW'); 126 127 my_die("email not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) 128 unless $email; 129 123 130 # XXX check for "valid" $email 124 131 } else { 125 132 # for version 1 file the action is process and email is not used 126 133 $action = 'PROCESS'; 127 $email = 'null';134 $email = 'null'; 128 135 } 129 136 … … 175 182 176 183 177 if ($req_id and !$no_update){184 { 178 185 # update the database with the request name. This will be used as the 179 # the output data store's product name186 # the fileset name in the output data store 180 187 my $command = "$pstamptool -updatereq -req_id $req_id -set_name $req_name"; 181 188 $command .= " -set_username $email" if $email ne 'null'; 182 189 $command .= " -set_outProduct $product"; 183 190 $command .= " -set_label $label" if $label_changed; 184 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 185 run(command => $command, verbose => $verbose); 186 unless ($success) { 187 my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR); 188 } 189 } 191 unless ($no_update) { 192 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 193 run(command => $command, verbose => $verbose); 194 unless ($success) { 195 my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR); 196 } 197 } else { 198 print "skipping $command\n"; 199 } 200 } 201 190 202 if ($duplicate_req_name) { 191 203 exit 0; … … 212 224 } 213 225 214 my $nRows = scalar @$rows;226 my $nRows = $rows ? scalar @$rows : 0; 215 227 print "\n$nRows rows read from request file\n"; 228 229 unless ($nRows) { 230 # pstamp_job_run was invoked so the request file must have contained a valid header 231 # a request file with no rows is invalid. 232 # The print above will let the log file know a bit more. 233 # Insert a faulted fake job and exit this program successfully. 234 print STDERR "Invalid request file.\n"; 235 insertFakeJobForRow(undef, 0, $PSTAMP_INVALID_REQUEST); 236 exit 0; 237 } 238 216 239 217 240 … … 219 242 my $imageList; 220 243 my $stage; 244 my $big_limit = 100; # XXX: this should be in a configuration file some where 221 245 foreach my $row (@$rows) { 222 246 223 if ($label eq 'WEB.UP' and ($nRows > 500 or $num_jobs > 500) and $req_id and !$no_update) { 224 # this is a big request and it came from the upload page and doesn't have a specific label assigned 225 # change it to the generic one that has lower with lower priority 226 $label = 'WEB.BIG'; 227 print "\nChanging label for big WEB.UP request to $label\n"; 247 248 if (!($label =~ /BIG/) and ($label =~ /PSI/ or $label =~ /WEB/) and ($nRows > $big_limit or $num_jobs > $big_limit) 249 and $req_id and !$no_update) { 250 251 # This is a "big" request and it came from one of the "high priority" channels 252 # and doesn't have a specific label assigned. 253 # Change the label to a value that its jobs run with lower priority. 254 255 my $old_label = $label; 256 $label = ($label =~ /WEB/) ? 'WEB.BIG' : 'PSI.BIG'; 257 print "\nChanging label for big $old_label request to $label\n"; 228 258 229 259 my $command = "$pstamptool -updatereq -req_id $req_id -set_label $label"; … … 249 279 250 280 if (($action eq 'LIST' or $mode eq "queue_job") and ($num_jobs eq 0)) { 251 print STDERR "no jobs created for $req_name\n" if $verbose; 252 insertFakeJobForRow(undef, 0, $PSTAMP_INVALID_REQUEST); 281 # this should not happen. The function above is required to insert a fake job for any 282 # rows that did not yield any jobs. 283 print STDERR "ERROR: zero jobs created for $req_name\n"; 284 insertFakeJobForRow(undef, 0, $PS_EXIT_PROG_ERROR); 253 285 } 254 286 … … 286 318 } 287 319 if ($job_type eq 'get_image') { 288 unless ($req_type eq 'byid' or $req_type eq 'byexp' or ($req_type eq 'byskycell' and $stage eq 'stack')) { 289 print STDERR "REQ_TYPE must be 'byid' or 'byexp' or byskcyell for stacks for JOB_TYPE 'get_image'\n"; 320 # get_image jobs are quite expensive in terms of space so we are currently restricting them 321 unless ($req_type eq 'byid' or $req_type eq 'byexp' 322 or ($req_type eq 'byskycell' and $stage eq 'stack') 323 or ($stage eq 'stack_summary')) { 324 print STDERR "REQ_TYPE must be 'byid' or 'byexp' JOB_TYPE 'get_image' for IMG_TYPE $stage\n"; 290 325 insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST); 291 326 return 0; … … 295 330 my $component = $row->{COMPONENT}; 296 331 if (!defined $component or (lc($component) eq "null") or (lc($component) eq "all")) { 297 if ($job_type eq 'get_image' ) {332 if ($job_type eq 'get_image' and ! ($stage eq 'stack' or $stage eq 'stack_summary')) { 298 333 $row->{COMPONENT} = 'all'; 299 334 } else { … … 384 419 } 385 420 386 if (($req_type eq "byexp") and ($stage eq "stack" )) {387 print STDERR "byexp not implemented for stackstage. row: $rownum\n";421 if (($req_type eq "byexp") and ($stage eq "stack" or $stage eq 'stack_summary')) { 422 print STDERR "byexp not implemented for $stage stage. row: $rownum\n"; 388 423 insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED); 389 424 return 0; … … 457 492 my $start_locate = gettimeofday(); 458 493 459 print "\nCalling new_locate_imagesfor row: $rownum\n";494 print "\nCalling locate_images_for_row for row: $rownum\n"; 460 495 461 496 $imageList = locate_images_for_row($ipprc, $image_db, $camera, $row, $verbose); … … 521 556 my $image_db = $proj_hash->{dbname}; 522 557 my $camera = $proj_hash->{camera}; 523 my $need_magic = $proj_hash->{need_magic};558 my $need_magic = $proj_hash->{need_magic}; 524 559 # Since user can get unmagicked data "by coordinate" requests can go back in time 525 560 # to dredge unusable data from the "dark days"... … … 532 567 $need_magic = 0 if $stage eq 'stack'; 533 568 534 if ($need_magic) { 535 536 # this project requires that postage stamps be extracted from destreaked images 537 538 if ($option_mask & ($PSTAMP_REQUEST_UNCENSORED | $PSTAMP_REQUIRE_UNCENSORED)) { 539 # The user has requested uncensored stamps 540 541 if (!$dest_requires_magic) { 542 # and this user's data store destination is allowed uncensored stamps, so accept the request 543 $need_magic = 0; 544 } else { 545 print STDERR "Error row $rownum: User not authorized to to request uncensored stamps.\n"; 546 if ($option_mask & $PSTAMP_REQUIRE_UNCENSORED) { 547 # user required uncensored stamps. Can't do it so fail. 548 foreach my $r (@$rowList) { 549 insertFakeJobForRow($r, 1, $PSTAMP_NOT_AUTHORIZED); 550 $num_jobs++; 551 } 552 return $num_jobs; 553 } 554 555 # user will accept censored stamps. alter OPTION_MASK and continue 556 557 print STDERR " Will attempt to make destreaked stamps\n"; 558 # zap the offending bit in the option mask 559 $option_mask = $option_mask ^ ($PSTAMP_REQUEST_UNCENSORED); 560 foreach my $r (@$rowList) { 561 $r->{OPTION_MASK} = $option_mask; 562 } 563 } 564 } 565 } 566 569 # XXX: magic is dead 570 $need_magic = 0; 571 567 572 my $numRows = scalar @$rowList; 568 573 … … 701 706 } 702 707 $base =~ s/.fits$//; 708 709 my $filter = $image->{filter}; 710 if (!$filter) { 711 if ($stage eq 'diff') { 712 $filter = $image->{filter_1}; 713 } 714 if (!$filter) { 715 # XXX: perhaps this should be a programming error... 716 print STDERR "missing filter using 'X'\n"; 717 $filter = 'X'; 718 } 719 } 720 # use first character of filter 721 $filter = substr($filter, 0, 1); 703 722 704 my $output_base = "$outdir/${rownum}_${job_num}_${ base}";723 my $output_base = "$outdir/${rownum}_${job_num}_${filter}_${base}"; 705 724 write_params($output_base, $image); 706 725 … … 719 738 if (!$no_update) { 720 739 # mode eq "queue_job" 740 my $start_addjob = gettimeofday(); 721 741 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 722 742 run(command => $command, verbose => $verbose); … … 728 748 my_die("failed to queue job for request $req_id", $PS_EXIT_UNKNOWN_ERROR); 729 749 } 750 my $dtime_addjob = gettimeofday() - $start_addjob; 751 print "Time to addjob for row $rownum $dtime_addjob\n"; 730 752 } else { 731 753 print "skipping command: $command\n"; … … 1160 1182 } 1161 1183 if (($img_type eq "raw") or ($img_type eq "chip") or ($img_type eq "warp") or 1162 ($img_type eq "stack") or ($img_type eq "diff")) {1184 ($img_type eq "stack") or ($img_type eq 'stack_summary') or ($img_type eq "diff")) { 1163 1185 return 1; 1164 1186 } else {
Note:
See TracChangeset
for help on using the changeset viewer.
