IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18619


Ignore:
Timestamp:
Jul 18, 2008, 12:56:11 PM (18 years ago)
Author:
bills
Message:

Add the job id to the response file to support a dquery request generating
multiple jobs

Location:
trunk/pstamp/scripts
Files:
2 edited

Legend:

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

    r18588 r18619  
    6767exit ($PS_EXIT_CONFIG_ERROR) unless defined $outputDataStoreRoot; # lookup failure outputs a message
    6868
    69 my $response_file = "$outputDataStoreRoot/$product/$req_name/response.fits";
     69my $out_dir = "$outputDataStoreRoot/$product/$req_name";
     70if (! -e $out_dir ) {
     71    # something must have gone wrong at the parse stage
     72    print STDERR "output fileset directory $out_dir does not exist\n" if $verbose;
     73    if (! mkdir $out_dir ) {
     74        stop_request($req_id, $PS_EXIT_SYS_ERROR, $verbose);
     75        die "cannot create output directory $out_dir";
     76    }
     77} elsif (! -d $out_dir) {
     78    stop_request($req_id, $PS_EXIT_SYS_ERROR, $verbose);
     79    die "output fileset directory $out_dir exists but is not a directory";
     80}
     81
     82
     83my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    7084
    7185my $request_fault = 0;
    72 if (-e $response_file) {
     86my @jobs;
     87{
     88    my $command = "$pstamptool -listjob -req_id $req_id";
     89    $command .= " -dbname $dbname" if $dbname;
     90    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     91        run(command => $command, verbose => $verbose);
     92    unless ($success) {
     93        die("Unable to perform $command error code: $error_code");
     94    }
     95    my $output = join "", @$stdout_buf;
     96    if (!$output) {
     97        if ($verbose) {
     98            print STDERR "Request $req_id produced no jobs.\n";
     99        }
     100        # assume that the parser set the fault
     101    } else {
     102        my $metadata =  $mdcParser->parse($output) or die("Unable to parse metdata config doc for jobs list");
     103        my $jobs = parse_md_list($metadata);
     104        @jobs = @$jobs;
     105    }
     106}
    73107
    74     # the job generated a response file put it into the Data Store
    75     # XXX: for now we have one response file. In the real system we may have multiple jobs with
    76     # multiple response files
     108my ($REGLIST, $reg_list) = tempfile("$out_dir/reqlist.XXXX", UNLINK => !$save_temps);
     109foreach my $job (@jobs) {
     110    my $job_id = $job->{job_id};
     111    my $response_file = "response${job_id}.fits";
     112    my $response_path = "$out_dir/$response_file";
    77113
    78     my $command = "echo 'response.fits|||table|' | $dsreg --add $req_name --product $product --list -";
     114    if (-e $response_path) {
     115        # the job generated a response file put it into the Data Store
     116        print $REGLIST "$response_file|||table|\n";
     117    } else  {
     118        print STDERR "detect_query response file for job $job_id not found\n";
     119        $request_fault = $PS_EXIT_UNKNOWN_ERROR;
     120    }
     121}
     122close $REGLIST;
     123
     124if (-s $reg_list) {
     125    my $command = "$dsreg --add $req_name --product $product --list $reg_list";
    79126    $command .= " --type MOPS_DETECTABILITY_RESPONSE";
    80127    $command .= " --dbname $dbname" if $dbname;
     
    85132        $request_fault = $error_code >> 8;
    86133        print STDERR "Unable to perform $command return code: $request_fault";
     134        # fall through to stop request
    87135    }
    88 
    89 } else  {
    90     print STDERR "detect_query response file not found\n";
    91     $request_fault = $PS_EXIT_UNKNOWN_ERROR;
    92136}
    93137
    94 # set the request's state to stop
    95 {
    96     my $command = "$pstamptool -processedreq -req_id $req_id -state stop -fault $request_fault";
     138stop_request($req_id, $request_fault, $verbose);
     139
     140exit 0;
     141
     142sub stop_request {
     143    my $req_id = shift;
     144    my $fault = shift;
     145    my $verbose = shift;
     146   
     147    my $command = "$pstamptool -processedreq -req_id $req_id -state stop";
     148    $command   .= " -fault $fault" if $fault;
    97149    $command   .= " -dbname $dbname" if $dbname;
    98150    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    102154    }
    103155}
    104 
  • trunk/pstamp/scripts/dqueryparse.pl

    r18587 r18619  
    8686my (undef, $extname, $extver, $req_name) = split " ", $fields_output;
    8787
     88die "$req_file is missing one of EXTNAME EXTVER or QUERY_ID"
     89    if !(defined($extname) and defined($extver) and defined($req_name));
     90
    8891die "$req_file has EXTNAME $extname not MOPS_DETECTABILITY_QUERY table"
    8992                if $extname ne         "MOPS_DETECTABILITY_QUERY";
    90 die "$req_file does not have a QUERY_ID" if ! $req_name;
    9193die "$req_file is version $extver expecting 1" if $extver ne 1;
    9294
     
    130132        $job_id = join "", @$stdout_buf;
    131133        chomp $job_id;
     134        if ($job_id && -e $response_file) {
     135            rename $response_file, "$out_dir/response${job_id}.fits";
     136        }
    132137        $result = 0;
    133138    } else {
     
    136141    }
    137142}
     143
    138144
    139145{
Note: See TracChangeset for help on using the changeset viewer.