IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 6, 2009, 5:44:55 PM (17 years ago)
Author:
bills
Message:

Create stamps in workdir area instead of the data store product directory
various changes to improve logging

File:
1 edited

Legend:

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

    r21190 r21410  
    1414use File::Temp qw( tempfile );
    1515use File::Copy;
     16use File::Basename qw(dirname);
    1617
    1718use PS::IPP::Metadata::Config;
     
    2324use PStamp::Job qw( :standard );
    2425
    25 my ( $req_id, $req_name, $req_file, $product, $dbname, $verbose, $save_temps );
     26my ( $req_id, $req_name, $req_file, $out_dir, $product, $dbname, $verbose, $save_temps, $redirect_output);
    2627
    2728# the char to the right of the bar may be used as a single - alias for the longer name
    2829# for example --input and -i are equivalent
    2930GetOptions(
    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,
    3740) or pod2usage( 2 );
    3841
    3942pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    4043
    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;
     44die "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
     47my $ipprc = PS::IPP::Config->new(); # IPP Configuration
     48
     49if ($redirect_output) {
     50    my $logDest = "$out_dir/psfinish.$req_id.log";
     51    $ipprc->redirect_output($logDest);
     52}
    4353
    4454my $missing_tools;
     
    5363}
    5464
    55 my $ipprc = PS::IPP::Config->new(); # IPP Configuration
    5665
    5766my $outputDataStoreRoot = metadataLookupStr($ipprc->{_siteConfig}, 'DATA_STORE_ROOT');
     
    6473    my $fileset = $req_name;
    6574
     75
    6676    # Here we invoke the assumption that the output for the request is placed in the
    6777    # 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
    6982
    7083    print STDERR "product: $product  REQ_NAME: $req_name $out_dir\n" if $verbose;
     
    7285    if (!-e $out_dir) {
    7386        # something must have gone wrong parsing the request
    74         print STDERR  "output fileset directory $out_dir does not exist\n";
     87        print STDERR  "output directory $out_dir does not exist\n";
    7588
    7689        if (!mkdir $out_dir) {
     
    8396        # XXX TODO: fault the request so we pstamp_finish doesn't keep trying to process the
    8497        # request
    85         print STDERR "output fileset directory $out_dir exists but is not a directory";
     98        print STDERR "output directory $out_dir exists but is not a directory";
    8699        stop_request($req_id, $PS_EXIT_UNKNOWN_ERROR, $dbname);
    87100    }
     
    111124    print $rlf "results.fits|||table|\n";
    112125
    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" ) {
    116128        print $rlf "$err_file|||text|\n";
    117129    }
     
    222234    if (!$request_fault) {
    223235        # 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 directory
    226         # to the fileset directory at parse time
    227236        my $command = "$dsreg --list $reglist_name --add $fileset --product $product --type PSRESULTS";
     237        $command .= " --link --datapath $out_dir";
    228238        $command .= " --dbname $dbname" if $dbname;
    229239
Note: See TracChangeset for help on using the changeset viewer.