IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 9, 2014, 6:17:18 PM (12 years ago)
Author:
watersc1
Message:

These have been tested and seem to work correctly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/sc_prepare_chip.pl

    r36596 r36844  
    1919# Hard coded values
    2020my $remote_root   = '/scratch3/watersc1/';  # Far side destination base location
     21my $remote_raw    = "${remote_root}/raw/";  # Directory to find raw data in.
    2122my $threads       = 2;                      # How many threads are we going to use?
    2223my $job_cost      = 150 / 60 / 60;          # Estimate of how long a job runs, in hours.
     
    150151#print Dumper(%detrends);
    151152
     153my @return_component_list = ("DBINFO.IMFILE","PPIMAGE.STATS","LOG.IMFILE","TRACE.IMFILE","PPIMAGE.BACKMDL","PPIMAGE.PATTERN");
    152154
    153155#
     
    157159my $uri_check   = $path_base . ".check";
    158160my $uri_config  = $path_base . ".config";
     161my $uri_generate= $path_base . ".generate";
     162my $uri_return  = $path_base . ".return";
    159163
    160164my $disk_command = $ipprc->file_resolve($uri_command,1);
     
    162166my $disk_check   = $ipprc->file_resolve($uri_check,1);
    163167my $disk_config  = $ipprc->file_resolve($uri_config,1);
     168my $disk_generate= $ipprc->file_resolve($uri_generate,1);
     169my $disk_return  = $ipprc->file_resolve($uri_return,1);
    164170
    165171my (undef, $remote_config) = uri_convert($uri_config); # Needs to be done after we've created it.
     
    168174open(CHECK,    ">$disk_check")  || &my_die("Couldn't open file? $disk_check",$chip_id,$PS_EXIT_SYS_ERROR);
    169175open(CONFIG,   ">$disk_config")  || &my_die("Couldn't open file? $disk_config",$chip_id,$PS_EXIT_SYS_ERROR);
     176open(GENERATE, ">$disk_generate") || &my_die("Couldn't open file? $disk_generate",$chip_id,$PS_EXIT_SYS_ERROR);
     177open(RETURN,   ">$disk_return") || &my_die("Couldn't open file? $disk_return", $chip_id, $PS_EXIT_SYS_ERROR);
     178
    170179
    171180#
     
    185194   
    186195    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    187         run(command => $command, verbose => $verbose);
     196        run(command => $command, verbose => 0);
    188197    unless ($success) {
    189198        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     
    254263   
    255264    my $chipData = $mdcParser->parse(join "", @$stdout_buf) or
    256         &my_die("Unable to parse chiptool -pendingimfile information.",
    257                 $chip_id,$error_code);
     265        next;
     266#       &my_die("Unable to parse chiptool -pendingimfile information.",
     267#               $chip_id,$error_code);
    258268    my $chipData2= parse_md_list($chipData);
    259269
     
    270280       
    271281        # Process the image and burntool table
    272         my (undef,$remote_uri) = uri_to_outputs($uri);
     282        my ($ipp_uri,$remote_uri) = uri_to_outputs_raw($uri);
    273283        my $btt = $uri;
    274284        $btt =~ s/fits$/burn.tbl/;
    275         my (undef,$remote_btt) = uri_to_outputs($btt);
     285        my ($ipp_btt,$remote_btt) = uri_to_outputs_raw($btt);
    276286       
    277287        # Initialize the ppI command
     
    287297            my $det_code = $det_types{$det};
    288298            my $duri = $detrends_to_use{$det}->{$class_id};
    289             my (undef, $remote_det_uri) = uri_to_outputs($duri);
     299            my ($ipp_det_uri, $remote_det_uri) = uri_to_outputs_raw($duri);
    290300            $ppImage_command .= " $det_code $remote_det_uri ";
    291301        }
     
    310320        $ppImage_command .= " -log ${remote_outroot}.${class_id}.log ";
    311321
    312         push @main_commands, $ppImage_command;
     322#       push @main_commands, $ppImage_command;
    313323
    314324        # Calculate pre and post commands
    315325        my $remote_outroot_dir = dirname($remote_outroot);
    316         push @pre_commands, "mkdir -p $remote_outroot_dir";
     326        my $pre_command = "mkdir -p $remote_outroot_dir";
    317327       
    318328        my $post_commandA = "chiptool -addprocessedimfile -exp_id $exp_id -chip_id $chip_id -class_id $class_id ";
     
    321331        $post_commandA   .= " -dbname $dbname " if defined $dbname;
    322332
    323         my $post_commandB = "echo -n $post_commandA > ${remote_outroot}.${class_id}.dbinfo && ";
     333        my $post_commandB = "echo -n \"$post_commandA\" > ${remote_outroot}.${class_id}.dbinfo ";
    324334        my $post_commandC = "ppStatsFromMetadata ${remote_outroot}.${class_id}.stats - CHIP_IMFILE >> ${remote_outroot}.${class_id}.dbinfo";
    325335       
    326         push @post_commands, "$post_commandB $post_commandC";
     336#       push @post_commands, "$post_commandB $post_commandC";
    327337
    328338        $job_index++;
     339
     340        print CONFIG "${pre_command} && ${ppImage_command} && ${post_commandB} && ${post_commandC}";
     341
     342
     343        # Determine which output files need to be returned.
     344        foreach my $component (@return_component_list) {
     345#           uri_convert_and_create( $ipprc->filename($component, $ipp_outroot, $class_id) );
     346            my $filename = $ipprc->filename($component, $ipp_outroot, $class_id);
     347            my ($ipp_disk, $remote_disk) = uri_to_outputs_for_return( $filename );
     348            my $remote_outroot_dir = dirname($ipp_disk);
     349            print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} ";
     350#           print "  $filename $ipp_disk $remote_disk\n";
     351#           die;
     352        }
     353
     354        print CONFIG "\n";
    329355    }
    330356}
    331357
    332358# Actually put the commands into the output file.
    333 my %unique_cmds = ();
    334 foreach my $cmd (@pre_commands) {
    335     unless(exists($unique_cmds{$cmd})) {
    336         print CONFIG $cmd . "\n";
    337         $unique_cmds{$cmd} = 1;
    338     }
    339 }
    340 foreach my $cmd (@main_commands) {
    341     unless(exists($unique_cmds{$cmd})) {
    342         print CONFIG $cmd . "\n";
    343         $unique_cmds{$cmd} = 1;
    344     }
    345 }
    346 foreach my $cmd (@post_commands) {
    347     unless(exists($unique_cmds{$cmd})) {
    348         print CONFIG $cmd . "\n";
    349         $unique_cmds{$cmd} = 1;
    350     }
    351 }
     359# my %unique_cmds = ();
     360# foreach my $cmd (@pre_commands) {
     361#     unless(exists($unique_cmds{$cmd})) {
     362#       print CONFIG $cmd . "\n";
     363#       $unique_cmds{$cmd} = 1;
     364#     }
     365# }
     366# foreach my $cmd (@main_commands) {
     367#     unless(exists($unique_cmds{$cmd})) {
     368#       print CONFIG $cmd . "\n";
     369#       $unique_cmds{$cmd} = 1;
     370#     }
     371# }
     372# foreach my $cmd (@post_commands) {
     373#     unless(exists($unique_cmds{$cmd})) {
     374#       print CONFIG $cmd . "\n";
     375#       $unique_cmds{$cmd} = 1;
     376#     }
     377# }
    352378
    353379close(CONFIG);
    354380close(TRANSFER);
    355381close(CHECK);
     382close(RETURN);
     383close(GENERATE);
    356384
    357385#
     
    425453}
    426454
     455sub uri_convert_and_create {
     456    my $neb_uri = shift;
     457    my $ipp_disk= $ipprc->file_resolve( $neb_uri , 1);
     458    my $remote_disk = $ipp_disk;
     459   
     460    unless(defined($ipp_disk)) {
     461        my_die();
     462    }
     463
     464    $remote_disk =~ s%^.*/%%;   # Remove nebulous path
     465    $remote_disk =~ s%^\d+\.%%; # Remove ins_id
     466    $remote_disk =~ s%:%/%g;    # Replace colons with directories
     467    $remote_disk = "${remote_root}/${remote_disk}";
     468    return($ipp_disk,$remote_disk);
     469}
     470
    427471sub uri_to_outputs {
    428472    my $neb_uri = shift;
     
    433477        print TRANSFER "$ipp_disk\n";
    434478        print CHECK    "$remote_disk\n";
     479    }
     480    return($ipp_disk,$remote_disk);
     481}
     482
     483sub uri_to_outputs_raw {
     484    my $neb_uri = shift;
     485    my ($ipp_disk, $remote_disk) = uri_convert( $neb_uri );
     486    $remote_disk = $remote_raw . $ipp_disk;
     487    unless (exists($file_filter{$neb_uri})) {
     488        $file_filter{$neb_uri} = 1;
     489        print TRANSFER "$ipp_disk\n";
     490        print CHECK    "$remote_disk\n";
     491    }
     492    return($ipp_disk,$remote_disk);
     493}
     494
     495sub uri_to_outputs_for_return {
     496    my $neb_uri = shift;
     497    my ($ipp_disk, $remote_disk) = uri_convert_and_create( $neb_uri );
     498    unless (exists($file_filter{$neb_uri})) {
     499        $file_filter{$neb_uri} = 1;
     500        print RETURN "$ipp_disk\n";
     501        print GENERATE "$remote_disk\n";
    435502    }
    436503    return($ipp_disk,$remote_disk);
Note: See TracChangeset for help on using the changeset viewer.