Changeset 28017 for branches/czw_branch/20100427/pstamp
- Timestamp:
- May 18, 2010, 5:06:01 PM (16 years ago)
- Location:
- branches/czw_branch/20100427
- Files:
-
- 16 edited
- 2 copied
-
. (modified) (1 prop)
-
pstamp/doc/dsinstall.txt (copied) (copied from trunk/pstamp/doc/dsinstall.txt )
-
pstamp/scripts/Makefile.am (modified) (2 diffs)
-
pstamp/scripts/detectability_respond.pl (modified) (20 diffs)
-
pstamp/scripts/dquery_finish.pl (modified) (7 diffs)
-
pstamp/scripts/dqueryparse.pl (modified) (8 diffs)
-
pstamp/scripts/pstamp_checkdependent.pl (modified) (24 diffs)
-
pstamp/scripts/pstamp_cleanup.pl (copied) (copied from trunk/pstamp/scripts/pstamp_cleanup.pl )
-
pstamp/scripts/pstamp_dorequest.pl (modified) (1 diff)
-
pstamp/scripts/pstamp_finish.pl (modified) (19 diffs)
-
pstamp/scripts/pstamp_get_image_job.pl (modified) (3 diffs)
-
pstamp/scripts/pstamp_job_run.pl (modified) (9 diffs)
-
pstamp/scripts/pstamp_parser_run.pl (modified) (12 diffs)
-
pstamp/scripts/pstampparse.pl (modified) (32 diffs)
-
pstamp/scripts/request_finish.pl (modified) (4 diffs)
-
pstamp/src/ppstampMakeStamp.c (modified) (3 diffs)
-
pstamp/src/ppstampMosaic.c (modified) (1 diff)
-
pstamp/test/detect_query_create (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20100427
- Property svn:mergeinfo changed
-
branches/czw_branch/20100427/pstamp/scripts/Makefile.am
r27704 r28017 3 3 4 4 install_files = \ 5 pstamp_cleanup.pl \ 5 6 pstamp_finish.pl \ 6 7 pstamp_insert_request.pl \ … … 20 21 pstamp_checkdependent.pl \ 21 22 request_finish.pl \ 23 detectability_respond.pl \ 22 24 detect_query_read \ 23 25 detect_response_create \ -
branches/czw_branch/20100427/pstamp/scripts/detectability_respond.pl
r27643 r28017 41 41 my $EXTVER = 1.0; 42 42 my $EXTNAME = 'MOPS_DETECTABILITY_RESPONSE'; 43 my ($req_id,$req_name,$product,$need_magic,$missing_tools );44 my ($request_file,$output,$ dbname,$verbose,$save_temps);43 my ($req_id,$req_name,$product,$need_magic,$missing_tools,$project); 44 my ($request_file,$output,$workdir,$dbname,$dbserver,$verbose,$save_temps); 45 45 GetOptions( 46 'input=s' =>\$request_file,46 'input=s' => \$request_file, 47 47 'output=s' => \$output, 48 'workdir=s' => \$workdir, 48 49 'dbname=s' => \$dbname, 50 'dbserver=s' => \$dbserver, 49 51 'verbose' => \$verbose, 50 52 'save-temps' => \$save_temps, … … 55 57 -exitval => 3, 56 58 ) unless 57 defined $request_file and defined $output and defined $ dbname;59 defined $request_file and defined $output and defined $workdir and defined $dbname; 58 60 59 61 my $detect_query_read = can_run('detect_query_read') or (warn "Can't find detect_query_read" and $missing_tools = 1); … … 71 73 72 74 my $ipprc = PS::IPP::Config->new(); 73 #my $tmp_dir = "/data/${host}.0/tmp/"; 75 76 if (!$dbserver) { 77 $dbserver = metadataLookupStr($ipprc->{_siteConfig}, 'PS_DBSERVER'); 78 } 79 # This is hardcoded in for the moment. 80 $project = resolve_project($ipprc,"gpc1",$dbname,$dbserver); 81 my $imagedb = $project->{dbname}; 82 if (!$imagedb) { 83 carp("failed to find imagedb for project: $project"); 84 } 74 85 75 86 # 76 87 # Parse input request file using detect_query_read (as it's already written). 77 88 # 78 79 89 my $dqr_command = "$detect_query_read --input $request_file"; 80 90 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 81 91 run(command => $dqr_command, verbose => $verbose); 82 92 unless ($success) { 83 my_die("Unable to perform $dqr_command error code: $error_code",-1,-1,-1,-1,-1,-1); 93 # This is a problem, because I'm not sure how we handle a failure to read something. 94 # We need to return a $PSTAMP_INVALID_REQUEST, I think, but if we can't read it, 95 # we can't send that response back. 96 die("Unable to perform $dqr_command error code: $error_code"); 84 97 } 85 98 my %query = (); … … 119 132 my %image_list_hash; 120 133 for (my $i = 1; $i < $Nrows; $i++) { 121 # print "$i $Nrows $query{CONTENT}{RA1_DEG}[$i] $query{CONTENT}{DEC1_DEG}[$i]\n"; 122 134 # This could use the fact that locate_images now accepts position arrays, but 135 # I'll save that for after I get the majority of things working. 123 136 my $image_set_tmp = find_image_set($query{HEADER}{FPA_ID}[0],$query{HEADER}{STAGE}[0], 124 137 $query{HEADER}{MJD_OBS}[0],$query{HEADER}{FILTER}[0], … … 126 139 $query{CONTENT}{ROWNUM}[$i],$verbose); 127 140 unless (%$image_set_tmp) { 128 my_die("No images were returned.",$query{HEADER}{QUERY_ID}[0],$query{HEADER}{FPA_ID}[0], 129 $query{HEADER}{MJD_OBS}[0],$query{HEADER}{FILTER}[0],$query{HEADER}{OBSCODE}[0], 130 $query{HEADER}{STAGE}[0]); 131 } 132 print "=== $image_set_tmp->{IMAGE}\n $image_set_tmp->{PSF}\n $image_set_tmp->{MASK}\n $image_set_tmp->{WEIGHT}\n $image_set_tmp->{SKY_COORDINATES}\n $image_set_tmp->{ROWNUM}\n"; 133 # This appends, assuming that if we get an image, we also get the identical psf/mask/weight/etc. 141 # No images were returned, so create a dummy entry that 142 $image_list_hash{'no_image'}{IMAGE} = 'no_image'; 143 $image_list_hash{'no_image'}{PSF} = 'no_psf'; 144 $image_list_hash{'no_image'}{MASK} = 'no_mask'; 145 $image_list_hash{'no_image'}{WEIGHT} = 'no_weight'; 146 $image_list_hash{'no_image'}{CATALOG} = 'no_catalog'; 147 $image_list_hash{'no_image'}{CLASS_ID} = 'no_class'; 148 $image_list_hash{'no_image'}{ERROR} = $PSTAMP_NO_IMAGE_MATCH; 149 push @{ $image_list_hash{'no_image'}{SKY_COORDINATES} }, "$query{CONTENT}{RA1_DEG}[$i] $query{CONTENT}{DEC1_DEG}[$i]"; 150 push @{ $image_list_hash{'no_image'}{ROWNUM} }, $query{CONTENT}{ROWNUM}[$i]; 151 next; 152 } 153 # print "=== $image_set_tmp->{IMAGE}\n $image_set_tmp->{PSF}\n"; 154 # print " $image_set_tmp->{MASK}\n $image_set_tmp->{WEIGHT}\n"; 155 # print " $image_set_tmp->{SKY_COORDINATES}\n $image_set_tmp->{ROWNUM}\n"; 156 157 # This indexes the results for identical images into the same hash. 134 158 $image_list_hash{$image_set_tmp->{IMAGE}}{IMAGE} = $image_set_tmp->{IMAGE}; 135 159 $image_list_hash{$image_set_tmp->{IMAGE}}{PSF} = $image_set_tmp->{PSF}; … … 138 162 $image_list_hash{$image_set_tmp->{IMAGE}}{CATALOG} = $image_set_tmp->{CATALOG}; 139 163 $image_list_hash{$image_set_tmp->{IMAGE}}{CLASS_ID} = $image_set_tmp->{CLASS_ID}; 164 $image_list_hash{$image_set_tmp->{IMAGE}}{ERROR} = $image_set_tmp->{ERROR}; 140 165 push @{ $image_list_hash{$image_set_tmp->{IMAGE}}{SKY_COORDINATES} }, $image_set_tmp->{SKY_COORDINATES}; 141 166 push @{ $image_list_hash{$image_set_tmp->{IMAGE}}{ROWNUM} }, $image_set_tmp->{ROWNUM}; 142 167 } 168 143 169 my $i = 0; 144 145 170 foreach my $k (keys %image_list_hash) { 171 # If we errored out on finding an image, we need to not try to run psphot here. 172 if ($image_list_hash{$k}{ERROR} != 0) { 173 next; 174 } 146 175 # Write coordinates of the requested targets to a file. 147 my ($coordfile,$coordname) = tempfile(" /tmp/detect.coords.$i.XXXX",176 my ($coordfile,$coordname) = tempfile("${workdir}/detect.coords.$i.XXXX", 148 177 UNLINK => !$save_temps); 149 my ($targetfile,$targetname) = tempfile(" /tmp/detect.targets.$i.XXXX",178 my ($targetfile,$targetname) = tempfile("${workdir}/detect.targets.$i.XXXX", 150 179 UNLINK => !$save_temps); 151 180 … … 153 182 print $coordfile "$image_list_hash{$k}{SKY_COORDINATES}[$j]\n"; 154 183 } 155 184 # print "$k\n"; 156 185 # Convert the sky coordinates to image coordinates with ppCoord. 157 186 my $command = "ppCoord -astrom $image_list_hash{$k}{CATALOG} -radec $coordname"; … … 171 200 } 172 201 173 202 # print "psphot $image_list_hash{$k}{PSF}\n"; 174 203 # Run psphotForced on the target list. 175 my $tmpdir = tempdir("detect.$i.XXXX", DIR => " /tmp/", CLEANUP => !$save_temps);204 my $tmpdir = tempdir("detect.$i.XXXX", DIR => "${workdir}/", CLEANUP => !$save_temps); 176 205 $image_list_hash{$k}{OUTROOT} = "$tmpdir/detectability.$query{HEADER}{STAGE}[0].$query{HEADER}{FPA_ID}[0]"; 177 206 … … 185 214 run(command => $psphot_cmd, verbose => $verbose); 186 215 unless ($success) { 187 my_die("Unable to perform $psphot_cmd. Error_code: $error_code", 188 $query{HEADER}{QUERY_ID}[0],$query{HEADER}{FPA_ID}[0], 189 $query{HEADER}{MJD_OBS}[0],$query{HEADER}{FILTER}[0],$query{HEADER}{OBSCODE}[0], 190 $query{HEADER}{STAGE}[0],$error_code); 216 $image_list_hash{$k}{ERROR} = $PSTAMP_SYSTEM_ERROR; 191 217 } 192 218 } … … 196 222 # 197 223 my @rownums = (); 224 my @out_errors = (); 198 225 my @psphot_Npix = (); 199 226 my @psphot_Qfact= (); 200 227 my @psphot_flux = (); 228 201 229 foreach my $k (keys %image_list_hash) { 202 my $cmf = "$image_list_hash{$k}{OUTROOT}.$image_list_hash{$k}{CLASS_ID}.cmf"; 203 204 my ($tmp_Npix,$tmp_Qfact,$tmp_flux) = read_cmf_file($cmf,$image_list_hash{$k}{EXTENSION_BASE}); 205 206 push @rownums, @{ $image_list_hash{$k}{ROWNUM} }; 207 push @psphot_Npix, @{ $tmp_Npix }; 208 push @psphot_Qfact, @{ $tmp_Qfact }; 209 push @psphot_flux, @{ $tmp_flux }; 230 if ($image_list_hash{$k}{ERROR} == 0) { 231 my $cmf = "$image_list_hash{$k}{OUTROOT}.$image_list_hash{$k}{CLASS_ID}.cmf"; 232 233 my ($tmp_Npix,$tmp_Qfact,$tmp_flux) = read_cmf_file($cmf,$image_list_hash{$k}{EXTENSION_BASE}); 234 235 push @rownums, @{ $image_list_hash{$k}{ROWNUM} }; 236 push @out_errors, (map { $image_list_hash{$k}{ERROR} } @{ $image_list_hash{$k}{ROWNUM} }); 237 push @psphot_Npix, @{ $tmp_Npix }; 238 push @psphot_Qfact, @{ $tmp_Qfact }; 239 push @psphot_flux, @{ $tmp_flux }; 240 } 241 else { 242 push @rownums, @{ $image_list_hash{$k}{ROWNUM} }; 243 push @out_errors, (map { $image_list_hash{$k}{ERROR} } @{ $image_list_hash{$k}{ROWNUM} }); 244 push @psphot_Npix, (map { 0 } @{ $image_list_hash{$k}{ROWNUM} }); 245 push @psphot_Qfact, (map { 0.0 } @{ $image_list_hash{$k}{ROWNUM} }); 246 push @psphot_flux, (map { 0.0 } @{ $image_list_hash{$k}{ROWNUM} }); 247 } 210 248 } 211 249 … … 214 252 $query{HEADER}{MJD_OBS}[0],$query{HEADER}{filter}[0], 215 253 $query{HEADER}{obscode}[0], 216 \@rownums, \@ psphot_Npix, \@psphot_Qfact, \@psphot_flux);217 254 \@rownums, \@out_errors, \@psphot_Npix, \@psphot_Qfact, \@psphot_flux); 255 # print "Wrote response file $output\n"; 218 256 # 219 257 # Add to datastore 220 258 # 221 # my $finish_command = "dquery_finish.pl --req_id $req_id --req_name $req_name --product $product"; 222 # ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 223 # run(command => $finish_command, verbose => $verbose); 224 # unless ($success) { 225 # warn ("Unable to perform $finish_command error code: $error_code"); 226 # } 227 259 # Files are added to the datastore by dquery_finish.pl 228 260 # 229 261 # Cleanup 230 262 # 231 263 # Since everything is written to temporary files, there should be nothing to cleanup. 264 232 265 # 233 266 # Utilities … … 242 275 my $index = shift; 243 276 my $verbose = shift; 244 277 278 # This is the set of things that we need in order to run psphotForced 245 279 my $option_mask |= 1; 246 280 $option_mask |= $PSTAMP_SELECT_IMAGE; … … 252 286 my $mjd_max = $mjd + 1; 253 287 288 # Construct a row list. 289 my @rowList; 290 $rowList[0]->{CENTER_X} = $ra; 291 $rowList[0]->{CENTER_Y} = $dec; 292 $rowList[0]->{ID} = 1; 293 $rowList[0]->{STAGE} = $stage; 294 $rowList[0]->{COORD_MASK} = 0; 295 296 # print "$stage\n"; 254 297 # Call the PStamp code to find the images that contain the target on the given MJD in the specified filter. 255 my @images = locate_images($ipprc,$dbname,"bycoord",$stage, 256 undef,undef,undef,$option_mask,$need_magic, 257 $ra,$dec,$mjd_min,$mjd_max,$filter . ".00000",undef,$verbose); 298 my @images = locate_images($ipprc,$imagedb, 299 \@rowList, 300 "bycoord",$stage, 301 undef,undef,undef, 302 $option_mask,$need_magic, 303 # $ra,$dec, 304 $mjd_min,$mjd_max,$filter . ".00000",undef,$verbose); 258 305 259 306 my %image_info = (); … … 270 317 } 271 318 elsif ($stage eq 'stack') { 272 # Stacks hide the exposure name very well, so I'm 273 # choosing the stack_id as the FPA_ID to match. This 274 # probably needs to be approved somehow. 319 # Stacks hide the exposure name very well, so we can only match against stage_id 275 320 if (${ $j }{stage_id} ne $FPA_ID) { 276 321 next; … … 285 330 } 286 331 # Debug prints of all the components of this image 287 foreach my $k (keys %{ $j }) { 288 print "$i $j $k ${ $j }{$k}\n"; 289 } 290 332 # foreach my $k (keys %{ $j }) { 333 # if ($k eq 'row_index') { 334 # print "$i $j $k @{${ $j }{$k} }\n"; 335 # } 336 # print "$i $j $k ${ $j }{$k}\n"; 337 # } 338 339 # Check for existance of the images. Drawn mostly from pstampparse.pl 340 my $run_state = ${ $j }{state}; 341 my $data_state = ${ $j }{data_state}; 342 $data_state = $run_state if $stage eq 'stack'; 343 my $fault = 0; 344 if (($run_state eq 'goto_purged') or ($data_state eq 'purged') or 345 ($run_state eq 'drop') or 346 ($run_state eq 'error_cleaned') or 347 ($run_state eq 'goto_scrubbed') or ($data_state eq 'scrubbed')) { 348 # image is gone and it's not coming back 349 $fault = $PSTAMP_GONE; 350 } 351 elsif (($data_state ne 'full') or ($need_magic and (${ $j }{magicked} < 0))) { 352 if (($stage eq 'stack')||($stage eq 'diff')) { 353 # updating stacks and diffs isn't implemented 354 $fault = $PSTAMP_NOT_IMPLEMENTED; 355 } 356 if ($stage eq 'chip') { 357 my $burntool_state = ${ $j }{burntool_state}; 358 if ($burntool_state and (abs($burntool_state) < 14)) { 359 $fault = $PSTAMP_NOT_AVAILABLE; 360 } 361 } 362 363 if ($fault == 0) { 364 # This bombs us out to dqueryparse, which will then flag a job for this run to be updated. 365 my_die_for_update($data_state,$query{HEADER}{STAGE}[0], 366 ${ $j }{stage_id},${ $j }{class_id} || ${ $j }{skycell_id}, 367 $need_magic,$imagedb,$PSTAMP_NOT_AVAILABLE); 368 } 369 } 370 291 371 # This image matches, so we want to save the information into our output structure 292 372 $image_info{ROWNUM} = $index; … … 295 375 $image_info{MASK} = ${ $j }{mask}; 296 376 $image_info{WEIGHT} = ${ $j }{weight}; 377 $image_info{ERROR} = $fault; 297 378 $image_info{SKY_COORDINATES} = "$ra $dec"; 298 379 # To do sky->image coordinate transformations, we need to use the cmf/smf file. If … … 405 486 my $obscode = shift; 406 487 my $rownum_ref = shift; 488 my $out_err_ref = shift; 407 489 my $psphot_Npix_ref = shift; 408 490 my $psphot_Qfact_ref = shift; … … 413 495 my $columns = [ 414 496 # matching rownum from detectability original request 415 { name => 'ROWNUM', type => '20A', writetype => TSTRING }, 497 { name => 'ROWNUM', type => 'V', writetype => TULONG }, 498 # any errors that occurred during processing 499 { name => 'ERROR_CODE', type => 'V', writetype => TULONG }, 416 500 # number of pixels used in hypothetical PSF for the query detection 417 501 { name => 'DETECT_N', type => 'V', writetype => TULONG }, … … 455 539 for (my $i = 0; $i < $numRows; $i++) { 456 540 push @{$colData{'ROWNUM'}}, ${ $rownum_ref }[$i]; 541 push @{$colData{'ERROR_CODE'}}, ${ $out_err_ref }[$i]; 457 542 push @{$colData{'DETECT_N'}}, ${ $psphot_Npix_ref }[$i]; 458 543 push @{$colData{'DETECT_F'}}, ${ $psphot_Qfact_ref }[$i]; … … 529 614 530 615 } 616 617 sub my_die_for_update { 618 my $state = shift; 619 my $stage = shift; 620 my $stage_id = shift; 621 my $component = shift; 622 my $need_magic = shift; 623 my $imagedb = shift; 624 my $exit_code = shift; 625 626 print "$state $stage $stage_id $component $need_magic $imagedb\n"; 627 print STDERR "$state $stage $stage_id $component $need_magic $imagedb\n"; 628 exit($exit_code); 629 } -
branches/czw_branch/20100427/pstamp/scripts/dquery_finish.pl
r27578 r28017 20 20 use PS::IPP::Config qw( :standard ); 21 21 22 my ( $req_id, $req_name, $req_file, $product, $out _dir, $dbname, $dbserver, $verbose, $save_temps );22 my ( $req_id, $req_name, $req_file, $product, $outdir, $dbname, $dbserver, $verbose, $save_temps ); 23 23 24 24 GetOptions( … … 27 27 'req_file=s' => \$req_file, 28 28 'product=s' => \$product, 29 'out _dir=s' => \$out_dir,29 'outdir=s' => \$outdir, 30 30 'dbname=s' => \$dbname, 31 31 'dbserver=s' => \$dbserver, … … 41 41 $err .= "--req_name is required\n" if !$req_name; 42 42 $err .= "--product is required\n" if !$product; 43 $err .= "--out _dir is required\n" if !$out_dir;43 $err .= "--outdir is required\n" if !$outdir; 44 44 45 45 die "$err" if $err; … … 76 76 die "product directory does not exist $prod_dir"; 77 77 } 78 my $out _dir = "$prod_dir/$req_name";78 my $outdir = "$prod_dir/$req_name"; 79 79 } 80 if (! -e $out _dir ) {80 if (! -e $outdir ) { 81 81 # something must have gone wrong at the parse stage 82 print STDERR "output fileset directory $out _dir does not exist\n" if $verbose;83 if (! mkdir $out _dir ) {82 print STDERR "output fileset directory $outdir does not exist\n" if $verbose; 83 if (! mkdir $outdir ) { 84 84 stop_request($req_id, $PS_EXIT_SYS_ERROR, $verbose); 85 die "cannot create output directory $out _dir";85 die "cannot create output directory $outdir"; 86 86 } 87 } elsif (! -d $out _dir) {87 } elsif (! -d $outdir) { 88 88 stop_request($req_id, $PS_EXIT_SYS_ERROR, $verbose); 89 die "output fileset directory $out _dir exists but is not a directory";89 die "output fileset directory $outdir exists but is not a directory"; 90 90 } 91 91 … … 118 118 119 119 # XXX: have the jobs produce the reglist as with postage stamp requests 120 my ($REGLIST, $reg_list) = tempfile("$out_dir/reqlist.XXXX", UNLINK => !$save_temps); 120 my ($REGLIST, $reg_list) = tempfile("$outdir/reqlist.XXXX", UNLINK => !$save_temps); 121 121 122 foreach my $job (@jobs) { 122 123 my $job_id = $job->{job_id}; 123 124 my $response_file = "response${job_id}.fits"; 124 my $response_path = "$out _dir/$response_file";125 my $response_path = "$outdir/$response_file"; 125 126 126 127 if (-e $response_path) { 127 128 # the job generated a response file put it into the Data Store 128 129 print $REGLIST "$response_file|||table|\n"; 130 131 # do the same if we have an error file. Should the parse data be uploaded as well? 132 my $err_file = "parse_error.txt"; 133 if (-e "$outdir/$err_file") { 134 print $REGLIST "$err_file|||text|\n"; 135 } 129 136 } else { 130 137 print STDERR "detect_query response file for job $job_id not found\n" if $verbose; … … 136 143 if (-s $reg_list) { 137 144 my $command = "$dsreg --add $req_name --product $product --list $reg_list"; 138 $command .= " --copy --datapath $out _dir";145 $command .= " --copy --datapath $outdir"; 139 146 $command .= " --type MOPS_DETECTABILITY_RESPONSE"; 147 $command .= " --ps0 $req_id"; 140 148 $command .= " --dbname $dbname" if $dbname; 141 149 … … 158 166 my $verbose = shift; 159 167 160 my $command = "$pstamptool -updatereq -req_id $req_id -s tate stop";161 $command .= " - fault $fault" if $fault;168 my $command = "$pstamptool -updatereq -req_id $req_id -set_state stop"; 169 $command .= " -set_fault $fault" if $fault; 162 170 $command .= " -dbname $dbname" if $dbname; 163 171 $command .= " -dbserver $dbserver" if $dbserver; -
branches/czw_branch/20100427/pstamp/scripts/dqueryparse.pl
r27578 r28017 2 2 # 3 3 # parse a MOPS_DETCTABILITY_QUERY table and create a results file 4 #5 # Note: this file is currently only a placeholder which creates a fake response file6 # and adds a completed job to the database7 4 # 8 5 9 6 use strict; 10 7 use warnings; 11 8 use Carp; 12 9 use Getopt::Long qw( GetOptions ); 13 10 use Pod::Usage qw( pod2usage ); 14 11 use IPC::Cmd 0.36 qw( can_run run ); 15 12 13 use PS::IPP::PStamp::RequestFile qw( :standard ); 14 use PS::IPP::PStamp::Job qw( :standard ); 16 15 use PS::IPP::Config qw($PS_EXIT_SUCCESS 17 16 $PS_EXIT_UNKNOWN_ERROR … … 26 25 ); 27 26 28 my ($req_file, $req_id, $out_dir, $product, $mode, $dbname, $dbserver, $verbose, $save_temps); 29 27 my ($no_update, $imagedb, $label); 28 my ($req_file, $req_id, $outdir, $product, $mode, $dbname, $dbserver, $verbose, $save_temps); 29 my ($job_id,$rownum); # stuff from the post-update world 30 30 # 31 31 # parse args … … 35 35 'file=s' => \$req_file, 36 36 'req_id=s' => \$req_id, 37 'out_dir=s' => \$out_dir, 37 'job_id=s' => \$job_id, 38 'rownum=s' => \$rownum, 39 'outdir=s' => \$outdir, 40 'label=s' => \$label, 38 41 'product=s' => \$product, 39 42 'mode=s' => \$mode, … … 44 47 ) or pod2usage(2); 45 48 46 my $err = ""; 47 48 if (!$req_file) { 49 $err .= "--file is required\n"; 50 } 51 if (!$req_id) { 52 $err .= "--req_id is required\n"; 53 } 54 if (!$out_dir) { 55 $err .="--out_dir is required\n"; 56 } 57 if (!$product) { 58 $err .="--product is required\n"; 59 } 60 61 62 die $err if ($err); 63 49 die "invalid mode '$mode'" unless ($mode eq "list_uri") or ($mode eq "queue_job"); 50 die "--file or --job_id is required" if !$req_file; 51 52 if ($mode ne "list_uri") { 53 die "req_id is required" if !$req_id; 54 die "outdir is required" if !$outdir; 55 die "product is required" if !$product; 56 } 64 57 my $missing_tools; 65 58 my $pstamptool = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools =1); 66 my $fakedresponse = can_run('fakedresponse.pl') or (warn "Can't find fakedresponse.pl" and $missing_tools =1); 59 my $detectresponse = can_run('detectability_respond.pl') or 60 (warn "Can't find detectability_respond.pl" and $missing_tools = 1); 67 61 my $fields = can_run('fields') or (warn "Can't find fields" and $missing_tools =1); 68 62 … … 77 71 } 78 72 73 # just deal with these arguments once and for all 74 $pstamptool .= " -dbname $dbname" if $dbname; 75 $pstamptool .= " -dbserver $dbserver" if $dbserver; 76 $detectresponse .= " --dbname $dbname" if $dbname; 77 78 $no_update = 1 if $mode eq "list_job"; 79 80 # Unless we're running as a job, write the parse arguments in case we need to rerun this parsing. 81 if (!$job_id) { 82 my $argslist = "$outdir/parse.args"; 83 open ARGSLIST, ">$argslist" or my_die("failed to open argslist file $argslist", $job_id, $PS_EXIT_UNKNOWN_ERROR); 84 print ARGSLIST "--label $label --mode $mode --req_id $req_id --product $product --outdir $outdir --file $req_file\n"; 85 close ARGSLIST; 86 } 87 79 88 # get the query id and check the extname and version from the header 80 my $fields_output; 89 my $fields_output; 81 90 { 82 91 my $command = "echo $req_file | $fields -x 0 EXTNAME EXTVER QUERY_ID"; … … 84 93 run(command => $command, verbose => $verbose); 85 94 86 # fields doesn't return zero when it succeeds87 # unless ($success) {88 # print STDERR @$stderr_buf;89 # }90 95 $fields_output = join "", @$stdout_buf; 91 96 } 92 97 my (undef, $extname, $extver, $req_name) = split " ", $fields_output; 93 98 94 die "$req_file is missing one of EXTNAME EXTVER or QUERY_ID" 99 my_die("$req_file is missing one of EXTNAME EXTVER or QUERY_ID", $PS_EXIT_PROG_ERROR) 95 100 if !(defined($extname) and defined($extver) and defined($req_name)); 96 97 die "$req_file has EXTNAME $extname not MOPS_DETECTABILITY_QUERY table" 98 if $extname ne "MOPS_DETECTABILITY_QUERY"; 99 die "$req_file is version $extver expecting 1" if $extver ne 1; 100 101 if (0) { 102 $out_dir .= "/$req_name"; 103 } 104 if (! -e $out_dir ) { 105 mkdir $out_dir or die "cannot create output directory $out_dir"; 106 } elsif (! -d $out_dir ) { 107 die "output fileset directory $out_dir exists but is not a directory"; 108 } 109 110 # 111 # XXX Eventually we will parse the file here, to look up the list of input images to be processed 112 # and queue a job for each image. 113 # The request file will be one of the arguments. Each job will look at all rows and create entries 114 # in the response file the coordinates that overlap the image. 115 # 116 # In the meantime we don't parse the file here, pass it to the program fakedresponse. 117 # It creates a response file with a line for each row in the request file 118 119 my $response_file = "$out_dir/response.fits"; 101 my_die("$req_file has EXTNAME $extname not MOPS_DETECTABILITY_QUERY table", $PS_EXIT_PROG_ERROR) 102 if $extname ne "MOPS_DETECTABILITY_QUERY"; 103 my_die("$req_file is version $extver expecting 1", $PS_EXIT_PROG_ERROR) 104 if $extver ne 1; 105 106 # Set up the workdir for this query. 107 if (! -e $outdir ) { 108 mkdir $outdir or my_die("cannot create output directory $outdir", $PS_EXIT_PROG_ERROR); 109 } elsif (! -d $outdir ) { 110 my_die ("output fileset directory $outdir exists but is not a directory", $PS_EXIT_PROG_ERROR); 111 } 112 113 114 # Pass along the request file to the response generator. 115 my $response_file = "$outdir/${req_name}.dresponse.${req_id}.fits"; 120 116 my $fault; 117 my $data_to_update = ''; 121 118 { 122 my $command = "$ fakedresponse --input $req_file --output $response_file --workdir $out_dir";119 my $command = "$detectresponse --input $req_file --output $response_file --workdir $outdir"; 123 120 $command .= " --save-temps" if $save_temps; 124 121 $command .= " --verbose" if $verbose; … … 127 124 run(command => $command, verbose => $verbose); 128 125 unless ($success) { 129 warn("Unable to perform $command error code: $error_code"); 130 } 126 warn("Warn! Unable to perform $command error code: $error_code"); 127 } 128 # Use the fault code to see if we can regenerate the missing data. 131 129 $fault = $error_code >> 8; 132 } 133 134 my $job_id; 130 if ($fault == $PSTAMP_NOT_AVAILABLE) { 131 $data_to_update = (split /\n/, (join "", @$stdout_buf))[-1]; 132 } 133 } 134 135 135 my $result; 136 { 137 my $command = "$pstamptool -addjob -req_id $req_id -outputBase $out_dir"; 138 $command .= " -job_type detect_query -state stop -fault $fault"; 136 # If we returned correctly with a valid response file, get a job ID 137 # for the completed work, and move the response to a standardized name. 138 if ($fault == 0) { 139 my $command = "$pstamptool -addjob -req_id $req_id -outputBase $outdir"; 140 $command .= " -job_type detect_query -state stop -fault 0"; 139 141 $command .= " -rownum 1"; 140 $command .= " -dbname $dbname" if $dbname; 141 $command .= " -dbserver $dbserver" if $dbserver; 142 143 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 144 run(command => $command, verbose => $verbose); 145 142 143 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 144 run(command => $command, verbose => $verbose); 146 145 if ($success) { 147 146 $job_id = join "", @$stdout_buf; 148 147 chomp $job_id; 149 148 if ($job_id && -e $response_file) { 150 rename $response_file, "$out _dir/response${job_id}.fits";149 rename $response_file, "$outdir/response${job_id}.fits"; 151 150 } 152 151 $result = 0; … … 156 155 } 157 156 } 158 159 157 else { 158 # Failed to run correctly, which means that we need to queue a job and flag data for updating. 159 # Get the dependency id for the data we're requesting be updated. 160 my $dep_id = queue_update_run($req_id,$job_id,$outdir,$label,$data_to_update); 161 162 # Link this request to a job and link that job to any dependency 163 my $command = "$pstamptool -addjob -req_id $req_id -outputBase $outdir"; 164 $command .= " -job_type detect_query -state run -fault 0"; 165 $command .= " -rownum 1"; 166 $command .= " -dep_id $dep_id" if $dep_id; 167 168 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 169 run(command => $command, verbose => $verbose); 170 171 if ($success) { 172 $job_id = join "", @$stdout_buf; 173 chomp $job_id; 174 if ($job_id && -e $response_file) { 175 # We shouldn't have a response file at this stage. 176 rename $response_file, "$outdir/response${job_id}.fits"; 177 } 178 $result = 0; 179 } else { 180 warn("Unable to perform $command error code: $error_code"); 181 $result = $error_code >> 8; 182 } 183 } 184 185 # This does not set the request state to stop. That will happen with the request_finish.pl script, 186 # which will notice that we've inserted the stopped job and decide we're finished. Easy enough. 160 187 { 161 my $command = "$pstamptool -updatereq -req_id $req_id -name $req_name -outProduct $product"; 162 $command .= " -fault $result" if $result; 163 $command .= " -dbname $dbname" if $dbname; 164 $command .= " -dbserver $dbserver" if $dbserver; 188 my $command = "$pstamptool -updatereq -req_id $req_id -set_name $req_name -set_outProduct $product"; 189 $command .= " -set_fault $result" if $result; 165 190 166 191 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 167 192 run(command => $command, verbose => $verbose); 168 193 unless ($success) { 169 die "$command failed";194 my_die("$command failed",$PS_EXIT_UNKNOWN_ERROR); 170 195 } 171 196 } 172 197 173 198 exit 0; 199 200 201 # If we have to queue an update run, do so and create a new dependent 202 sub queue_update_run { 203 my ($req_id, $job_id, $outdir, $label, $data_to_update) = @_; 204 205 my ($state, $stage, $stage_id, $component, $need_magic, $imagedb) = split /\s+/, $data_to_update; 206 207 if (($state ne 'cleaned') and ($state ne 'update') and ($state ne 'goto_cleaned')) { 208 # We should have received one of these states, so if not, signal that we have a problem. 209 my_die("$stage $stage_id is in unexpected state $state", $PS_EXIT_PROG_ERROR); 210 } 211 my $dep_id; 212 my $command = "$pstamptool -getdependent -stage $stage -stage_id $stage_id -imagedb $imagedb -component $component "; 213 $command .= " -outdir $outdir"; 214 $command .= " -need_magic" if $need_magic; 215 216 my $rlabel = "dq_ud_" . $label if $label; 217 $command .= " -rlabel $rlabel" if $rlabel; 218 219 if (!$no_update) { 220 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 221 run(command => $command, verbose => $verbose); 222 unless ($success) { 223 my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR); 224 } 225 my $output = join "", @$stdout_buf; 226 chomp $output; 227 $dep_id = $output; 228 229 my_die("pstamptool -getdependent returned invalid dep_id", $PS_EXIT_PROG_ERROR) if !$dep_id; 230 } 231 else { 232 print STDERR "skipping $command\n"; 233 $dep_id = 42; 234 } 235 236 return($dep_id); 237 } 238 239 240 241 sub my_die { 242 my $msg = shift; 243 my $fault = shift; 244 245 carp $msg; 246 247 # we don't fault the request here pstamp_parser_run.pl handles that if necessary 248 exit $fault; 249 } -
branches/czw_branch/20100427/pstamp/scripts/pstamp_checkdependent.pl
r27751 r28017 21 21 use Carp; 22 22 23 # XXX: put this in a module somewhere 24 my $IPP_DIFF_MODE_WARP_WARP = 1; 25 my $IPP_DIFF_MODE_WARP_STACK = 2; 26 my $IPP_DIFF_MODE_STACK_WARP = 3; 27 my $IPP_DIFF_MODE_STACK_STACK = 4; 23 28 24 29 my ($dep_id, $stage, $stage_id, $component, $imagedb, $rlabel, $need_magic); … … 30 35 'stage_id=i' => \$stage_id, 31 36 'component=s' => \$component, 32 'imagedb=s' => \$imagedb, # dbname for images 37 'imagedb=s' => \$imagedb, # dbname for images. 33 38 'rlabel=s' => \$rlabel, 34 39 'need_magic' => \$need_magic, … … 56 61 } 57 62 63 # Append imagedb to the ippTools 58 64 $chiptool .= " -dbname $imagedb"; 59 65 $warptool .= " -dbname $imagedb"; 60 66 $difftool .= " -dbname $imagedb"; 67 $stacktool .= " -dbname $imagedb"; 61 68 $magicdstool .= " -dbname $imagedb"; 62 63 69 64 70 my $ipprc = PS::IPP::Config->new(); … … 67 73 $dbserver = metadataLookupStr($ipprc->{_siteConfig}, 'PS_DBSERVER'); 68 74 } 69 70 75 71 76 … … 103 108 # Got "it" 104 109 110 my $magic_ok = 0; 111 if ($stage eq 'diff') { 112 if ($it->{diff_mode} == $IPP_DIFF_MODE_STACK_STACK) { 113 # stack stack diffs don't need magic, but since the warps need to have the chips destreaked 114 # in order to be processed se set need_magic in the database for all runs 115 # Now the diffs themselves don't need to be destreaked so 116 $magic_ok = 1; 117 } 118 } 105 119 my $status = 0; 106 120 if (($it->{state} eq 'full') or ($it->{state} eq 'update') and ($whole_run or ($it->{data_state} eq 'full')) 107 and (!$need_magic or $ it->{magicked} > 0)) {108 109 # This Dependency is satisfied. all done121 and (!$need_magic or $magic_ok or $it->{magicked} > 0)) { 122 123 # This Dependency is satisfied. All done! 110 124 my $command = "$pstamptool -updatedependent -set_state full -dep_id $dep_id"; 111 125 $command .= " -dbname $dbname" if $dbname; … … 123 137 } elsif (($it->{state} eq 'cleaned') or ($it->{state} eq 'update') and 124 138 ($whole_run or ($it->{data_state} eq 'cleaned'))) { 139 140 # Update has not been queued for this component yet. 125 141 126 142 # XXX: if $whole_run this is going to repeatedly call -setimfiletoupdate. This will be a no-op … … 140 156 } 141 157 } else { 158 # update for this component has been queued by hasn't completed yet or the state is an error state 159 # XXX: in this state we aren't checking the dependents anymore. If something goes wrong this 160 # will never complete. Consider calling the 'queue_update' functions again just to check. They are relatively cheap 161 162 142 163 print "${stage}Run $stage_id state is $it->{state} $component data_state is $it->{data_state}\n"; 143 164 … … 150 171 151 172 # temporary hack to deal with data with old burntool tables. This check is now done by pstampparse.pl 152 # so runs in this state willnot get queued173 # so runs in this state should not get queued 153 174 if ($stage eq 'chip') { 154 175 my $burntool_state = $it->{burntool_state}; … … 169 190 } 170 191 if (!$job_fault and ($stage eq 'chip')) { 171 $job_fault = queue_update_magicDSRun($stage, $stage_id, $rlabel, $it->{raw_magicked}, $it->{dsRun_state}); 192 # chip processing is done, start destreaking. 193 $job_fault = queue_update_magicDSRun($stage, $stage_id, $rlabel, $need_magic, $it->{raw_magicked}, $it->{dsRun_state}); 172 194 } 173 195 if ($job_fault) { … … 186 208 my $need_magic = shift; 187 209 210 188 211 my $dsRun_state; 189 212 my $raw_all_magicked = 1; # this gets cleared if any of the inputs aren't destreaked … … 193 216 $raw_all_magicked &= ($chip->{raw_magicked} > 0); 194 217 195 if ($chip->{data_state} ne 'update') { 218 if ($chip->{state} =~ /error/) { 219 faultJobs('stop', undef, undef, $PSTAMP_GONE); 220 } elsif (($chip->{data_state} ne 'update') and ($chip->{data_state} ne 'full')) { 196 221 my $command = "$chiptool -setimfiletoupdate -chip_id $chip_id -class_id $chip->{class_id}"; 197 222 $command .= " -set_label $rlabel" if $rlabel; … … 228 253 } 229 254 230 my $status = queue_update_magicDSRun('chip', $chip_id, $rlabel, $ raw_all_magicked, $dsRun_state);255 my $status = queue_update_magicDSRun('chip', $chip_id, $rlabel, $need_magic, $raw_all_magicked, $dsRun_state); 231 256 232 257 return $status; … … 247 272 248 273 my $warp_id = $metadata->{warp_id}; 274 my $state = $metadata->{state}; 275 if ($state =~ /error/) { 276 print STDERR "warpRun $warp_id has state $state faulting jobs\n"; 277 faultJobs('stop', undef, undef, $PSTAMP_GONE); 278 exit 0; 279 } 280 249 281 if (!$whole_run) { 250 282 my $skycell = $metadata; … … 256 288 if !$data or scalar @$data == 0; 257 289 258 my $ good_to_go= 1;290 my $chips_ready = 1; 259 291 my @chipsToUpdate; 260 292 my $chip_id; … … 262 294 $chip_id = $chip->{chip_id}; 263 295 if (($chip->{data_state} ne 'full') or ($need_magic and ($chip->{magicked} <= 0))) { 264 $ good_to_go= 0;296 $chips_ready = 0; 265 297 push @chipsToUpdate, $chip; 266 298 } else { … … 269 301 } 270 302 271 if ($good_to_go) { 303 if ($chips_ready) { 304 # the reason we defer setting the warp to update is so that we can handle error conditions at previous 305 # stages more easily. 272 306 my $command = "$warptool -setskyfiletoupdate -warp_id $warp_id -skycell_id $skycell->{skycell_id}"; 273 307 $command .= " -set_label $rlabel" if $rlabel; … … 333 367 my $need_magic = shift; 334 368 335 # XXXX This is not ready to go yet XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxx336 337 369 my $diff_id = $metadata->{diff_id}; 338 370 my $diff_mode = $metadata->{diff_mode}; … … 341 373 my $skycell_id = $skycell->{skycell_id}; 342 374 343 # put this in a module somewhere344 my $IPP_DIFF_MODE_WARP_WARP = 1;345 my $IPP_DIFF_MODE_WARP_STACK = 2;346 my $IPP_DIFF_MODE_STACK_WARP = 2;347 my $IPP_DIFF_MODE_STACK_STACK = 4;348 375 if ($diff_mode == $IPP_DIFF_MODE_WARP_STACK ) { 349 # check the state of the stack350 my $command = "$stacktool -sum kskyfile -stack_id $skycell->{stack2}";376 # check the state of the template stack 377 my $command = "$stacktool -sumskyfile -stack_id $skycell->{stack2}"; 351 378 my $stack = runToolAndParseExpectOne($command, $verbose); 352 379 my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack2}", $PS_EXIT_UNKNOWN_ERROR) if !$stack; … … 361 388 # now check the warp 362 389 $command = "$warptool -warped -warp_id $skycell->{warp1} -skycell_id $skycell_id"; 363 my $warp = runToolAndExpectOne($command, $verbose); 364 my_die("failed to find warpSkyfile for warpRun $skycell->{warp_id} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) 365 if !$warp; 366 } 367 368 my $good_to_go = 1; 369 my @chipsToUpdate; 370 my $chip_id; 371 my $warp_id; 372 my $data ; #XXXX 373 foreach my $chip (@$data) { 374 $chip_id = $chip->{chip_id}; 375 if (($chip->{data_state} ne 'full') or ($need_magic and ($chip->{magicked} <= 0))) { 376 $good_to_go = 0; 377 push @chipsToUpdate, $chip; 378 } else { 379 # this chip is good to go 380 } 381 } 382 383 if ($good_to_go) { 384 my $command = "$warptool -setskyfiletoupdate -warp_id $warp_id -skycell_id $skycell->{skycell_id}"; 385 $command .= " -set_label $rlabel" if $rlabel; 386 387 if (!$no_update) { 388 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 389 run(command => $command, verbose => $verbose); 390 unless ($success) { 391 my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR); 390 my $warp = runToolAndParseExpectOne($command, $verbose); 391 my_die("failed to find warpSkyfile for warpRun $skycell->{warp1} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp; 392 393 if ($warp->{data_state} ne 'full') { 394 return queue_update_warp($warp, 0, $rlabel, $need_magic); 395 } 396 # warps are ready fall through and queue the diff update 397 } elsif ($diff_mode eq $IPP_DIFF_MODE_WARP_WARP) { 398 my $command = "$warptool -warped -warp_id $skycell->{warp1} -skycell_id $skycell_id"; 399 my $warp1 = runToolAndParseExpectOne($command, $verbose); 400 my_die("failed to find warpSkyfile for warpRun $skycell->{warp1} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp1; 401 402 my $warps_ready = 1; 403 my $status = 0; 404 if ($warp1->{data_state} ne 'full') { 405 $warps_ready = 0; 406 $status = queue_update_warp($warp1, 0, $rlabel, $need_magic); 407 if ($status) { 408 return $status; 392 409 } 393 } else { 394 print "skipping $command\n"; 395 } 396 } elsif (scalar @chipsToUpdate > 0) { 397 return queue_update_chip($chip_id, 0, \@chipsToUpdate, $rlabel, $need_magic); 398 } 399 } else { 400 my $warpRun = $metadata; 401 my $warp_id = $warpRun->{warp_id}; 402 my $command = "$chiptool -listrun -chip_id $warpRun->{chip_id}"; 403 my $data = runToolAndParse($command, $verbose); 404 my_die("failed to find chipRun $warpRun->{chip_id} for warpRun $warp_id", $PS_EXIT_UNKNOWN_ERROR) 405 if !$data or scalar @$data != 1; 406 407 my $chipRun = $data->[0]; 408 409 my $chipRunState = $chipRun->{state}; 410 if (($chipRunState =~ /purge/) or ($chipRunState =~ /scrub/)) { 411 print STDERR "warpRun $warp_id depends on chipRun $chipRun->{chip_id} which is in state $chipRunState\n"; 412 faultJobs('stop', 'warp', $warp_id, $PSTAMP_GONE); 413 return 0; 414 } 415 my $warpRunState = $warpRun->{state}; 416 if (($chipRunState eq 'full') and (! $need_magic or ($chipRun->{magicked} > 0)) and ($warpRunState eq 'cleaned')) { 417 # The inputs and outputs are ready. Queue the warpRun for update. 418 419 # providing no -skycell_id arguments changes all skyfiles with data_state = 'cleaned' to 'update' 420 my $command = "$warptool -setskyfiletoupdate -warp_id $warp_id"; 421 $command .= " -set_label $rlabel" if $rlabel; 422 423 if (!$no_update) { 424 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 425 run(command => $command, verbose => $verbose); 426 unless ($success) { 427 my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR); 428 } 429 } else { 430 print "skipping $command\n"; 431 } 432 } elsif ($chipRunState eq 'cleaned' or 433 (($chipRun->{state} eq 'full') and ($need_magic and ($chipRun->{magicked} < 0) and ($chipRun->{dsRun_state} ne 'new')))) { 434 my $data = [$chipRun]; 435 return queue_update_chip($chipRun->{chip_id}, 1, $data, $rlabel, $need_magic); 436 } 437 } 438 439 # return value may be the return status of script so zero is good 410 } 411 $command = "$warptool -warped -warp_id $skycell->{warp2} -skycell_id $skycell_id"; 412 my $warp2 = runToolAndParseExpectOne($command, $verbose); 413 my_die("failed to find warpSkyfile for warpRun $skycell->{warp2} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp2; 414 415 if ($warp2->{data_state} ne 'full') { 416 $warps_ready = 0; 417 $status = queue_update_warp($warp2, 0, $rlabel, $need_magic); 418 } 419 420 if (!$warps_ready) { 421 # don't queue the diff update yet 422 return $status; 423 } 424 425 } elsif ($diff_mode == $IPP_DIFF_MODE_STACK_STACK ) { 426 # check the state of the input stack 427 my $command = "$stacktool -sumskyfile -stack_id $skycell->{stack2}"; 428 my $stack1 = runToolAndParseExpectOne($command, $verbose); 429 my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack2}", $PS_EXIT_UNKNOWN_ERROR) if !$stack1; 430 431 if ($stack1->{state} ne 'full') { 432 print STDERR "input stack for diffRun $diff_id $skycell_id is not in full state faulting jobs\n"; 433 # this faults all jobs depending on this dep_id 434 faultJobs('stop', 'diff', $diff_id, $PSTAMP_GONE); 435 return $PSTAMP_GONE; 436 } 437 # check the state of the template stack 438 $command = "$stacktool -sumskyfile -stack_id $skycell->{stack2}"; 439 my $stack2 = runToolAndParseExpectOne($command, $verbose); 440 my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack2}", $PS_EXIT_UNKNOWN_ERROR) if !$stack2; 441 442 if ($stack2->{state} ne 'full') { 443 print STDERR "template stack for diffRun $diff_id $skycell_id is not in full state faulting jobs\n"; 444 # this faults all jobs depending on this dep_id 445 faultJobs('stop', 'diff', $diff_id, $PSTAMP_GONE); 446 return $PSTAMP_GONE; 447 } 448 449 # inputs are ready fall through and queue the diff update 450 } elsif ($diff_mode == $IPP_DIFF_MODE_STACK_WARP ) { 451 # check the state of the input stack 452 my $command = "$stacktool -sumskyfile -stack_id $skycell->{stack1}"; 453 my $stack = runToolAndParseExpectOne($command, $verbose); 454 my_die("failed to find stackSumSkyfile for stack_id $skycell->{stack1}", $PS_EXIT_UNKNOWN_ERROR) if !$stack; 455 456 if ($stack->{state} ne 'full') { 457 print STDERR "input stack for diffRun $diff_id $skycell_id is not in full state faulting jobs\n"; 458 # this faults all jobs depending on this dep_id 459 faultJobs('stop', 'diff', $diff_id, $PSTAMP_GONE); 460 return $PSTAMP_GONE; 461 } 462 463 # now check the template warp 464 $command = "$warptool -warped -warp_id $skycell->{warp2} -skycell_id $skycell_id"; 465 my $warp = runToolAndParseExpectOne($command, $verbose); 466 my_die("failed to find warpSkyfile for warpRun $skycell->{warp2} skycell_id $skycell_id", $PS_EXIT_UNKNOWN_ERROR) if !$warp; 467 468 if ($warp->{data_state} ne 'full') { 469 return queue_update_warp($warp, 0, $rlabel, $need_magic); 470 } 471 # warps are ready fall through and queue the diff update 472 } else { 473 my_die("unexpected diff_mode found: $diff_mode", $PS_EXIT_PROG_ERROR); 474 } 475 476 my $command = "$difftool -setskyfiletoupdate -diff_id $diff_id -skycell_id $skycell_id"; 477 $command .= " -set_label $rlabel" if $rlabel; 478 479 if (!$no_update) { 480 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 481 run(command => $command, verbose => $verbose); 482 unless ($success) { 483 my_die("failed to queue ${stage}Run $stage_id $component for update", $PS_EXIT_UNKNOWN_ERROR); 484 } 485 } else { 486 print "skipping $command\n"; 487 } 488 } else { 489 # XXX todo whole_run 490 return $PS_EXIT_PROG_ERROR; 491 } 492 493 # return value is a unix style exit status so zero is good 440 494 return 0; 441 495 } … … 530 584 my ($state, $stage, $stage_id, $job_fault) = @_; 531 585 532 my $command = "$pstamptool -updatejob -s tate stop -fault $job_fault -dep_id $dep_id";586 my $command = "$pstamptool -updatejob -set_state stop -set_fault $job_fault -dep_id $dep_id"; 533 587 $command .= " -dbname $dbname" if $dbname; 534 588 $command .= " -dbserver $dbserver" if $dbserver; … … 549 603 my $stage_id = shift; 550 604 my $rlabel = shift; 605 my $need_magic = shift; 551 606 my $input_magicked = shift; 552 607 my $dsRun_state = shift; 553 608 554 # XXX: this code is only fully coded and tested forchip stage609 # XXX: this code assumes that destreaking is handled at the chip stage 555 610 my_die ("queue_update_magicDSRun only works for stage chip", $PS_EXIT_PROG_ERROR) if $stage ne 'chip'; 556 611 … … 578 633 print "skipping $command\n"; 579 634 } 635 } elsif ($dsRun_state eq 'failed_revert') { 636 print "magicDSRun.state = $dsRun_state for chipRun $stage_id is in state failed_revert cannot update"; 637 faultJobs('stop', undef, undef, $PSTAMP_NOT_AVAILABLE); 580 638 } else { 581 639 print "magicDSRun.state = $dsRun_state for chipRun $stage_id"; … … 593 651 carp $msg; 594 652 595 my $command = "$pstamptool -updatedepe dent -fault $fault -dep_id $dep_id";653 my $command = "$pstamptool -updatedependent -set_fault $fault -dep_id $dep_id"; 596 654 $command .= " -dbname $dbname" if $dbname; 597 655 $command .= " -dbserver $dbserver" if $dbserver; … … 600 658 run(command => $command, verbose => $verbose); 601 659 unless ($success) { 602 my_die("failed to set pstampDependent.fault for dep_id: $dep_id", 603 $PS_EXIT_UNKNOWN_ERROR); 660 carp "$cmd failed"; 604 661 } 605 662 } else { -
branches/czw_branch/20100427/pstamp/scripts/pstamp_dorequest.pl
r19221 r28017 106 106 { 107 107 ## TODO: what about request status 108 my $command = "$pstamptool -updatereq -req_id $request_id -s tate stop";108 my $command = "$pstamptool -updatereq -req_id $request_id -set_state stop"; 109 109 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 110 110 run(command => $command, verbose => $verbosity); -
branches/czw_branch/20100427/pstamp/scripts/pstamp_finish.pl
r27751 r28017 25 25 use PS::IPP::PStamp::Job qw( :standard ); 26 26 27 my ( $req_id, $req_name, $req_file, $out_dir, $product, $dbname, $dbserver, $verbose, $save_temps, $redirect_output); 27 my %imagedb_cache; 28 29 my ( $req_id, $req_name, $req_file, $outdir, $product, $dbname, $dbserver, $verbose, $save_temps, $redirect_output); 28 30 29 31 # the char to the right of the bar may be used as a single - alias for the longer name … … 34 36 'req_file=s' => \$req_file, 35 37 'product=s' => \$product, 36 'out _dir=s' => \$out_dir,38 'outdir=s' => \$outdir, 37 39 'dbname=s' => \$dbname, 38 40 'dbserver=s' => \$dbserver, … … 44 46 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 45 47 46 die "usage: --req_id id --req_name name --req_file file --product product --out_dir output_directory [--dbname dbname --verbose]\n" 47 if !$req_id or !$req_name or !$req_file or !$product or !$out_dir; 48 die "usage: --req_id id --req_name name --req_file file --product product --outdir output_directory [--dbname dbname --verbose]\n" 49 if !$req_id or !$req_name or !$req_file or !$product or !$outdir; 50 51 die "outdir is NULL\n" if $outdir eq "NULL"; 48 52 49 53 my $ipprc = PS::IPP::Config->new(); # IPP Configuration 50 54 if ($redirect_output) { 51 my $logDest = "$out_dir/psfinish.$req_id.log"; 55 # XXX: what happens here if the directory does not exist? We check below 56 my $logDest = "$outdir/psfinish.$req_id.log"; 52 57 $ipprc->redirect_output($logDest); 53 58 } … … 70 75 71 76 if ($product eq "NULL") { 77 # nothing more to do 72 78 stop_request_and_exit($req_id, $PS_EXIT_PROG_ERROR); 73 79 } 74 75 my $outputDataStoreRoot = metadataLookupStr($ipprc->{_siteConfig}, 'DATA_STORE_ROOT');76 exit ($PS_EXIT_CONFIG_ERROR) unless defined $outputDataStoreRoot; # lookup failure outputs a message77 80 78 81 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 82 85 my $fileset = $req_name; 83 86 84 print STDERR "product: $product REQ_NAME: $req_name $out _dir\n" if $verbose;85 86 if (!-e $out _dir) {87 print STDERR "product: $product REQ_NAME: $req_name $outdir\n" if $verbose; 88 89 if (!-e $outdir) { 87 90 # something must have gone wrong parsing the request 88 print STDERR "output directory $out _dir does not exist\n";89 90 if (!mkdir $out _dir) {91 print STDERR "cannot create output directory $out _dir";91 print STDERR "output directory $outdir does not exist\n"; 92 93 if (!mkdir $outdir) { 94 print STDERR "cannot create output directory $outdir"; 92 95 stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR); 93 96 } 94 97 95 98 96 } elsif (! -d $out _dir ) {99 } elsif (! -d $outdir ) { 97 100 # XXX TODO: fault the request so we pstamp_finish doesn't keep trying to process the 98 101 # request 99 print STDERR "output directory $out _dir exists but is not a directory";102 print STDERR "output directory $outdir exists but is not a directory"; 100 103 stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR); 101 104 } … … 116 119 } 117 120 118 # at this point we need to find out what kind of request type it is and 119 # split the processing depending on the request type 120 # the only processing required for a detectabilty query is to build the output fileset. 121 122 # the following is for a postage stamp request 123 124 my ($rlf, $reglist_name) = tempfile ("$out_dir/reglist.XXXX", UNLINK => !$save_temps); 121 # start building the list of files to be placed in the output fileset 122 my ($rlf, $reglist_name) = tempfile ("$outdir/reglist.XXXX", UNLINK => !$save_temps); 123 124 # results file 125 125 print $rlf "results.fits|||table|\n"; 126 # human readable representation of the results file 126 127 print $rlf "results.mdc|||text|\n"; 127 128 128 129 my $err_file = "parse_error.txt"; 129 if (-e "$out _dir/$err_file" ) {130 if (-e "$outdir/$err_file" ) { 130 131 print $rlf "$err_file|||text|\n"; 131 132 } 132 133 133 my ($tdf, $table_def_name) = tempfile ("$out_dir/tabledef.XXXX", UNLINK => !$save_temps);134 134 # The results table definition file 135 my ($tdf, $table_def_name) = tempfile ("$outdir/tabledef.XXXX", UNLINK => !$save_temps); 135 136 136 137 # data for the header 137 138 print $tdf "$req_name|$req_id|\n"; 139 140 # get the list of jobs generated for this request 138 141 my @jobs; 139 142 { … … 151 154 print STDERR "Request $req_id produced no jobs.\n" 152 155 } 153 # This should not happen. A fake job should be queued156 # This should not happen. A fake job should have been entered 154 157 stop_request_and_exit($req_id, $PS_EXIT_PROG_ERROR); 155 158 } else { 159 if (0) { 156 160 my $metadata = $mdcParser->parse($output) or die("Unable to parse metdata config doc"); 157 161 158 162 my $jobs = parse_md_list($metadata); 163 } 164 my $jobs = parse_md_fast($mdcParser, $output); 159 165 160 166 @jobs = @$jobs; … … 163 169 164 170 my $exp_info; 165 my $last_exp_id = -1;166 171 foreach my $job (@jobs) { 167 172 my $job_id = $job->{job_id}; … … 171 176 my $exp_id = $job->{exp_id}; 172 177 173 174 178 if (($fault eq $PSTAMP_DUP_REQUEST) and ($req_name eq "NULL")) { 175 # this request had a duplicate request name. We can't put the results 176 # on the data store since the product name is already used 177 # maybe we could be more clever about this and choose a fileset name 178 stop_request_and_exit($req_id, $fault); 179 # this request had a duplicate request name yet the parser didn't give 180 # it an "ERROR style name. 181 stop_request_and_exit($req_id, $PS_EXIT_PROG_ERROR); 179 182 } 180 183 my ($row, $req_info, $project) = get_request_info($rows, $rownum); … … 198 201 # get the metadata for the exposure (if any i.e. stack) 199 202 # returns an appropriate string if !$exp_id 200 $exp_info = get_exposure_info($image_db, $exp_id); 201 $last_exp_id = $exp_id; 203 $exp_info = get_exposure_info($job_params, $image_db, $exp_id); 202 204 } else { 203 205 my $filter = $job_params->{filter}; 204 206 $filter = "0" if !$filter; 205 207 $exp_info = "0|0|0|$filter|0|0"; 206 $last_exp_id = -1;207 208 } 208 209 209 210 if (($job_type eq "stamp") || ($job_type eq "get_image") || ($job_type eq "none")) { 210 my $jreglist = "$out _dir/reglist$job_id";211 my $jreglist = "$outdir/reglist$job_id"; 211 212 if (open JRL, "<$jreglist") {; 212 213 # process the reglist file to get the list of files produced by this job … … 225 226 # If not found check the PHU. If that doesn't work just set them to zero. 226 227 # XXX do this more cleanly 227 my (undef, $ra_deg, $dec_deg) = split " ", `echo $out _dir/$img_name | fields -x 0 RA_DEG DEC_DEG`;228 my (undef, $ra_deg, $dec_deg) = split " ", `echo $outdir/$img_name | fields -x 0 RA_DEG DEC_DEG`; 228 229 if (!defined $ra_deg) { 229 (undef, $ra_deg, $dec_deg) = split " ", `echo $out _dir/$img_name | fields RA_DEG DEC_DEG`;230 (undef, $ra_deg, $dec_deg) = split " ", `echo $outdir/$img_name | fields RA_DEG DEC_DEG`; 230 231 } 231 232 $ra_deg = 0.0 if (!$ra_deg); … … 258 259 # make the results file 259 260 { 260 my $command = "$pstamp_results --input $table_def_name --output $out _dir/results.fits";261 my $command = "$pstamp_results --input $table_def_name --output $outdir/results.fits"; 261 262 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 262 263 run(command => $command, verbose => $verbose); … … 266 267 } else { 267 268 # dump a textual representation 268 my $command = "$pstampdump $out _dir/results.fits > $out_dir/results.mdc";269 my $command = "$pstampdump $outdir/results.fits > $outdir/results.mdc"; 269 270 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 270 271 run(command => $command, verbose => $verbose); … … 278 279 # register the fileset 279 280 my $command = "$dsreg --list $reglist_name --add $fileset --product $product --type PSRESULTS"; 280 $command .= " --link --datapath $out_dir --ps0 $req_id"; 281 $command .= " --dbname $dbname" if $dbname; 281 $command .= " --link --datapath $outdir --ps0 $req_id"; 282 # XXX: let dsreg and config handle resolving dbname and dbserver 283 # $command .= " --dbname $dbname" if $dbname; 282 284 283 285 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 292 294 # set the request's state to stop 293 295 { 294 my $command = "$pstamptool -updatereq -req_id $req_id -s tate stop -fault $request_fault";296 my $command = "$pstamptool -updatereq -req_id $req_id -set_state stop -set_fault $request_fault"; 295 297 $command .= " -dbname $dbname" if $dbname; 296 298 $command .= " -dbserver $dbserver" if $dbserver; … … 308 310 my $fault = shift; 309 311 310 my $command = "$pstamptool -updatereq -req_id $req_id -s tate stop -fault $fault";312 my $command = "$pstamptool -updatereq -req_id $req_id -set_state stop -set_fault $fault"; 311 313 $command .= " -dbname $dbname" if $dbname; 312 314 $command .= " -dbserver $dbserver" if $dbserver; … … 345 347 $data_group = "null" if !$data_group; 346 348 347 # This is ugly, error prone and hard to change.349 # XXX: This is ugly, error prone and hard to change. 348 350 # Create a results file module and provide a list of the names (we have the data in the columns) 349 351 my $rowinfo = "$row->{PROJECT}|$row->{JOB_TYPE}|$row->{REQ_TYPE}|$row->{IMG_TYPE}|"; … … 376 378 my $metadata = $mdcParser->parse($data) or die("Unable to parse metdata config doc"); 377 379 380 # no need to use parse_md_fast here 378 381 my $results = parse_md_list($metadata); 379 382 if (scalar @$results != 1) { … … 385 388 386 389 sub get_exposure_info { 390 my $job_params = shift; 387 391 my $image_db= shift; 388 392 my $exp_id = shift; 389 393 390 if (!$exp_id or !$image_db) { 391 # no exposure id just return zeros 392 # XXX: we could put a value in for filter, but we don't have a good place to find it 393 394 #"$mjd_obs|$ra_obs|$dec_obs|$filter|$exp_time|$fpa_id"; 395 return "0|0|0|0|0|0"; 396 } 397 398 my $regtool = can_run('regtool') or (warn "Can't find regtool" and $missing_tools = 1); 399 if ($missing_tools) { 400 warn("Can't find required tools."); 401 exit ($PS_EXIT_CONFIG_ERROR); 402 } 403 404 my $command = "$regtool -processedexp -dbname $image_db -exp_id $exp_id"; 405 406 # run the tool and parse the output 407 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 408 run(command => $command, verbose => $verbose); 409 unless ($success) { 410 # not sure if we should die here 411 die "cannot get exposure information for $exp_id from image database $image_db"; 412 } 413 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 414 415 my $output = join "", @$stdout_buf; 416 if (!$output) { 417 print STDERR "no output returned from $command\n" if $verbose; 418 return undef; 419 } 420 my $metadata = $mdcParser->parse($output) or die("Unable to parse metdata config doc"); 421 422 my $exposures = parse_md_list($metadata); 423 my $numExp = @$exposures; 424 425 die "unexpected number of exposures $numExp found for exp_id: $exp_id in DB: $image_db" if $numExp != 1; 394 my ($dateobs, $ra, $decl, $filter, $exp_time, $exp_name); 395 396 $dateobs = $job_params->{dateobs}; 397 $ra = $job_params->{ra}; 398 $decl = $job_params->{decl}; 399 $filter = $job_params->{filter}; 400 $exp_time = $job_params->{exp_time}; 401 $exp_name = $job_params->{exp_name}; 402 403 unless (defined $dateobs and defined $ra and defined $decl and defined $filter and defined $exp_time and defined $exp_name) { 404 # job params don't have all of the values that we need (most likely this is a diff stage job) 405 # go look up the exposure if we have one 406 if (!$exp_id or !$image_db) { 407 # no exposure id just return zeros 408 # XXX: we could put a value in for filter, but we don't have a good place to find it 409 410 #"$mjd_obs|$ra_obs|$dec_obs|$filter|$exp_time|$fpa_id"; 411 return "0|0|0|0|0|0"; 412 } 413 414 my $exp; 415 # get cache of exposures for this image_db 416 my $exp_cache = $imagedb_cache{$image_db}; 417 if (defined $exp_cache) { 418 $exp = $exp_cache->{$exp_id}; 419 } 420 421 unless (defined $exp) { 422 423 my $regtool = can_run('regtool') or (warn "Can't find regtool" and $missing_tools = 1); 424 if ($missing_tools) { 425 warn("Can't find required tools."); 426 exit ($PS_EXIT_CONFIG_ERROR); 427 } 428 429 my $command = "$regtool -processedexp -dbname $image_db -exp_id $exp_id"; 430 431 # run the tool and parse the output 432 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 433 run(command => $command, verbose => $verbose); 434 unless ($success) { 435 # not sure if we should die here 436 die "cannot get exposure information for $exp_id from image database $image_db"; 437 } 438 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 439 440 my $output = join "", @$stdout_buf; 441 if (!$output) { 442 print STDERR "no output returned from $command\n" if $verbose; 443 return undef; 444 } 445 if (0) { 446 my $metadata = $mdcParser->parse($output) or die("Unable to parse metdata config doc"); 447 448 my $exposures = parse_md_list($metadata); 449 } 450 my $exposures = parse_md_fast($mdcParser, $output); 451 my $numExp = @$exposures; 452 453 die "unexpected number of exposures $numExp found for exp_id: $exp_id in DB: $image_db" if $numExp != 1; 454 455 $exp = $exposures->[0]; 456 457 unless (defined $exp_cache) { 458 my %new_exp_cache; 459 $exp_cache = \%new_exp_cache; 460 $imagedb_cache{$image_db} = $exp_cache; 461 } 462 $exp_cache->{$exp_id} = $exp; 463 } else { 464 print "found $exp_id in cache\n"; 465 } 466 467 #my $info = "$mjd_obs|$ra_obs|$dec_obs|$filter|$exp_time|$fpa_id"; 468 $dateobs = $exp->{dateobs}; 469 $ra = $exp->{ra}; 470 $decl = $exp->{decl}; 471 $filter = $exp->{filter}; 472 $exp_time = $exp->{exp_time}; 473 $exp_name = $exp->{exp_name}; 474 } 475 476 die "failed to find exp_info for $exp_id" unless (defined $dateobs and defined $ra and defined $decl and defined $filter and defined $exp_time and defined $exp_name); 426 477 427 my $exp = $exposures->[0];428 429 #my $info = "$mjd_obs|$ra_obs|$dec_obs|$filter|$exp_time|$fpa_id";430 431 478 use constant RADIANS_TO_DEGREES => 90. / atan2(1, 0); 432 my $ra_deg = $ exp->{ra}* RADIANS_TO_DEGREES;433 my $decl_deg = $ exp->{decl}* RADIANS_TO_DEGREES;434 my $mjd_obs = dateobs_to_mjd($ exp->{dateobs});435 436 my $info = "$mjd_obs|$ra_deg|$decl_deg|$ exp->{filter}|$exp->{exp_time}|$exp->{exp_name}";479 my $ra_deg = $ra * RADIANS_TO_DEGREES; 480 my $decl_deg = $decl * RADIANS_TO_DEGREES; 481 my $mjd_obs = dateobs_to_mjd($dateobs); 482 483 my $info = "$mjd_obs|$ra_deg|$decl_deg|$filter|$exp_time|$exp_name"; 437 484 438 485 return $info; -
branches/czw_branch/20100427/pstamp/scripts/pstamp_get_image_job.pl
r26215 r28017 87 87 } 88 88 89 my $out _dir = dirname($output_base);89 my $outdir = dirname($output_base); 90 90 my $prefix = basename($output_base) . "_"; 91 91 my $results_file = $output_base . ".bundle_results"; … … 102 102 my $command = "$dist_bundle --camera $camera --stage $stage --stage_id $stage_id"; 103 103 $command .= " --component $component"; 104 $command .= " --path_base $path_base --outdir $out _dir --results_file $results_file";104 $command .= " --path_base $path_base --outdir $outdir --results_file $results_file"; 105 105 $command .= " --prefix $prefix"; 106 106 $command .= " --magicked" if $magicked; … … 139 139 } 140 140 141 my $reglist = "$out _dir/reglist$job_id";141 my $reglist = "$outdir/reglist$job_id"; 142 142 if (! open(REGLIST, ">$reglist") ) { 143 143 my_die("failed to open registration list: $reglist", $PS_EXIT_UNKNOWN_ERROR); -
branches/czw_branch/20100427/pstamp/scripts/pstamp_job_run.pl
r27751 r28017 74 74 my $ppstamp = can_run('ppstamp') or (warn "Can't find ppstamp" and $missing_tools = 1); 75 75 my $pstamp_get_image_job = can_run('pstamp_get_image_job.pl') or (warn "Can't find pstamp_get_image_job.pl" and $missing_tools = 1); 76 my $dqueryparse = can_run('dqueryparse.pl') or (warn "Can't find dqueryparse.pl" and $missing_tools = 1); 76 77 77 78 if ($missing_tools) { … … 83 84 my $jobStatus; 84 85 if ($jobType eq "stamp") { 85 my $argslist = "$outputBase.args"; 86 open ARGSLIST, "<$argslist" or my_die("failed to open argslist file $argslist", $job_id, $PS_EXIT_UNKNOWN_ERROR); 87 my $argString = <ARGSLIST>; 88 close ARGSLIST; 89 chomp $argString; 86 my $params = read_params_file($outputBase); 87 88 my $argString; 89 $argString = $params->{job_args}; 90 90 91 91 # XXX: should we do any other sanity checking? 92 my_die("arglist file $argslist is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString; 92 my_die("argument list is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString; 93 94 # XXX: remove -astrom from argString and add it here 95 96 $argString .= " -file $params->{image}"; 97 $argString .= " -mask $params->{mask}"; 98 if ($options & $PSTAMP_SELECT_VARIANCE) { 99 $argString .= " -variance $params->{weight}"; 100 } 93 101 94 102 my $command = "$ppstamp $outputBase $argString"; … … 119 127 my %extensions = ( $PSTAMP_SELECT_IMAGE => "fits", 120 128 $PSTAMP_SELECT_MASK => "mk.fits", 121 $PSTAMP_SELECT_ WEIGHT=> "wt.fits");122 123 my $output_mask = $options & ($PSTAMP_SELECT_IMAGE | $PSTAMP_SELECT_MASK | $PSTAMP_SELECT_ WEIGHT);129 $PSTAMP_SELECT_VARIANCE => "wt.fits"); 130 131 my $output_mask = $options & ($PSTAMP_SELECT_IMAGE | $PSTAMP_SELECT_MASK | $PSTAMP_SELECT_VARIANCE); 124 132 125 133 foreach my $key (keys (%extensions)) { … … 139 147 } 140 148 141 get_other_outputs($F, $outputBase, $options );149 get_other_outputs($F, $outputBase, $options, $params); 142 150 143 151 close $F; … … 165 173 } 166 174 } elsif ($jobType eq "detect_query") { 167 my_die("detect_query jobs not supported yet", $job_id,$PS_EXIT_CONFIG_ERROR); 175 # detect_query jobs are basically holders to note that we need a file updated before we can continue. 176 # Load the argument list that dqueryparse should have created the first time it ran, so we know how to 177 # run it again the same way. 178 my $argslist = "$outputBase/parse.args"; 179 open ARGSLIST, "<$argslist" or my_die("failed to open argslist file $argslist", $job_id, $PS_EXIT_UNKNOWN_ERROR); 180 my $argString = <ARGSLIST>; 181 close ARGSLIST; 182 chomp $argString; 183 184 # XXX: should we do any other sanity checking? 185 my_die("arglist file $argslist is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString; 186 187 my $command = "$dqueryparse --job_id $job_id $argString"; 188 $command .= " --dbname $dbname" if $dbname; 189 $command .= " --dbserver $dbserver" if $dbserver; 190 $command .= " --verbose" if $verbose; 191 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 192 run(command => $command, verbose => $verbose); 193 194 # Although dqueryparse can potentially force more updates (and more jobs), it should still return success. 195 if ($success) { 196 $jobStatus = $PS_EXIT_SUCCESS; 197 } else { 198 $jobStatus = $error_code >> 8; 199 my_die("dqueryparse.pl failed with error code: $jobStatus", $job_id, $jobStatus); 200 } 168 201 } else { 169 202 my_die("unknown jobType $jobType found", $job_id, $PS_EXIT_PROG_ERROR); … … 172 205 # mark the job stopped in the database 173 206 { 174 my $command = "$pstamptool -updatejob -job_id $job_id -s tate stop";175 $command .= " - fault $jobStatus" if $jobStatus;207 my $command = "$pstamptool -updatejob -job_id $job_id -set_state stop"; 208 $command .= " -set_fault $jobStatus" if $jobStatus; 176 209 $command .= " -dbname $dbname" if $dbname; 177 210 $command .= " -dbserver $dbserver" if $dbserver; … … 212 245 my $output_base = shift; 213 246 my $options = shift; 247 my $params = shift; 214 248 215 249 if ($options & ( $PSTAMP_SELECT_CMF | $PSTAMP_SELECT_PSF | $PSTAMP_SELECT_BACKMDL)) { 216 my $comp = read_params_file($output_base); 217 218 my $stage = $comp->{stage}; 250 if (!$params) { 251 $params = read_params_file($output_base); 252 } 253 254 my $stage = $params->{stage}; 219 255 220 256 # raw files don't have any other data products … … 225 261 # detected in pstampparse so that the user can be notified with 226 262 # a message in parse_error.txt ("warp do not have a background model") 227 my $cmf_file = $ comp->{cmf} if ($options & $PSTAMP_SELECT_CMF);228 my $psf_file = $ comp->{psf} if ($options & $PSTAMP_SELECT_PSF);229 my $backmdl_file = $ comp->{backmdl} if ($options & $PSTAMP_SELECT_BACKMDL);230 my $pattern_file = $ comp->{pattern} if ($options & $PSTAMP_SELECT_BACKMDL);263 my $cmf_file = $params->{cmf} if ($options & $PSTAMP_SELECT_CMF); 264 my $psf_file = $params->{psf} if ($options & $PSTAMP_SELECT_PSF); 265 my $backmdl_file = $params->{backmdl} if ($options & $PSTAMP_SELECT_BACKMDL); 266 my $pattern_file = $params->{pattern} if ($options & $PSTAMP_SELECT_BACKMDL); 231 267 232 268 my $outdir = dirname($output_base); … … 317 353 my $command = "$pstamptool -updatejob"; 318 354 $command .= " -job_id $job_id"; 319 $command .= " - fault $exit_code";355 $command .= " -set_fault $exit_code"; 320 356 # XXX: fix pstamptool to not require -state when -fault with nonzero value is provided 321 $command .= " -s tate run";357 $command .= " -set_state run"; 322 358 $command .= " -dbname $dbname" if defined $dbname; 323 359 $command .= " -dbserver $dbserver" if defined $dbserver; -
branches/czw_branch/20100427/pstamp/scripts/pstamp_parser_run.pl
r27751 r28017 28 28 my $redirect_output; 29 29 my $product; 30 my $outdir; 30 31 my $label; 31 32 my $verbose; … … 37 38 'uri=s' => \$uri, 38 39 'product=s' => \$product, 40 'outdir=s' => \$outdir, 39 41 'label=s' => \$label, 40 42 'redirect-output' => \$redirect_output, … … 81 83 } 82 84 83 # workdir is where all of the files generated for this request are placed 84 # NOTE: this location needs to be kept in sync with the web interface ( request.php ) 85 my $datestr = strftime "%Y%m%d", gmtime; 86 my $datedir = "$pstamp_workdir/$datestr"; 87 if (! -e $datedir ) { 88 mkdir $datedir or my_die( "failed to create working directory $datedir for request id $req_id", $req_id, 85 if (!$outdir or ($outdir eq "NULL")) { 86 # outdir is where all of the files generated for this request are placed 87 # NOTE: this location needs to be kept in sync with the web interface ( request.php ) 88 my $datestr = strftime "%Y%m%d", gmtime; 89 my $datedir = "$pstamp_workdir/$datestr"; 90 if (! -e $datedir ) { 91 mkdir $datedir or my_die( "failed to create working directory $datedir for request id $req_id", $req_id, 92 $PS_EXIT_CONFIG_ERROR); 93 } 94 95 $outdir = "$datedir/$req_id"; 96 } 97 98 if (! -e $outdir ) { 99 mkdir $outdir or my_die("failed to create working directory $outdir for request id $req_id", $req_id, 89 100 $PS_EXIT_CONFIG_ERROR); 90 101 } 91 92 my $workdir = "$datedir/$req_id"; 93 if (! -e $workdir ) { 94 mkdir $workdir or my_die("failed to create working directory $workdir for request id $req_id", $req_id, 95 $PS_EXIT_CONFIG_ERROR); 96 } 102 97 103 98 104 if ($redirect_output) { 99 my $logDest = "$ workdir/psparse.$req_id.log";105 my $logDest = "$outdir/psparse.$req_id.log"; 100 106 $ipprc->redirect_output($logDest); 101 107 } … … 108 114 109 115 my $fn = basename($uri); 110 my $new_uri = "$ workdir/$fn";116 my $new_uri = "$outdir/$fn"; 111 117 if ($uri =~ /^http:/) { 112 118 # if the uri is an http uri download the file … … 118 124 } 119 125 } elsif ($uri ne $new_uri) { 120 # put a link to the file into the workdir126 # copy the request file into outdir 121 127 if (-e $new_uri) { 128 # file exists already delete it incase the previous copy is bogus 122 129 unlink $new_uri or my_die("failed to unlink $new_uri", $req_id, $PS_EXIT_UNKNOWN_ERROR); 123 130 } 124 131 if (! copy $uri, $new_uri) { 125 my_die ("failed to copy request file $uri to workdir $ workdir", $req_id, $PS_EXIT_UNKNOWN_ERROR);132 my_die ("failed to copy request file $uri to workdir $outdir", $req_id, $PS_EXIT_UNKNOWN_ERROR); 126 133 } 127 134 } … … 152 159 } elsif ($request_type eq "MOPS_DETECTABILITY_QUERY") { 153 160 $reqType = 'dquery'; 154 $parse_cmd = $dqueryparse; 161 $parse_cmd = "$dqueryparse"; 162 $parse_cmd .= " --label $label" if $label; 155 163 } else { 156 164 print STDERR "Unknown request type $request_type found in $uri"; … … 172 180 # that they sent us a request file that we don't understand 173 181 174 my $command = "$pstamptool -updatereq -req_id $req_id -s tate run";175 $command .= " - reqType unknown";176 $command .= " - fault $PS_EXIT_DATA_ERROR";182 my $command = "$pstamptool -updatereq -req_id $req_id -set_state run"; 183 $command .= " -set_reqType unknown"; 184 $command .= " -set_fault $PS_EXIT_DATA_ERROR"; 177 185 $command .= " -dbname $dbname" if $dbname; 178 186 $command .= " -dbserver $dbserver" if $dbserver; … … 185 193 } 186 194 187 $parse_cmd .= " --mode queue_job --req_id $req_id --product $product --out _dir $workdir --file $uri";195 $parse_cmd .= " --mode queue_job --req_id $req_id --product $product --outdir $outdir --file $uri"; 188 196 $parse_cmd .= " --dbname $dbname" if $dbname; 189 197 $parse_cmd .= " --dbserver $dbserver" if $dbserver; … … 193 201 my $fault; 194 202 { 195 my $error_file_name = "$ workdir/parse_error.txt";203 my $error_file_name = "$outdir/parse_error.txt"; 196 204 # get rid of any error file from previous attempt to parse this request 197 205 unlink $error_file_name if (-e $error_file_name); … … 218 226 unless ($success) { 219 227 $fault = $error_code >> 8; 220 $newState = "stop";228 # $newState = "stop"; 221 229 } 222 230 } … … 226 234 # 227 235 { 228 my $command = "$pstamptool -updatereq -req_id $req_id -state $newState"; 229 $command .= " -reqType $reqType" if $reqType; 230 $command .= " -uri $new_uri" if $new_uri; 231 $command .= " -fault $fault" if $fault; 236 my $command = "$pstamptool -updatereq -req_id $req_id -set_state $newState"; 237 $command .= " -set_outdir $outdir"; 238 $command .= " -set_reqType $reqType" if $reqType; 239 $command .= " -set_uri $new_uri" if $new_uri; 240 $command .= " -set_fault $fault" if $fault; 232 241 $command .= " -dbname $dbname" if $dbname; 233 242 $command .= " -dbserver $dbserver" if $dbserver; … … 268 277 carp($msg); 269 278 270 my $command = "$pstamptool -updatereq -req_id $req_id - fault $fault";279 my $command = "$pstamptool -updatereq -req_id $req_id -set_fault $fault"; 271 280 $command .= " -dbname $dbname" if $dbname; 272 281 $command .= " -dbserver $dbserver" if $dbserver; -
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 -
branches/czw_branch/20100427/pstamp/scripts/request_finish.pl
r24831 r28017 21 21 use PS::IPP::Config qw( :standard ); 22 22 23 my ( $req_id, $req_name, $req_file, $req_type, $out _dir, $product, $dbname, $dbserver, $verbose, $save_temps, $redirect_output );23 my ( $req_id, $req_name, $req_file, $req_type, $outdir, $product, $dbname, $dbserver, $verbose, $save_temps, $redirect_output ); 24 24 25 25 GetOptions( … … 28 28 'req_file=s' => \$req_file, 29 29 'req_type=s' => \$req_type, 30 'out _dir=s' => \$out_dir,30 'outdir=s' => \$outdir, 31 31 'product=s' => \$product, 32 32 'dbname=s' => \$dbname, … … 46 46 $err .= "--req_name is required\n" if !$req_name; 47 47 $err .= "--product is required\n" if !$product; 48 # $err .= "--out _dir is required\n" if !$out_dir;48 # $err .= "--outdir is required\n" if !$outdir; 49 49 50 50 die "$err" if $err; 51 51 52 52 53 if (!$out _dir) {54 $out _dir = dirname($req_file);53 if (!$outdir) { 54 $outdir = dirname($req_file); 55 55 } 56 56 57 57 if ($redirect_output) { 58 my $logDest = "$out _dir/reqfinish.$req_id.log";58 my $logDest = "$outdir/reqfinish.$req_id.log"; 59 59 my $ipprc = PS::IPP::Config->new(); 60 60 $ipprc->redirect_output($logDest); … … 79 79 } 80 80 if ($finish_cmd) { 81 my $command = $finish_cmd . " --req_id $req_id --req_name $req_name --req_file $req_file --product $product --out _dir $out_dir";81 my $command = $finish_cmd . " --req_id $req_id --req_name $req_name --req_file $req_file --product $product --outdir $outdir"; 82 82 $command .= " --dbname $dbname" if $dbname; 83 83 $command .= " --dbserver $dbserver" if $dbserver; -
branches/czw_branch/20100427/pstamp/src/ppstampMakeStamp.c
r27461 r28017 36 36 double d_before = check->sky->d; 37 37 psLogMsg("ppstampMakeStamp", 2, "Before fit Center Pixel RA: %f DEC: %f (degrees)\n", 38 r_before * PS_DEG_RAD, d_before * PS_DEG_RAD);38 r_before * PS_DEG_RAD, d_before * PS_DEG_RAD); 39 39 40 40 if (outFPA->toSky->type != PS_PROJ_TAN) { 41 // we need to make astrometry terms for the output which are centered on the output chip center,42 // but we keep the original plate scale43 psFree(outFPA->toSky);44 outFPA->toSky = psProjectionAlloc (r_before, d_before, inFPA->toSky->Xs, inFPA->toSky->Ys, PS_PROJ_TAN);45 46 if (!pmAstromLinearizeToSky(inFPA, inChip, outFPA, outChip, roi)) {41 // we need to make astrometry terms for the output which are centered on the output chip center, 42 // but we keep the original plate scale 43 psFree(outFPA->toSky); 44 outFPA->toSky = psProjectionAlloc (r_before, d_before, inFPA->toSky->Xs, inFPA->toSky->Ys, PS_PROJ_TAN); 45 46 if (!pmAstromLinearizeToSky(inFPA, inChip, outFPA, outChip, roi)) { 47 47 psFree(check); 48 48 psError(PS_ERR_UNKNOWN, false, "Failed to linearize astrometry\n"); … … 56 56 57 57 psLogMsg("ppstampMakeStamp", 2, "After fit: Center Pixel RA: %f DEC: %f (degrees)\n", 58 r_after * PS_DEG_RAD, d_after * PS_DEG_RAD);59 psLogMsg("ppstampMakeStamp", 2, "Error in fit to astrometry %.2f %.2f (arcseconds)\n", 60 (r_after - r_before) * PS_DEG_RAD * 3600, (d_after - d_before) * PS_DEG_RAD * 3600);58 r_after * PS_DEG_RAD, d_after * PS_DEG_RAD); 59 psLogMsg("ppstampMakeStamp", 2, "Error in fit to astrometry %.2f %.2f (arcseconds)\n", 60 (r_after - r_before) * PS_DEG_RAD * 3600, (d_after - d_before) * PS_DEG_RAD * 3600); 61 61 62 62 // XXX: should we fail if the fit is bad ?? … … 238 238 return PS_EXIT_DATA_ERROR; 239 239 } 240 char *fpaName = psMetadataLookupStr(NULL, input->fpa->concepts, "FPA.OBS"); // Name of FPA241 240 pmFPAview *outview = pmFPAviewAlloc(0); 242 pmFPAAddSourceFromView(output->fpa, fpaName,outview, output->format);241 pmFPAAddSourceFromView(output->fpa, outview, output->format); 243 242 244 243 outview->chip = 0; -
branches/czw_branch/20100427/pstamp/src/ppstampMosaic.c
r18712 r28017 24 24 pmChip *inChip = pmFPAviewThisChip(view, input->fpa); 25 25 if (!mChip->hdu && !mChip->parent->hdu) { 26 const char *name = psMetadataLookupStr(&status, input->fpa->concepts, "FPA.OBS"); // Name of FPA 27 pmFPAAddSourceFromView(mosaic->fpa, name, mosaicView, mosaic->format); 26 pmFPAAddSourceFromView(mosaic->fpa, mosaicView, mosaic->format); 28 27 } 29 28 psFree(mosaicView); -
branches/czw_branch/20100427/pstamp/test/detect_query_create
r27784 r28017 16 16 $output, # Name of output table 17 17 $query_id, 18 $nostage, 18 19 ); 19 20 … … 22 23 'output|o=s' => \$output, 23 24 'query_id|q=s' => \$query_id, 25 'nostage' => \$nostage, 24 26 ) or pod2usage( 2 ); 25 27 … … 66 68 # } 67 69 ]; 70 unless(defined($nostage)) { 71 push @{ $header }, { name => 'STAGE', 72 writetype => TSTRING, 73 comment => 'processing stage to examine', 74 value => undef 75 }; 76 } 68 77 69 78 # Specification of columns to write
Note:
See TracChangeset
for help on using the changeset viewer.
