IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18587


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

Location:
trunk/pstamp/scripts
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/Makefile.am

    r18542 r18587  
    1515        pstamp_webrequest.pl \
    1616        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
    1823
    1924install_SCRIPTS = $(install_files)
  • 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;
  • trunk/pstamp/scripts/pstamp_finish.pl

    r18533 r18587  
    3131
    3232
    33 my ( $dbname, $limit, $verbose, $save_temps );
     33my ( $req_id, $req_name, $product, $dbname, $verbose, $save_temps );
    3434
    3535# the char to the right of the bar may be used as a single - alias for the longer name
    3636# for example --input and -i are equivalent
    3737GetOptions(
    38            'limit=s'    => \$limit,
     38           'req_id=s'   => \$req_id,
     39           'req_name=s' => \$req_name,
     40           'product=s'  => \$product,
    3941           'dbname=s'   => \$dbname,
    40            'verbose'  => \$verbose,
     42           'verbose'    => \$verbose,
    4143           'save-temps' => \$save_temps,
    4244) or pod2usage( 2 );
     
    6264my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    6365
    64 my @requests;
    6566{
    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 = @$requests
    86 }
    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 
    9867    # set the output fileset's name to the request name.
    9968    my $fileset = $req_name;
     
    156125            # including those that produced no jobs.
    157126            # 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 code
    160127            # we've included parse_results.txt to the fileset if it exists
    161128            #
     
    169136            my $jobs = parse_md_list($metadata);
    170137
    171             @jobs = @$jobs
     138            @jobs = @$jobs;
    172139        }
    173140    }
     
    201168            }
    202169        } else {
    203             die "Unknown jobType: $job_type";
     170            print STDERR "Unknown jobType: $job_type";
     171            next;
    204172        }
    205173    }
     
    235203    # set the request's state to stop
    236204    {
    237        
    238205        my $command = "$pstamptool -processedreq -req_id $req_id -state stop -fault $request_fault";
    239206        $command   .= " -dbname $dbname" if $dbname;
     
    245212    }
    246213}
     214sub 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  
    121121
    122122my $new_uri;
    123 if ($ds_id) {
     123if ($ds_id && ($uri =~ /^http:/)) {
    124124    {
    125125        $new_uri = "$workdir/request.fits";
     
    183183if ($request_type eq "PS1_PS_REQUEST") {
    184184    $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;
    187186} elsif ($request_type eq "MOPS_DETECTABILITY_QUERY") {
    188187    $reqType = 'dquery';
    189     $parse_cmd = $dqueryparse  . " --mode queue_job --req_id $req_id --out_dir $outProductDir --uri $uri";
     188    $parse_cmd = $dqueryparse;
    190189}
    191190
    192191if (!$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;
    197209
    198210my $fault;
     
    211223    if ($errbuf) {
    212224        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);
    214229        }
    215         print OUT "$errbuf";
    216         close(OUT);
    217230        print STDERR $errbuf if $verbose;
    218231    }
     
    241254# Note: We do not return $fault here. If there was a fatal error we've already exited.
    242255# 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.finish
     256# handled by the task pstamp.request.finish
    244257
    245258exit 0;
  • trunk/pstamp/scripts/pstamp_revert_request.pl

    r18537 r18587  
    9191my $fileset = $req_name;
    9292
    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;
     93print STDERR "product: $product  REQ_NAME: $req_name\n" if $verbose;
    9894
    9995if ($product and $fileset) {
  • trunk/pstamp/scripts/pstamp_runcommand.sh

    r18243 r18587  
    1818# These variables need to be customized for a particular installation
    1919# XXX: why not pass these on on the command line or in the environment?
    20 export PSCONFDIR=/export/data0/bills/psconfig
     20export PSCONFDIR=/home/panstarrs/bills/psconfig
    2121
    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
     22WORK_DIR=/data/ipp004.0/pstamp-work
    2423
    2524#### END LOCAL_CONFIGURATION
  • trunk/pstamp/scripts/pstampparse.pl

    r18541 r18587  
    8888    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    8989        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    #}
    9394    $fields_output = join "", @$stdout_buf;
    9495}
Note: See TracChangeset for help on using the changeset viewer.