Changeset 18587
- Timestamp:
- Jul 16, 2008, 3:27:19 PM (18 years ago)
- Location:
- trunk/pstamp/scripts
- Files:
-
- 2 added
- 7 edited
-
Makefile.am (modified) (1 diff)
-
detect_query_read (added)
-
detect_response_create (added)
-
dqueryparse.pl (modified) (7 diffs)
-
pstamp_finish.pl (modified) (7 diffs)
-
pstamp_parser_run.pl (modified) (4 diffs)
-
pstamp_revert_request.pl (modified) (1 diff)
-
pstamp_runcommand.sh (modified) (1 diff)
-
pstampparse.pl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/Makefile.am
r18542 r18587 15 15 pstamp_webrequest.pl \ 16 16 pstamp_get_image_job.pl \ 17 dqueryparse.pl 17 request_finish.pl \ 18 detect_query_read \ 19 detect_response_create \ 20 dquery_finish.pl \ 21 dqueryparse.pl \ 22 fakedresponse.pl 18 23 19 24 install_SCRIPTS = $(install_files) -
trunk/pstamp/scripts/dqueryparse.pl
r18540 r18587 5 5 # Note: this file is currently only a placeholder which creates a fake response file 6 6 # and adds a completed job to the database 7 #8 # TODO: split off the actual generation of the response file into a standalone program9 7 # 10 8 … … 28 26 ); 29 27 30 my ($ uri, $out_dir, $mode, $req_id, $verbose, $save_temps);28 my ($req_file, $req_id, $out_dir, $product, $mode, $dbname, $verbose, $save_temps); 31 29 32 30 # … … 35 33 36 34 GetOptions( 37 'uri=s' => \$uri, 35 'file=s' => \$req_file, 36 'req_id=s' => \$req_id, 38 37 'out_dir=s' => \$out_dir, 38 'product=s' => \$product, 39 'mode=s' => \$mode, 40 'dbname=s' => \$dbname, 39 41 'verbose' => \$verbose, 40 'mode=s' => \$mode,41 'req_id=s' => \$req_id,42 42 'save-temps' => \$save_temps, 43 'verbose' => \$verbose,44 43 ) or pod2usage(2); 45 44 46 45 my $err = ""; 47 46 48 if (!$uri) { 49 $err .= "--uri is required\n"; 47 if (!$req_file) { 48 $err .= "--file is required\n"; 49 } 50 if (!$req_id) { 51 $err .= "--req_id is required\n"; 50 52 } 51 53 if (!$out_dir) { 52 54 $err .="--out_dir is required\n"; 53 55 } 56 if (!$product) { 57 $err .="--product is required\n"; 58 } 54 59 55 if (!$req_id) {56 $err .= "--req_id is required\n";57 }58 60 59 61 die $err if ($err); … … 62 64 my $pstamptool = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools =1); 63 65 my $fakedresponse = can_run('fakedresponse.pl') or (warn "Can't find fakedresponse.pl" and $missing_tools =1); 66 my $fields = can_run('fields') or (warn "Can't find fields" and $missing_tools =1); 64 67 65 68 if ($missing_tools) { … … 68 71 } 69 72 73 # get the query id and check the extname and version from the header 74 my $fields_output; 75 { 76 my $command = "echo $req_file | $fields -x 0 EXTNAME EXTVER QUERY_ID"; 77 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 78 run(command => $command, verbose => $verbose); 79 80 # fields doesn't return zero when it succeeds 81 # unless ($success) { 82 # print STDERR @$stderr_buf; 83 # } 84 $fields_output = join "", @$stdout_buf; 85 } 86 my (undef, $extname, $extver, $req_name) = split " ", $fields_output; 87 88 die "$req_file has EXTNAME $extname not MOPS_DETECTABILITY_QUERY table" 89 if $extname ne "MOPS_DETECTABILITY_QUERY"; 90 die "$req_file does not have a QUERY_ID" if ! $req_name; 91 die "$req_file is version $extver expecting 1" if $extver ne 1; 92 93 $out_dir .= "/$req_name"; 94 if (! -e $out_dir ) { 95 mkdir $out_dir or die "cannot create output directory $out_dir"; 96 } elsif (! -d $out_dir ) { 97 die "output fileset directory $out_dir exists but is not a directory"; 98 } 99 100 # 101 # we don't parse the file here, pass it to fakedresponse it will create a response for each 102 # row in the file 70 103 my $response_file = "$out_dir/response.fits"; 71 104 my $fault; 72 105 { 73 my $command = "$fakedresponse --input $ uri--output $response_file --workdir $out_dir";106 my $command = "$fakedresponse --input $req_file --output $response_file --workdir $out_dir"; 74 107 $command .= " --save-temps" if $save_temps; 75 108 $command .= " --verbose" if $verbose; … … 84 117 85 118 my $job_id; 119 my $result; 86 120 { 87 my $command = "$pstamptool -addjob -req_id $req_id -uri $uri -outputBase $out_dir -job_type detect_query"; 88 $command .= " -state stop -fault $fault"; 121 my $command = "$pstamptool -addjob -req_id $req_id -uri $req_file -outputBase $out_dir"; 122 $command .= " -job_type detect_query -state stop -fault $fault"; 123 $command .= " -rownum 1"; 124 $command .= " -dbname $dbname" if $dbname; 89 125 90 126 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 101 137 } 102 138 103 exit $result; 139 { 140 my $command = "$pstamptool -processedreq -req_id $req_id -name $req_name -outProduct $product"; 141 $command .= " -fault $result" if $result; 142 $command .= " -dbname $dbname" if $dbname; 104 143 105 106 107 108 sub fake_dquery_response { 109 my $line = shift; 110 my ($rownum, $ra1, $dec1, $ra2, $dec2, $mag) = split " ", $line; 111 112 # todo perhaps think more about these values 113 my $n = rand(16); 114 my $f = rand(1); 115 116 return ($rownum, $n, $f); 144 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 145 run(command => $command, verbose => $verbose); 146 unless ($success) { 147 die "$command failed"; 148 } 117 149 } 150 151 exit 0; -
trunk/pstamp/scripts/pstamp_finish.pl
r18533 r18587 31 31 32 32 33 my ( $ dbname, $limit, $verbose, $save_temps );33 my ( $req_id, $req_name, $product, $dbname, $verbose, $save_temps ); 34 34 35 35 # the char to the right of the bar may be used as a single - alias for the longer name 36 36 # for example --input and -i are equivalent 37 37 GetOptions( 38 'limit=s' => \$limit, 38 'req_id=s' => \$req_id, 39 'req_name=s' => \$req_name, 40 'product=s' => \$product, 39 41 'dbname=s' => \$dbname, 40 'verbose' => \$verbose,42 'verbose' => \$verbose, 41 43 'save-temps' => \$save_temps, 42 44 ) or pod2usage( 2 ); … … 62 64 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 63 65 64 my @requests;65 66 { 66 my $command = "$pstamptool -completedreq";67 $command .= " -limit $limit" if $limit;68 $command .= " -dbname $dbname" if $dbname;69 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =70 run(command => $command, verbose => $verbose);71 unless ($success) {72 die("Unable to perform $command error code: $error_code");73 }74 my $output = join "", @$stdout_buf;75 if (!$output) {76 if ($verbose) {77 print STDERR "no completed requests pending\n"78 }79 exit 0;80 }81 my $metadata = $mdcParser->parse($output) or die("Unable to parse metdata config doc");82 83 my $requests = parse_md_list($metadata);84 85 @requests = @$requests86 }87 88 foreach my $req (@requests) {89 my $req_id = $req->{req_id};90 91 my $product = $req->{outProduct};92 die "outProduct in request is null" if !$product;93 94 my $req_name = $req->{name};95 die "request name is null" if !$req_name;96 97 98 67 # set the output fileset's name to the request name. 99 68 my $fileset = $req_name; … … 156 125 # including those that produced no jobs. 157 126 # for now add an entry for rownum 1 and a phony error code. 158 #159 # possible fix: have pstampparse add a dummy job with state=stop and a fault code160 127 # we've included parse_results.txt to the fileset if it exists 161 128 # … … 169 136 my $jobs = parse_md_list($metadata); 170 137 171 @jobs = @$jobs 138 @jobs = @$jobs; 172 139 } 173 140 } … … 201 168 } 202 169 } else { 203 die "Unknown jobType: $job_type"; 170 print STDERR "Unknown jobType: $job_type"; 171 next; 204 172 } 205 173 } … … 235 203 # set the request's state to stop 236 204 { 237 238 205 my $command = "$pstamptool -processedreq -req_id $req_id -state stop -fault $request_fault"; 239 206 $command .= " -dbname $dbname" if $dbname; … … 245 212 } 246 213 } 214 sub stop_request { 215 my $req_id = shift; 216 my $fault = shift; 217 my $dbname = shift; 218 219 my $command = "$pstamptool -processedreq -req_id $req_id -state stop -fault $fault"; 220 $command .= " -dbname $dbname" if $dbname; 221 222 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 223 run(command => $command, verbose => $verbose); 224 unless ($success) { 225 die("Unable to perform $command error code: $error_code"); 226 } 227 } -
trunk/pstamp/scripts/pstamp_parser_run.pl
r18539 r18587 121 121 122 122 my $new_uri; 123 if ($ds_id ) {123 if ($ds_id && ($uri =~ /^http:/)) { 124 124 { 125 125 $new_uri = "$workdir/request.fits"; … … 183 183 if ($request_type eq "PS1_PS_REQUEST") { 184 184 $reqType = 'pstamp'; 185 $parse_cmd = $pstampparse . " --mode queue_job --req_id $req_id --product $product --out_dir $outProductDir --file $uri"; 186 $parse_cmd .= " --dbname $dbname" if $dbname; 185 $parse_cmd = $pstampparse; 187 186 } elsif ($request_type eq "MOPS_DETECTABILITY_QUERY") { 188 187 $reqType = 'dquery'; 189 $parse_cmd = $dqueryparse . " --mode queue_job --req_id $req_id --out_dir $outProductDir --uri $uri";188 $parse_cmd = $dqueryparse; 190 189 } 191 190 192 191 if (!$parse_cmd) { 193 # XXX TODO mark the error state for the job and set it to stop 194 die "null request type found in $uri" if !$request_type; 195 die "unknown request type $request_type found in $uri"; 196 } 192 print STDERR "No EXTNAME found in $uri" if !$request_type; 193 print STDERR "Unknown request type $request_type found in $uri"; 194 195 my $command = "$pstamptool -processedreq -req_id $req_id -state run"; 196 $command .= " -reqType unknown"; 197 $command .= " -fault $PS_EXIT_DATA_ERROR"; 198 $command .= " -dbname $dbname" if $dbname; 199 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 200 run(command => $command, verbose => $verbose); 201 unless ($success) { 202 die("Unable to perform $command error code: $error_code"); 203 } 204 exit $PS_EXIT_DATA_ERROR; 205 } 206 207 $parse_cmd .= " --mode queue_job --req_id $req_id --product $product --out_dir $outProductDir --file $uri"; 208 $parse_cmd .= " --dbname $dbname" if $dbname; 197 209 198 210 my $fault; … … 211 223 if ($errbuf) { 212 224 if (!open OUT, ">$error_file_name") { 213 die("unable to open parse_error file $error_file_name"); 225 print STDERR ("unable to open parse_error file $error_file_name"); 226 } else { 227 print OUT "$errbuf"; 228 close(OUT); 214 229 } 215 print OUT "$errbuf";216 close(OUT);217 230 print STDERR $errbuf if $verbose; 218 231 } … … 241 254 # Note: We do not return $fault here. If there was a fatal error we've already exited. 242 255 # If we got a fault it's due to bad input from the user we've set things up for this to be 243 # handled by the pstamp.request.finish256 # handled by the task pstamp.request.finish 244 257 245 258 exit 0; -
trunk/pstamp/scripts/pstamp_revert_request.pl
r18537 r18587 91 91 my $fileset = $req_name; 92 92 93 # Here we invoke the assumption that the output for the request is placed in the 94 # fileset directory directly 95 my $out_dir = "$outputDataStoreRoot/$product/$fileset"; 96 97 print STDERR "product: $product REQ_NAME: $req_name $out_dir\n" if $verbose; 93 print STDERR "product: $product REQ_NAME: $req_name\n" if $verbose; 98 94 99 95 if ($product and $fileset) { -
trunk/pstamp/scripts/pstamp_runcommand.sh
r18243 r18587 18 18 # These variables need to be customized for a particular installation 19 19 # XXX: why not pass these on on the command line or in the environment? 20 export PSCONFDIR=/ export/data0/bills/psconfig20 export PSCONFDIR=/home/panstarrs/bills/psconfig 21 21 22 WORK_DIR=/export/data1/bills/pstamp/work 23 CMD_DIR=/export/data0/bills/src/ipp/pstamp/scripts:/export/data0/bills/src/ipp/DataStoreServer/web/cgi 22 WORK_DIR=/data/ipp004.0/pstamp-work 24 23 25 24 #### END LOCAL_CONFIGURATION -
trunk/pstamp/scripts/pstampparse.pl
r18541 r18587 88 88 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 89 89 run(command => $command, verbose => $verbose); 90 unless ($success) { 91 print STDERR @$stderr_buf; 92 } 90 # fields doesn't return zero when it succeeds 91 #unless ($success) { 92 # print STDERR @$stderr_buf; 93 #} 93 94 $fields_output = join "", @$stdout_buf; 94 95 }
Note:
See TracChangeset
for help on using the changeset viewer.
