IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 16, 2008, 3:27:19 PM (18 years ago)
Author:
bills
Message:

Changes to get detectability query processing working with the new
request processing scheme and tables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/dqueryparse.pl

    r18540 r18587  
    55# Note: this file is currently only a placeholder which creates a fake response file
    66# and adds a completed job to the database
    7 #
    8 # TODO: split off the actual generation of the response file into a standalone program
    97#
    108
     
    2826                       );
    2927
    30 my ($uri, $out_dir, $mode, $req_id, $verbose, $save_temps);
     28my ($req_file, $req_id, $out_dir, $product, $mode, $dbname, $verbose, $save_temps);
    3129
    3230#
     
    3533
    3634GetOptions(
    37         'uri=s'           =>      \$uri,
     35        'file=s'          =>      \$req_file,
     36        'req_id=s'        =>      \$req_id,
    3837        'out_dir=s'       =>      \$out_dir,
     38        'product=s'       =>      \$product,
     39        'mode=s'          =>      \$mode,
     40        'dbname=s'        =>      \$dbname,
    3941        'verbose'         =>      \$verbose,
    40         'mode=s'          =>      \$mode,
    41         'req_id=s'        =>      \$req_id,
    4242        'save-temps'      =>      \$save_temps,
    43         'verbose'         =>      \$verbose,
    4443) or pod2usage(2);
    4544
    4645my $err = "";
    4746
    48 if (!$uri) {
    49     $err .= "--uri is required\n";
     47if (!$req_file) {
     48    $err .= "--file is required\n";
     49}
     50if (!$req_id) {
     51    $err .= "--req_id is required\n";
    5052}
    5153if (!$out_dir) {
    5254    $err .="--out_dir is required\n";
    5355}
     56if (!$product) {
     57    $err .="--product is required\n";
     58}
    5459
    55 if (!$req_id) {
    56     $err .= "--req_id is required\n";
    57 }
    5860
    5961die $err if ($err);
     
    6264my $pstamptool = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools =1);
    6365my $fakedresponse = can_run('fakedresponse.pl') or (warn "Can't find fakedresponse.pl" and $missing_tools =1);
     66my $fields = can_run('fields') or (warn "Can't find fields" and $missing_tools =1);
    6467
    6568if ($missing_tools) {
     
    6871}
    6972
     73# get the query id and check the extname and version from the header
     74my $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}
     86my (undef, $extname, $extver, $req_name) = split " ", $fields_output;
     87
     88die "$req_file has EXTNAME $extname not MOPS_DETECTABILITY_QUERY table"
     89                if $extname ne         "MOPS_DETECTABILITY_QUERY";
     90die "$req_file does not have a QUERY_ID" if ! $req_name;
     91die "$req_file is version $extver expecting 1" if $extver ne 1;
     92
     93$out_dir .= "/$req_name";
     94if (! -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
    70103my $response_file = "$out_dir/response.fits";
    71104my $fault;
    72105{
    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";
    74107    $command .= " --save-temps" if $save_temps;
    75108    $command .= " --verbose" if $verbose;
     
    84117
    85118my $job_id;
     119my $result;
    86120{
    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;
    89125
    90126    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    101137}
    102138
    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;
    104143
    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    }
    117149}
     150 
     151exit 0;
Note: See TracChangeset for help on using the changeset viewer.