Changeset 21410
- Timestamp:
- Feb 6, 2009, 5:44:55 PM (17 years ago)
- Location:
- trunk/pstamp/scripts
- Files:
-
- 7 edited
-
pstamp_finish.pl (modified) (8 diffs)
-
pstamp_job_run.pl (modified) (4 diffs)
-
pstamp_listjobs.pl (modified) (2 diffs)
-
pstamp_parser_run.pl (modified) (6 diffs)
-
pstamp_queue_requests.pl (modified) (4 diffs)
-
pstampparse.pl (modified) (2 diffs)
-
request_finish.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_finish.pl
r21190 r21410 14 14 use File::Temp qw( tempfile ); 15 15 use File::Copy; 16 use File::Basename qw(dirname); 16 17 17 18 use PS::IPP::Metadata::Config; … … 23 24 use PStamp::Job qw( :standard ); 24 25 25 my ( $req_id, $req_name, $req_file, $ product, $dbname, $verbose, $save_temps);26 my ( $req_id, $req_name, $req_file, $out_dir, $product, $dbname, $verbose, $save_temps, $redirect_output); 26 27 27 28 # the char to the right of the bar may be used as a single - alias for the longer name 28 29 # for example --input and -i are equivalent 29 30 GetOptions( 30 'req_id=s' => \$req_id, 31 'req_name=s' => \$req_name, 32 'req_file=s' => \$req_file, 33 'product=s' => \$product, 34 'dbname=s' => \$dbname, 35 'verbose' => \$verbose, 36 'save-temps' => \$save_temps, 31 'req_id=s' => \$req_id, 32 'req_name=s' => \$req_name, 33 'req_file=s' => \$req_file, 34 'product=s' => \$product, 35 'out_dir=s' => \$out_dir, 36 'dbname=s' => \$dbname, 37 'verbose' => \$verbose, 38 'save-temps' => \$save_temps, 39 'redirect-output' => \$redirect_output, 37 40 ) or pod2usage( 2 ); 38 41 39 42 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 40 43 41 die "usage: --req_id id --req_name name --req_file file --product product [--dbname dbname --verbose]\n" 42 if !$req_id or !$req_name or !$req_file or !$product; 44 die "usage: --req_id id --req_name name --req_file file --product product --out_dir output_directory [--dbname dbname --verbose]\n" 45 if !$req_id or !$req_name or !$req_file or !$product or !$out_dir; 46 47 my $ipprc = PS::IPP::Config->new(); # IPP Configuration 48 49 if ($redirect_output) { 50 my $logDest = "$out_dir/psfinish.$req_id.log"; 51 $ipprc->redirect_output($logDest); 52 } 43 53 44 54 my $missing_tools; … … 53 63 } 54 64 55 my $ipprc = PS::IPP::Config->new(); # IPP Configuration56 65 57 66 my $outputDataStoreRoot = metadataLookupStr($ipprc->{_siteConfig}, 'DATA_STORE_ROOT'); … … 64 73 my $fileset = $req_name; 65 74 75 66 76 # Here we invoke the assumption that the output for the request is placed in the 67 77 # fileset directory directly 68 my $out_dir = "$outputDataStoreRoot/$product/$fileset"; 78 # my $out_dir = "$outputDataStoreRoot/$product/$fileset"; 79 80 # now we are assuming that the output directory is the dirname of the request file 81 # XXX: put this in the database 69 82 70 83 print STDERR "product: $product REQ_NAME: $req_name $out_dir\n" if $verbose; … … 72 85 if (!-e $out_dir) { 73 86 # something must have gone wrong parsing the request 74 print STDERR "output filesetdirectory $out_dir does not exist\n";87 print STDERR "output directory $out_dir does not exist\n"; 75 88 76 89 if (!mkdir $out_dir) { … … 83 96 # XXX TODO: fault the request so we pstamp_finish doesn't keep trying to process the 84 97 # request 85 print STDERR "output filesetdirectory $out_dir exists but is not a directory";98 print STDERR "output directory $out_dir exists but is not a directory"; 86 99 stop_request($req_id, $PS_EXIT_UNKNOWN_ERROR, $dbname); 87 100 } … … 111 124 print $rlf "results.fits|||table|\n"; 112 125 113 # XXX: this file is in the request's workdir not the out_dir 114 my $err_file = "$out_dir/parse_error.txt"; 115 if (-e $err_file ) { 126 my $err_file = "parse_error.txt"; 127 if (-e "$out_dir/$err_file" ) { 116 128 print $rlf "$err_file|||text|\n"; 117 129 } … … 222 234 if (!$request_fault) { 223 235 # register the fileset 224 # Note that we are assuming that the fileset's files are already in the fileset directory.225 # We could put them somewhere else and copy them in but for now we set the output directory226 # to the fileset directory at parse time227 236 my $command = "$dsreg --list $reglist_name --add $fileset --product $product --type PSRESULTS"; 237 $command .= " --link --datapath $out_dir"; 228 238 $command .= " --dbname $dbname" if $dbname; 229 239 -
trunk/pstamp/scripts/pstamp_job_run.pl
r20152 r21410 18 18 my $dbname; 19 19 my $job_id; 20 my $redirect_output; 21 my $output_base; 20 22 21 23 my $host = hostname(); … … 23 25 24 26 GetOptions( 25 'job_id=s' => \$job_id, 26 'dbname=s' => \$dbname, 27 'verbose' => \$verbose, 27 'job_id=s' => \$job_id, 28 'output_base=s' => \$output_base, 29 'redirect-output' => \$redirect_output, 30 'dbname=s' => \$dbname, 31 'verbose' => \$verbose, 28 32 ); 29 33 … … 35 39 36 40 die "job_id is required" if !$job_id; 41 die "output_base is required" if !$output_base; 37 42 38 43 use IPC::Cmd 0.36 qw( can_run run ); … … 53 58 caturi 54 59 ); 60 my $ipprc = PS::IPP::Config->new(); # IPP Configuration 61 62 if ($redirect_output) { 63 my $logDest = "$output_base.log"; 64 $ipprc->redirect_output($logDest); 65 } 55 66 56 67 my $missing_tools; -
trunk/pstamp/scripts/pstamp_listjobs.pl
r18545 r21410 101 101 my $add_fits = 0; 102 102 if ($job->{jobType} ne "get_image") { 103 $add_fits = 1;103 # $add_fits = 1; 104 104 } 105 105 … … 115 115 } 116 116 117 print "$job->{job_id} $job->{state} $ uri\n";117 print "$job->{job_id} $job->{state} $job->{fault} $job->{name} $job->{outProduct} $uri\n"; 118 118 } 119 119 -
trunk/pstamp/scripts/pstamp_parser_run.pl
r21385 r21410 12 12 use Sys::Hostname; 13 13 use Getopt::Long qw( GetOptions ); 14 14 use File::Basename qw( basename dirname); 15 16 my $req_id; 17 my $uri; 18 my $redirect_output; 19 my $product; 15 20 my $verbose; 16 21 my $dbname; 17 my $req_id;18 22 19 23 GetOptions( 20 'verbose' => \$verbose, 21 'dbname=s' => \$dbname, 22 'req_id=s' => \$req_id, 24 'req_id=s' => \$req_id, 25 'uri=s' => \$uri, 26 'product=s' => \$product, 27 'redirect-output' => \$redirect_output, 28 'verbose' => \$verbose, 29 'dbname=s' => \$dbname, 23 30 ); 24 31 … … 29 36 } 30 37 31 die "req_id is required" if !defined($req_id); 38 die "--req_id --uri --product are required" 39 if !defined($req_id) or 40 !defined($uri) or 41 !defined($product); 32 42 33 43 use IPC::Cmd 0.36 qw( can_run run ); … … 66 76 } 67 77 78 if ($redirect_output) { 79 my $logDest = "$workdir/psparse.$req_id.log"; 80 $ipprc->redirect_output($logDest); 81 } 82 68 83 my $defaultDSProduct = metadataLookupStr($ipprc->{_siteConfig}, 'PSTAMP_DATA_STORE_PRODUCT'); 69 84 exit ($PS_EXIT_CONFIG_ERROR) unless defined $defaultDSProduct; … … 83 98 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 84 99 85 my $psrequest; 86 #Look up the uri for the given request 87 { 88 my $command = "$pstamptool -pendingreq -req_id $req_id"; 89 $command .= " -dbname $dbname" if $dbname; 100 101 my $fn = basename($uri); 102 my $new_uri = "$workdir/$fn"; 103 if ($uri =~ /^http:/) { 104 # if the uri is an http uri download the file 105 my $command = "$dsget --uri $uri --filename $new_uri"; 90 106 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 91 107 run(command => $command, verbose => $verbose); … … 93 109 die("Unable to perform $command error code: $error_code"); 94 110 } 95 96 if (@$stdout_buf == 0) { 97 print STDERR "pending pstamp request id $req_id not found\n"; 98 exit 1; 99 } 100 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 101 die("Unable to parse metdata config doc"); 102 103 my $requests = parse_md_list($metadata); 104 105 my $num = @$requests; 106 die "unexpected number of requests $num found" if $num > 1; 107 108 $psrequest = $requests->[0]; 109 } 110 111 if (!$psrequest) { 112 print STDERR "pending postage stamp request $req_id not found\n"; 113 exit 1; 114 } 115 116 my $uri = $psrequest->{uri}; 117 118 # if the uri is from a data store, download it 119 120 my $ds_id = $psrequest->{ds_id}; 121 122 my $new_uri; 123 if ($ds_id && ($uri =~ /^http:/)) { 124 { 125 $new_uri = "$workdir/request.fits"; 126 my $command = "$dsget --uri $uri --filename $new_uri"; 127 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 128 run(command => $command, verbose => $verbose); 129 unless ($success) { 130 die("Unable to perform $command error code: $error_code"); 131 } 132 133 $uri = $new_uri; 134 } 135 } 136 137 # find the name of the output directory 138 my $product; 139 if ($ds_id) { 140 my $command = "$pstamptool -datastore -ds_id $ds_id"; 141 $command .= " -dbname $dbname" if $dbname; 142 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 143 run(command => $command, verbose => $verbose); 144 unless ($success) { 145 die("Unable to perform $command error code: $error_code"); 146 } 147 148 if (@$stdout_buf == 0) { 149 print STDERR "data store with data store id $ds_id not found\n"; 150 exit 1; 151 } 152 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 153 die("Unable to parse metdata config doc"); 154 155 my $dataStores = parse_md_list($metadata); 156 157 my $dataStore = $dataStores->[0]; 158 159 $product = $dataStore->{outProduct}; 160 } else { 111 } elsif ($uri ne $new_uri) { 112 # put a link to the file into the workdir 113 if (-e $new_uri) { 114 unlink $new_uri or die "failed to unlink $new_uri"; 115 } 116 if (! symlink $uri, $new_uri) { 117 die ("failed to link request file $uri to workdir $workdir"); 118 } 119 } 120 $uri = $new_uri; 121 122 die "request file $uri not found" if ! -e $uri; 123 124 # if product was not defined (in database), use the default 125 if ($product eq "NULL") { 161 126 $product = $defaultDSProduct; 162 127 } 163 164 #165 # Here is one of the places that we assume that the output for a request goes directly into166 # the output fileset directory in the data store.167 #168 my $outProductDir = "$outputDataStoreRoot/$product";169 170 die "output product directory $outProductDir does not exist" if (! -e $outProductDir) ;171 die "file with name of output product directory $outProductDir exists but is not a directory"172 if (! -d $outProductDir);173 128 174 129 my $parse_cmd; … … 220 175 } 221 176 222 $parse_cmd .= " --mode queue_job --req_id $req_id --product $product --out_dir $ outProductDir --file $uri";177 $parse_cmd .= " --mode queue_job --req_id $req_id --product $product --out_dir $workdir --file $uri"; 223 178 $parse_cmd .= " --dbname $dbname" if $dbname; 179 $parse_cmd .= " --verbose" if $verbose; 224 180 225 181 my $newState = "run"; -
trunk/pstamp/scripts/pstamp_queue_requests.pl
r19265 r21410 107 107 my $command = "$dsproductls --uri $ds->{uri}/index.txt"; 108 108 $command .= " --last_fileset $ds->{lastFileset}" if $ds->{lastFileset}; 109 109 110 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 110 111 run(command => $command, verbose => $verbose); 111 112 unless ($success) { 113 # dsproductls exit status is the http error code - 300 114 my $exit_status = $error_code >> 8; 115 116 # don't die on "common faults" 117 # perhaps after some number of these we should mark the data store as disabled 118 next if ($exit_status == 200); # 500 cannot connect (data store down) 119 next if ($exit_status == 104); # 404 not found 120 # next if ($exit_status == 100); # 400 bad request 121 112 122 die("Unable to perform $command: $error_code"); 113 123 } … … 143 153 run(command => $command, verbose => $verbose); 144 154 unless ($success) { 155 # we don't want to die here. We need to set lastFileset 156 # so that we don't re queue requsts that we have proccessed 145 157 die("Unable to perform $command: $error_code"); 146 158 } … … 175 187 } 176 188 $lastFileset = $fs_name; 177 last if ($numFilesets >= $limit); 178 } 179 180 ## now update the last_fileset column in pstampDataStore 181 ## XXX: we should perhaps do this while processing each fileset so that if a later 182 ## one has an error we don't get repeats. 183 184 if ($lastFileset) { 185 # print "last fileset: $lastFileset\n"; 189 186 190 { 191 ## now update the last_fileset column in pstampDataStore 187 192 my $command = "$pstamptool -ds_id $ds_id -moddatastore -last_fileset $lastFileset"; 188 193 $command .= " -dbname $dbname" if $dbname; … … 193 198 } 194 199 } 200 last if ($numFilesets >= $limit); 195 201 } 196 202 } -
trunk/pstamp/scripts/pstampparse.pl
r21242 r21410 84 84 die "REQ_NAME not found in $request_file_name" if (!$req_name); 85 85 die "wrong EXTVER $extver found in $request_file_name" if ($extver ne "1"); 86 87 if ($out_dir) {88 $out_dir .= "/$req_name";89 if (! -e $out_dir ) {90 mkdir $out_dir or die "cannot create output directory $out_dir";91 } elsif (! -d $out_dir ) {92 die "output fileset directory $out_dir exists but is not a directory";93 }94 }95 86 96 87 if ($req_id) { … … 187 178 } 188 179 189 # Call PStamp::Job's locate_images routin te to get the parameters for this request specification180 # Call PStamp::Job's locate_images routine to get the parameters for this request specification 190 181 my $images = locate_images($ipprc, $image_db, $req_type, $img_type, $id, $class_id, 191 $x, $y, $mjd_min, $mjd_max, $filter );182 $x, $y, $mjd_min, $mjd_max, $filter, $verbose); 192 183 193 184 if (!$images) { -
trunk/pstamp/scripts/request_finish.pl
r19221 r21410 13 13 use File::Temp qw( tempfile ); 14 14 use File::Copy; 15 use File::Basename qw( dirname ); 15 16 16 17 use PS::IPP::Metadata::Config; … … 20 21 use PS::IPP::Config qw( :standard ); 21 22 22 my ( $req_id, $req_name, $req_file, $req_type, $ product, $dbname, $verbose, $save_temps);23 my ( $req_id, $req_name, $req_file, $req_type, $out_dir, $product, $dbname, $verbose, $save_temps, $redirect_output ); 23 24 24 25 GetOptions( … … 27 28 'req_file=s' => \$req_file, 28 29 'req_type=s' => \$req_type, 30 'out_dir=s' => \$out_dir, 29 31 'product=s' => \$product, 30 32 'dbname=s' => \$dbname, 31 33 'verbose' => \$verbose, 32 34 'save-temps' => \$save_temps, 35 'redirect-output' => \$redirect_output, 33 36 ) or pod2usage( 2 ); 34 37 … … 42 45 $err .= "--req_name is required\n" if !$req_name; 43 46 $err .= "--product is required\n" if !$product; 47 # $err .= "--out_dir is required\n" if !$out_dir; 44 48 45 49 die "$err" if $err; 50 51 52 if (!$out_dir) { 53 $out_dir = dirname($req_file); 54 } 55 56 if ($redirect_output) { 57 my $logDest = "$out_dir/reqfinish.$req_id.log"; 58 my $ipprc = PS::IPP::Config->new(); 59 $ipprc->redirect_output($logDest); 60 } 46 61 47 62 my $missing_tools; … … 63 78 } 64 79 if ($finish_cmd) { 65 my $command = $finish_cmd . " --req_id $req_id --req_name $req_name --req_file $req_file --product $product ";80 my $command = $finish_cmd . " --req_id $req_id --req_name $req_name --req_file $req_file --product $product --out_dir $out_dir"; 66 81 $command .= " --dbname $dbname" if $dbname; 67 82 $command .= " --verbose" if $verbose;
Note:
See TracChangeset
for help on using the changeset viewer.
