IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37833


Ignore:
Timestamp:
Jan 12, 2015, 12:53:36 PM (11 years ago)
Author:
eugene
Message:

merging changes from ipp-pv3-20140717 (via branches/eam_branches/ipp-pv3-20140717-merge)

Location:
trunk
Files:
27 edited
8 copied

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/Build.PL

    r37315 r37833  
    138138        scripts/stack_bkg_mk_mdc.pl
    139139        scripts/sc_mk_stack_mdc.pl
     140        scripts/sc_mk_staticsky_mdc.pl
    140141        scripts/sc_prepare_camera.pl
    141142        scripts/sc_prepare_chip.pl
    142143        scripts/sc_prepare_stack.pl
     144        scripts/sc_prepare_staticsky.pl
    143145        scripts/sc_prepare_warp.pl
     146        scripts/sc_prepare_run.pl
    144147        scripts/sc_remote_exec.pl
     148        scripts/sc_remote_poll.pl
     149        scripts/sc_retry_return.pl
    145150        scripts/sc_transfer_tool.pl
    146151    )],
  • trunk/ippScripts/MANIFEST

    r37315 r37833  
    5151scripts/regenerate_background.pl
    5252scripts/sc_mk_stack_mdc.pl
     53scripts/sc_mk_staticsky_mdc.pl
    5354scripts/sc_prepare_camera.pl
    5455scripts/sc_prepare_chip.pl
    5556scripts/sc_prepare_stack.pl
     57scripts/sc_prepare_staticsky.pl
    5658scripts/sc_prepare_warp.pl
    5759scripts/sc_remote_exec.pl
  • trunk/ippScripts/scripts

  • trunk/ippScripts/scripts/dist_defineruns.pl

    r37120 r37833  
    9090    push @stages, $stage;
    9191} else {
    92     @stages = qw(chip chip_bg camera fake warp warp_bg diff stack SSdiff sky skysingle skycal ff);
     92    @stages = qw(chip chip_bg camera fake warp warp_bg diff stack SSdiff sky skysingle ff);
    9393}
    9494
  • trunk/ippScripts/scripts/lap_science.pl

    r37812 r37833  
    3434my $qstack_threshold     = 0.05; # Only make a quickstack if more than 5% of the exposures require it.
    3535my $minimum_stack_inputs = 2;    # We can avoid magicking stack inputs if we have more than this number.
    36 my $maximum_stack_inputs = 25;   # This is the place-holder guess on how big a stack we should process locally
     36my $maximum_stack_inputs = 25;   # This is the place-holder guess on how big a stack we should process locally.  25 is the best guess.
    3737my $do_updates_pv2       = 0;    # Do updates using the calls needed for PV2. 
    3838
     
    10581058    unless ($success) {
    10591059        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    1060         &my_die("Unable to perform stacktool -definebyquery: $error_code", $lap_id);
     1060        &my_die("Unable to perform stacktool -definebyquery: $error_code :: $command", $lap_id);
    10611061    }
    10621062    my $stacks_made = $mdcParser->parse_list(join "", @$stdout_buf) or
     
    10661066    ## Queue the "deep" stacks that will run locally.
    10671067    my $deep_minimum = $maximum_stack_inputs + 1;
     1068    if ($deep_minimum < 2) { $deep_minimum = 2; }
    10681069    $command = "$stacktool ";
    10691070    $command .= " -pretend " if defined $debug;
     
    10791080    unless ($success) {
    10801081        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    1081         &my_die("Unable to perform stacktool -definebyquery: $error_code", $lap_id);
    1082     }
    1083     my $stacks_made_deep .= $mdcParser->parse_list(join "", @$stdout_buf) or
     1082        &my_die("Unable to perform stacktool -definebyquery: $error_code :: $command", $lap_id);
     1083    }
     1084    my $stacks_made_deep = $mdcParser->parse_list(join "", @$stdout_buf) or
    10841085        &my_die("unable to parse metadata from stacktool -definebyquery", $lap_id, "");   
    10851086
    10861087    # Append deep stacks to stacks so we can get a complete count later.
    1087     push @{ $stacks_made}, @{ $stacks_made_deep };
     1088    push @{ $stacks_made }, @{ $stacks_made_deep };
    10881089   
    10891090    ## Determine the sass_id so we can record it in the database.
     
    14491450
    14501451    my @clean_modes = (
    1451 #       'chiptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -chip_id @CHIP_ID@',
     1452        'chiptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -chip_id @CHIP_ID@',
    14521453#       'warptool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -warp_id @WARP_ID@',
    14531454        'difftool -dbname @DBNAME@ -updaterun -set_state goto_cleaned -set_label goto_cleaned -label @LABEL@ -diff_id @DIFF_ID@',
  • trunk/ippScripts/scripts/permcheck.pl

    r37594 r37833  
    6262if ($stage eq 'warp') { # These things are destined to have their only copy on the stsciXX nodes.
    6363    %backup_hosts = ('stsci00' => 1, 'stsci01' => 1, 'stsci02' => 1,
    64                      'stsci03' => 1, 'stsci04' => 1, 'stsci05' => 1, 'stsci06' => 1,
     64                     #'stsci03' => 1,
     65                     'stsci04' => 1, 'stsci05' => 1, 'stsci06' => 1,
    6566                     'stsci07' => 1, 'stsci08' => 1, 'stsci09' => 1,
    6667                     'stsci10' => 1, 'stsci11' => 1, 'stsci12' => 1,
  • trunk/ippScripts/scripts/queuestaticsky.pl

  • trunk/ippScripts/scripts/sc_mk_stack_mdc.pl

    r36844 r37833  
    11#! /usr/bin/env perl                                                                                                                                                       
    2 
    32use Carp;
    43use warnings;
    54use strict;
    65
     6use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     7use Pod::Usage qw( pod2usage );
     8
     9
     10my $remote_root = '/scratch3/watersc1/';
     11
     12my ($compmap_file);
     13GetOptions(
     14    'compmap=s'   => \$compmap_file,
     15    ) or pod2usage( 2 );
     16
     17pod2usage( -msg => "Required options: --compmap", -exitval => 3) unless
     18    defined($compmap_file);
     19
     20my %component_map = ();
     21open(CM,$compmap_file) || die "Cannot find requested compmap file";
     22while(<CM>) {
     23    chomp;
     24    my ($symbolic_name,$disk_name) = split /\s+/;
     25    $component_map{$symbolic_name} = $disk_name;
     26}
     27close(CM);
     28
    729my $counter = 0;
    830
    931foreach my $path_base (@ARGV) {
    10     print "INPUT${counter}  METADATA\n";
    11     print "   IMAGE           STR     ${path_base}.fits\n";
    12     print "   MASK            STR     ${path_base}.mask.fits\n";
    13     print "   VARIANCE        STR     ${path_base}.wt.fits\n";
    14     print "   PSF             STR     ${path_base}.psf\n";
    15     print "   SOURCES         STR     ${path_base}.cmf\n";
    16     print "   BKGMODEL        STR     ${path_base}.mdl.fits\n";
    17     print "END\n\n";
     32    my $mdc_content = "";
     33    my $file = "";
     34    my $error = 0;
     35
     36#   print "PB: $path_base\n";
     37
     38    #header
     39    $mdc_content .= "INPUT${counter}  METADATA\n";
     40
     41    # check each file against its possible locations, incrementing the error counter if not found
     42    $file = do_checks("${path_base}.fits",$error);
     43    $mdc_content .=  "   IMAGE           STR     $file\n";
     44
     45    $file = do_checks("${path_base}.mask.fits",$error);
     46    $mdc_content .=  "   MASK            STR     $file\n";
     47
     48    $file = do_checks("${path_base}.wt.fits",$error);
     49    $mdc_content .=  "   VARIANCE        STR     $file\n";
     50   
     51    $file = do_checks("${path_base}.psf",$error);
     52    $mdc_content .=  "   PSF             STR     $file\n";
     53   
     54    $file = do_checks("${path_base}.cmf",$error);
     55    $mdc_content .=  "   SOURCES         STR     $file\n";
     56
     57    # This is static, and isn't used by ppStack, but I believe needs to exist in the mdc. 2014-08-28 czw
     58    $mdc_content .=  "   BKGMODEL        STR     ${path_base}.mdl.fits\n";
     59    $mdc_content .=  "END\n\n";
     60#    print "MDC: $mdc_content\n";
     61    # If we had no errors, print it and move on.
     62    if ($error == 0) {
     63        print $mdc_content;
     64    }
     65
    1866    $counter++;
    1967}
     68
     69sub do_checks {
     70    my ($cfile,$error) = @_;
     71#    print  ">$cfile<\n";
     72    if (! ((-e $cfile)&&(-s $cfile))) { # This cfile does not exist or is zero size.
     73        my $disk = $component_map{$cfile};
     74        $cfile = "${disk}";
     75        if (! ((-e $cfile)&&(-s $cfile))) { # The other expected cfile did not exist.
     76#           $cfile = '';
     77            $error++;
     78            die "Missing cfile $cfile!";
     79        }
     80    }
     81    return($cfile);
     82}
     83   
  • trunk/ippScripts/scripts/sc_prepare_camera.pl

    r37125 r37833  
    11#! /usr/bin/env perl
     2
     3# generate the input & output files lists and commands for a single camRun
    24
    35use Carp;
     
    1618use Pod::Usage qw( pod2usage );
    1719
    18 
    1920# Hard coded values
    20 # my $remote_root   = '/scratch3/watersc1/';  # Far side destination base location
    21 my $remote_root   = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
    22 $remote_root = '/scratch3/watersc1/';
    23 my $threads       = 2;                      # How many threads are we going to use?
    24 my $job_cost      = 1700 / 60 / 60;         # Estimate of how long a job runs, in hours.
    25 my $proc_per_node = 24;                     # processors per node
    26 my $min_nodes     = 1;                      # smallest allocation to ask for
    27 my $max_nodes     = 1000;                   # largest allocation to ask for
    28 my $min_time      = 1;                      # shortest allocation to ask for
    29 my $max_time      = 8;                      # longest allocation to ask for
    30 my $remote_hostname= "LANL/Mustang";         # Name of the remote node.
    31 my @return_component_list = ("DBINFO.EXP", "PSASTRO.CONFIG", "PSASTRO.OUTPUT", "LOG.EXP", "PSASTRO.STATS");
     21# my $remote_root   = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
     22my $remote_root     = '/scratch3/watersc1/';  # Far side destination base location
     23my $remote_hostname = "LANL/Mustang";         # Name of the remote node.
     24my $threads_req     = 0;                      # How many threads are we going to use?
     25
     26my $fail_state = "prep_fail";
     27
    3228# Look for programs we need
    3329my $missing_tools;
    34 
    3530my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1);
    3631my $camtool    = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);
     
    4136}
    4237
    43 my ($remote_id,$cam_id,,$camera,$dbname,$verbose,$path_base,$no_update);
     38my ($remote_id,$cam_id,$camera,$dbname,$verbose,$path_base,$no_update);
    4439GetOptions(
    4540    'remote_id=s'    => \$remote_id,
     41    'cam_id=s'       => \$cam_id,
    4642    'camera|c=s'     => \$camera,
    4743    'dbname|d=s'     => \$dbname,
     
    5248
    5349pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    54 pod2usage( -msg => "Required options: --remote_id --camera --dbname --path_base", -exitval => 3) unless
     50pod2usage( -msg => "Required options: --remote_id --cam_id --camera --dbname --path_base", -exitval => 3) unless
    5551    defined($remote_id) and
     52    defined($cam_id) and
    5653    defined($camera) and
    5754    defined($path_base) and
    5855    defined($dbname);
    59 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id);
     56
     57my $ipprc = PS::IPP::Config->new( $camera ) or &my_die( "Unable to set up", $remote_id, $cam_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
    6058
    6159my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    6260
    63 #
    64 # Step 1: Get a list of the components that make up this remoteRun
    65 
    66 # SHould this call listrun to ensure we're in state new?
    67 my $rt_cmd = "$remotetool -listcomponent -remote_id $remote_id";
    68 $rt_cmd   .= " -dbname $dbname " if defined($dbname);
    69 
    70 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    71     run(command => $rt_cmd, verbose => $verbose);
    72 unless ($success) {
    73     $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    74     &my_die("Unable to run remotetool to determine stage parameters.",
    75             $remote_id,$error_code);
    76 }
    77 my $compData = $mdcParser->parse(join "", @$stdout_buf) or
    78     &my_die("Unable to determine component information.",
    79             $remote_id,$PS_EXIT_PROG_ERROR);
    80 my $compData2= parse_md_list($compData);
    81 
    82 #
    83 # Step 1b: Open output files
    84 my $uri_command = $path_base . ".cmd";
     61my @return_component_list = ("DBINFO.EXP", "PSASTRO.CONFIG", "PSASTRO.OUTPUT", "LOG.EXP", "PSASTRO.STATS");
     62
     63# STEP 0: Open output files
    8564my $uri_transfer= $path_base . ".transfer";
    8665my $uri_check   = $path_base . ".check";
     
    8968my $uri_return  = $path_base . ".return";
    9069
    91 my $disk_command = $ipprc->file_resolve($uri_command,1);
    9270my $disk_transfer= $ipprc->file_resolve($uri_transfer,1);
    9371my $disk_check   = $ipprc->file_resolve($uri_check,1);
     
    9674my $disk_return  = $ipprc->file_resolve($uri_return,1);
    9775
    98 my (undef, $remote_config) = uri_convert($uri_config); # Needs to be done after we've created it.
    99 
    100 open(TRANSFER, ">$disk_transfer")  || &my_die("Couldn't open file? $disk_transfer",$remote_id,$PS_EXIT_SYS_ERROR);
    101 open(CHECK,    ">$disk_check")  || &my_die("Couldn't open file? $disk_check",$remote_id,$PS_EXIT_SYS_ERROR);
    102 open(CONFIG,   ">$disk_config")  || &my_die("Couldn't open file? $disk_config",$remote_id,$PS_EXIT_SYS_ERROR);
    103 open(GENERATE, ">$disk_generate") || &my_die("Couldn't open file? $disk_generate",$remote_id,$PS_EXIT_SYS_ERROR);
    104 open(RETURN,   ">$disk_return") || &my_die("Couldn't open file? $disk_return", $remote_id, $PS_EXIT_SYS_ERROR);
     76my (undef, $remote_config) = &uri_convert($uri_config); # Needs to be done after we've created it.
     77
     78open(TRANSFER, ">$disk_transfer")  || &my_die("Couldn't open file? $disk_transfer",$remote_id, $cam_id, $PS_EXIT_SYS_ERROR, $fail_state);
     79open(CHECK,    ">$disk_check")     || &my_die("Couldn't open file? $disk_check",   $remote_id, $cam_id, $PS_EXIT_SYS_ERROR, $fail_state);
     80open(CONFIG,   ">$disk_config")    || &my_die("Couldn't open file? $disk_config",  $remote_id, $cam_id, $PS_EXIT_SYS_ERROR, $fail_state);
     81open(GENERATE, ">$disk_generate")  || &my_die("Couldn't open file? $disk_generate",$remote_id, $cam_id, $PS_EXIT_SYS_ERROR, $fail_state);
     82open(RETURN,   ">$disk_return")    || &my_die("Couldn't open file? $disk_return",  $remote_id, $cam_id, $PS_EXIT_SYS_ERROR, $fail_state);
    10583my %file_filter = ();
    10684
    107 #
    108 # Step 2: Iterate over all componenets in this remote run.
    10985my $job_index = 0;
    110 my @pre_commands = ();
    111 my @main_commands = ();
    112 my @post_commands = ();
    113 
    114 foreach my $compEntry (@$compData2) {
    115     my $cam_id = $compEntry->{stage_id};
    116 
    117 # Get exposure level information from the camRun we're working from.
    118    
     86
     87# STEP 1: Get exposure level information for this camRun
     88my ($workdir,$exp_tag,$reduction);
     89{
    11990    my $command = "$camtool -pendingexp -cam_id $cam_id ";
    12091    $command   .= " -dbname $dbname " if defined($dbname);
    121    
     92
    12293    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    12394        run(command => $command, verbose => 0);
    12495    unless ($success) {
    12596        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    126        
    127         &my_die("Unable to run camtool to determine stage parameters.",
    128                 $cam_id,$error_code);
    129     }
    130 
    131     my $camData = $mdcParser->parse(join "", @$stdout_buf) or
    132         &my_die("Unable to determine cam component information.",
    133                 $cam_id,$PS_EXIT_PROG_ERROR);
    134     my $camData2= parse_md_list($camData);
    135     my $camEntry = ${ $camData2 }[0];
    136    
    137     my $workdir = $camEntry->{workdir};
    138     my $exp_tag = $camEntry->{exp_tag};
     97
     98        &my_die("Unable to run camtool to determine stage parameters.", $remote_id, $cam_id, $error_code, $fail_state);
     99    }
     100
     101    my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or
     102        &my_die("Unable to determine cam component information.", $remote_id, $cam_id, $PS_EXIT_PROG_ERROR, $fail_state);
     103    my $metadata = parse_md_list($MDlist);
     104    my $camEntry = $metadata->[0];
     105
     106    $workdir   = $camEntry->{workdir};
     107    $exp_tag   = $camEntry->{exp_tag};
     108    $reduction = $camEntry->{reduction};
     109    $reduction = 'DEFAULT' unless defined $reduction;
    139110    unless (defined($workdir)) {
    140         while( my ($k, $v) = each %$camEntry ) {
    141             print "key: $k, value: $v.\n";
    142         }
    143 
    144         print "%{ $camEntry }\n";
    145         die;
    146     }
    147     my $ipp_outroot = "${workdir}/${exp_tag}/${exp_tag}.cm.${cam_id}";
    148     my $remote_outroot = uri_local_to_remote($ipp_outroot);
    149 
    150 
    151 #
     111        while( my ($k, $v) = each %$camEntry ) {
     112            print "key: $k, value: $v.\n";
     113        }
     114        print "%{ $camEntry }\n";
     115        die;
     116    }
     117}
     118
     119my $ipp_outroot = "${workdir}/${exp_tag}/${exp_tag}.cm.${cam_id}";
     120my $remote_outroot = uri_local_to_remote($ipp_outroot);
     121
    152122# Step 3: Iterate over the sub-components
    153 
    154     my $reg_command = "$camtool -pendingimfile -cam_id $cam_id ";
    155     $reg_command   .= " -dbname $dbname " if defined($dbname);
    156 
    157     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    158         run(command => $reg_command, verbose => 0);
     123{
     124    my $command = "$camtool -pendingimfile -cam_id $cam_id ";
     125    $command   .= " -dbname $dbname " if defined($dbname);
     126
     127    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     128        run(command => $command, verbose => 0);
    159129    unless ($success) {
    160         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    161         &my_die("Unable to run camtool -pendingimfile ",
    162                 $cam_id,$error_code);
    163     }
    164    
     130        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     131        &my_die("Unable to run camtool -pendingimfile ", $remote_id, $cam_id, $error_code, $fail_state);
     132    }
    165133
    166134    # We don't actually care about the input cam data other than to know which mask files to instantiate.
    167     my $inpData = $mdcParser->parse(join "", @$stdout_buf) or
    168         &my_die("Unable to determine cam component information.",
    169                 $cam_id, $PS_EXIT_PROG_ERROR);
    170     my $inpData2=parse_md_list($inpData);
    171     my $chipProto= ${ $inpData2 }[0];
     135    my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or
     136        &my_die("Unable to determine cam component information.", $remote_id, $cam_id, $PS_EXIT_PROG_ERROR, $fail_state);
     137
     138    my $metadata = parse_md_list($MDlist);
     139    my $chipProto = $metadata->[0];
    172140    my $chip_path = $chipProto->{path_base};
    173     my $remote_chip_path = uri_local_to_remote( $chip_path );
     141    my $remote_chip_path = &uri_local_to_remote( $chip_path );
    174142    my $pre_cmd_cmfs = "ls -1 ${remote_chip_path}*.cmf > ${remote_outroot}.cmflist";
    175143    my $pre_cmd_masks= "ls -1 ${remote_chip_path}*.mk.fits > ${remote_outroot}.masklist";
    176144
    177     my $reduction = 'DEFAULT' unless defined $camEntry->{reduction};
    178     my $recipe_psastro = $ipprc->reduction($reduction, 'PSASTRO'); # Recipe to use                                                                         
     145    my $recipe_psastro = $ipprc->reduction($reduction, 'PSASTRO'); # Recipe to use
     146    if ($recipe_psastro eq "") {
     147        &my_die("Unable to determine PSASTRO recipe", $cam_id, $PS_EXIT_PROG_ERROR);
     148    }
    179149
    180150    my $psastro_command = " psastro -list ${remote_outroot}.cmflist ";
    181151    $psastro_command   .= " -masklist ${remote_outroot}.masklist ${remote_outroot} ";
    182 #    $psastro_command   .= " -refmasklist ${remote_outroot}.masklist ${remote_outroot} "; # This is used to do edge calculations.  It should probably be smart enough to know that it can just use the masks I just specified, but it's not.
    183     # Uncomment when remote psastro supports this
     152#   $psastro_command   .= " -refmasklist ${remote_outroot}.masklist ${remote_outroot} ";
     153    $psastro_command   .= " -refmasklist /turquoise/usr/projects/ps1/watersc1/references/gpc1.refmask.list ";
    184154    $psastro_command   .= " -kh-correct /turquoise/usr/projects/ps1/watersc1/references/khcorrect.20140606.v0.fits ";
    185     $psastro_command   .= " -refmasklist /turquoise/usr/projects/ps1/watersc1/references/gpc1.refmask.list ";
    186 #    $psastro_command   .= " -astrommodel /turquoise/usr/projects/ps1/watersc1/references/gpc1.20080909.asm ";
     155#   $psastro_command   .= " -astrommodel /turquoise/usr/projects/ps1/watersc1/references/gpc1.20080909.asm ";
    187156    $psastro_command   .= " -astrommodel /turquoise/usr/projects/ps1/watersc1/references/gpc1.20140505.asm ";
    188157    $psastro_command   .= " -recipe PSASTRO $recipe_psastro ";
     
    190159    $psastro_command   .= " -dumpconfig ${remote_outroot}.psastro.mdc -stats ${remote_outroot}.stats ";
    191160    $psastro_command   .= " -recipe PPSTATS CAMSTATS ";
    192    
     161
    193162    my $camtool_post_cmd = "camtool -cam_id $cam_id -addprocessedexp -uri UNKNOWN ";
    194     $camtool_post_cmd  .=  " -dbname $dbname " if defined $dbname;                                                                                                            $camtool_post_cmd  .=  " -path_base $ipp_outroot -hostname $remote_hostname -dtime_script 0 ";
     163    $camtool_post_cmd  .=  " -dbname $dbname " if defined $dbname;
     164    $camtool_post_cmd  .=  " -path_base $ipp_outroot -hostname $remote_hostname -dtime_script 0 ";
    195165    my $post_cmd_echo = " echo -n \"$camtool_post_cmd\" > ${remote_outroot}.dbinfo ";
    196166    my $post_cmd_SfM  = " ppStatsFromMetadata ${remote_outroot}.stats - CAMERA_EXP_FPA >> ${remote_outroot}.dbinfo ";
     
    201171    # Determine which output files need to be returned
    202172    foreach my $component(@return_component_list) {
    203         my $filename = $ipprc->filename($component,$ipp_outroot);
    204         my ($ipp_disk, $remote_disk) = uri_to_outputs_for_return( $filename);
    205         my $remote_outroot_dir = dirname($ipp_disk);
    206         print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk ";
    207     }
    208     foreach my $chipInfo (@{ $inpData2 }) {
    209         my $filename = $ipprc->filename("PSASTRO.OUTPUT.MASK",$ipp_outroot,$chipInfo->{class_id});
    210         my ($ipp_disk, $remote_disk) = uri_to_outputs_for_return( $filename);
    211         my $remote_outroot_dir = dirname($ipp_disk);
    212         print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk ";
     173        my $filename = $ipprc->filename($component,$ipp_outroot);
     174        my ($ipp_disk, $remote_disk) = &uri_to_outputs_for_return( $filename);
     175        my $remote_outroot_dir = dirname($ipp_disk);
     176        print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk ";
     177    }
     178    foreach my $chipInfo (@{ $metadata }) {
     179        my $filename = $ipprc->filename("PSASTRO.OUTPUT.MASK",$ipp_outroot,$chipInfo->{class_id});
     180        my ($ipp_disk, $remote_disk) = &uri_to_outputs_for_return( $filename);
     181        my $remote_outroot_dir = dirname($ipp_disk);
     182        print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk ";
    213183    }
    214184    print CONFIG "\n";
     
    220190close(GENERATE);
    221191
    222 #
    223 # Construct the moab command last, so we can use the job_index counter to estimate resources.  Somehow.
    224 my $proc_need = $job_index * $threads;       # how many total processors do we need?
    225 my $node_need = $proc_need / $proc_per_node; # this equals how many nodes?
    226 my $time_need = $job_index * $job_cost;      # How many seconds will this take?
    227 
    228 my $fill_factor = 0.8;  # This is the factor of how much of the time allocation we'd like to fill
    229 my ($time_req,$node_req);
    230 if ($node_need * $job_cost < $fill_factor * $min_nodes * $min_time) {
    231     $time_req = $min_time;
    232     $node_req = $min_nodes;
    233 }
    234 elsif ($node_need * $job_cost > $fill_factor * $max_nodes * $max_time) {
    235     $time_req = $max_time;
    236     $node_req = $max_nodes;
    237     print STDERR "You've requested the construction of a bundle that appears to need $node_need nodes and $job_cost time per job.  This exceeds the max limits ($max_nodes, $max_time).  Using those max values instead.  Good luck.\n";
    238 }
    239 else {
    240     $time_req = int(($node_need * $job_cost) / ($fill_factor * $max_nodes)) + 1;
    241     $node_req = int(($node_need * $job_cost) / ($fill_factor * $time_req)) + 1;
    242 }
    243 $time_req += 1; # Safety addition.
    244 
    245 open(COMMAND,  ">$disk_command") || &my_die("Couldn't open file? $disk_command",$remote_id,$PS_EXIT_SYS_ERROR);
    246 print COMMAND "#!/bin/tcsh\n";
    247 print COMMAND "##### Moab controll lines\n";
    248 print COMMAND "#MSUB -l nodes=${node_req}:ppn=${proc_per_node},walltime=${time_req}:00:00\n"; ## CHECK RESOURCES
    249 print COMMAND "#MSUB -j oe\n";
    250 print COMMAND "#MSUB -V\n";
    251 print COMMAND "#MSUB -o ${remote_root}cam.${remote_id}.out\n";
    252 print COMMAND "date\n";
    253 print COMMAND 'srun -n $SLURM_JOB_NUM_NODES -m cyclic -l /bin/hostname | sort -n | awk \'{printf "%s\n", $2}\' > hosts.${SLURM_JOB_ID}' . "\n";
    254 print COMMAND "${remote_root}/stask_chip.py $remote_config " . 'hosts.${SLURM_JOB_ID} 1' . "\n";
    255 print COMMAND "date\n";
    256 close(COMMAND);
    257 
    258192unless($no_update) {
    259     my $command = "remotetool -updaterun -remote_id $remote_id ";
    260     $command .= " -set_state pending ";
    261     $command .= " -dbname $dbname " if defined $dbname;
    262 
     193    my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $cam_id ";
     194    $command   .= " -set_jobs $job_index";
     195    $command   .= " -set_path_base $path_base";
     196    $command   .= " -set_state prep_done";
     197    $command   .= " -dbname $dbname " if defined $dbname;
    263198    system($command);
    264199}
    265200
     201exit (0);
    266202
    267203## Common SC routines
     
    271207    my $ipp_disk= $ipprc->file_resolve( $neb_uri );
    272208    my $remote_disk = $ipp_disk;
    273    
     209
    274210    unless(defined($ipp_disk)) {
    275         my_die();
     211        &my_die( "Unable to generate file for $neb_uri ", $remote_id, $cam_id, $PS_EXIT_SYS_ERROR, $fail_state);
    276212    }
    277213
     
    287223    my $ipp_disk= $ipprc->file_resolve( $neb_uri , 1);
    288224    my $remote_disk = $ipp_disk;
    289    
     225
    290226    unless(defined($ipp_disk)) {
    291         my_die();
     227        &my_die( "Unable to generate file for $neb_uri ", $remote_id, $cam_id, $PS_EXIT_SYS_ERROR, $fail_state);
    292228    }
    293229
     
    302238    my $neb_uri = shift;
    303239    my ($ipp_disk, $remote_disk) = uri_convert( $neb_uri );
    304    
     240
    305241    unless (exists($file_filter{$neb_uri})) {
    306242        $file_filter{$neb_uri} = 1;
     
    332268    return($remote_uri);
    333269}
    334  
     270
    335271sub uri_remote_to_local { #(local_neb_uri) = uri_remote_to_local(remote_uri);
    336272    # This needs to replace the remote root directory with the nebulous tag.
     
    338274    $remote_uri =~ s%${remote_root}%%;
    339275    my $local_uri  = "neb:///" . $remote_uri;
    340    
     276
    341277    return($local_uri);
    342278}
     
    345281sub my_die { # exit with status; my_die(message,stage_id,exit_code,exit_status);
    346282    my $msg = shift;
    347     my $id  = shift;
     283    my $remote_id  = shift;
     284    my $stage_id  = shift;
    348285    my $exit_code = shift;
    349286    my $exit_state = shift;
     
    352289
    353290    carp($msg);
    354    
    355     if (defined $id and not $no_update) {
    356         my $command = "remotetool -updaterun -remote_id $id";
    357         $command .= " -fault $exit_code " if defined $exit_code;
     291
     292    if (defined $remote_id and defined $stage_id and not $no_update) {
     293        my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $stage_id";
    358294        $command .= " -set_state $exit_state " if defined $exit_state;
    359295        $command .= " -dbname $dbname " if defined $dbname;
  • trunk/ippScripts/scripts/sc_prepare_chip.pl

    r37125 r37833  
    11#! /usr/bin/env perl
     2
     3# generate the input & output files lists and commands for a single chipRun
    24
    35use Carp;
     
    1618use Pod::Usage qw( pod2usage );
    1719
    18 
    1920# Hard coded values
    20 # my $remote_root   = '/scratch3/watersc1/';  # Far side destination base location
    21 my $remote_root   = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
    22 $remote_root = '/scratch3/watersc1/';
    23 my $remote_raw    = "${remote_root}/raw/";  # Directory to find raw data in.
    24 my $threads       = 2;                      # How many threads are we going to use?
    25 my $job_cost      = 150 / 60 / 60;          # Estimate of how long a job runs, in hours.
    26 my $proc_per_node = 24;                     # processors per node
    27 my $min_nodes     = 1;                      # smallest allocation to ask for
    28 my $max_nodes     = 1000;                   # largest allocation to ask for
    29 my $min_time      = 1;                      # shortest allocation to ask for
    30 my $max_time      = 8;                      # longest allocation to ask for
    31 
    32 # We need to ensure we only ever try to transfer a file once.
    33 my %file_filter = ();
     21# my $remote_root   = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
     22my $remote_root     = '/scratch3/watersc1/';  # Far side destination base location
     23my $remote_hostname = "LANL/Mustang";         # Name of the remote node.
     24my $remote_raw      = "${remote_root}/tmp/";  # Directory to find raw data in.
     25my $threads_req     = 4;
     26
     27my $fail_state = "prep_fail";
     28my $hard_fail_state = "fail";
    3429
    3530# Look for programs we need
    3631my $missing_tools;
    37 my $regtool  = can_run('regtool') or (warn "Can't find regtool" and $missing_tools = 1);
    3832my $chiptool = can_run('chiptool') or (warn "Can't find chiptool" and $missing_tools = 1);
    3933my $detselect= can_run('detselect') or (warn "Can't find detselect" and $missing_tools = 1);
    4034my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1);
     35my $ipp_burntool_fix = can_run('ipp_apply_burntool_fix.pl') or (warn "Can't find ipp_apply_burntool_fix.pl" and $missing_tools = 1);
    4136
    4237if ($missing_tools) {
     
    4641
    4742# Options
    48 my ($exp_id,$exp_name,$remote_id,$chip_id,$detrends,$camera,$dbname,$verbose,$path_base,$no_update);
     43my ($remote_id,$chip_id,$camera,$dbname,$path_base,$no_update,$verbose,$dbverbose);
    4944GetOptions(
    5045    'remote_id=s'    => \$remote_id,
     46    'chip_id=s'      => \$chip_id,
    5147    'camera|c=s'     => \$camera,
    5248    'dbname|d=s'     => \$dbname,
     
    5450    'no_update'      => \$no_update,
    5551    'verbose'        => \$verbose,
     52    'dbverbose'      => \$dbverbose,
    5653    ) or pod2usage( 2 );
    5754
    5855pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    59 pod2usage( -msg => "Required options: --remote_id --camera --dbname --path_base", -exitval => 3) unless
     56pod2usage( -msg => "Required options: --remote_id --chip_id --camera --dbname --path_base", -exitval => 3) unless
    6057    defined($remote_id) and
     58    defined($chip_id) and
    6159    defined($camera) and
    6260    defined($path_base) and
    6361    defined($dbname);
    64 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $exp_id);
     62
     63my $ipprc = PS::IPP::Config->new( $camera ) or &my_die( "Unable to set up", $remote_id, $chip_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
    6564
    6665my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    6766
    68 #
    69 # Step 1: Get a list of the components that make up this remoteRun
    70 
    71 # SHould this call listrun to ensure we're in state new?
    72 my $rt_cmd = "$remotetool -listcomponent -remote_id $remote_id";
    73 $rt_cmd   .= " -dbname $dbname " if defined($dbname);
    74 
    75 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    76     run(command => $rt_cmd, verbose => $verbose);
    77 unless ($success) {
    78     $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    79    
    80     &my_die("Unable to run chiptool to determine stage parameters.",
    81             $remote_id,$error_code);
    82 }
    83 my $compData = $mdcParser->parse(join "", @$stdout_buf) or
    84     &my_die("Unable to determine component information.",
    85             $remote_id,$PS_EXIT_PROG_ERROR);
    86 my $compData2= parse_md_list($compData);
    87 
    88 #
    89 # Step 1a: Load up the catalog of detrends
    90 # Detrend concept holders
    91 my %detrends = ();
    92 my %det_types = ('MASK' => '-mask',
    93                  'FLAT' => '-flat',
    94                  'DARK' => '-dark',
    95                  'VIDEODARK' => '-dark',
    96                  'LINEARITY' => '-linearity',
    97                  'FRINGE'    => '-fringe',
    98                  'NOISEMAP'  => '-noisemap');
    99 
    100 foreach my $det_type (keys (%det_types)) {
    101     my $dt_cmd = "$detselect -show -camera $camera -det_type $det_type ";
    102     $dt_cmd   .= " -dbname $dbname " if defined($dbname);
    103 
    104     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    105         run(command => $dt_cmd, verbose => $verbose);
    106     unless ($success) {
    107         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    108         &my_die("UNable to run detselect to determine detrend catalog",
    109                 $remote_id,$error_code);
    110     }
    111     my $detData = $mdcParser->parse(join "", @$stdout_buf) or
    112         &my_die("Unable to determine detrend information.",
    113                 $remote_id,$PS_EXIT_PROG_ERROR);
    114     my $detData2= parse_md_list($detData);
    115 
    116     # Data structure for this:
    117     # $detrend{NAME} = \@list_of_detselect_shows
    118     # $detrend{NAME}[0] = \%hash_of_detselect_constraint_results (first element)
    119     # $detrend{NAME}[0]{class_id} = uri
    120 
    121     # At this point, I have the list of detselect shows, assign it
    122     $detrends{$det_type} = $detData2;
    123 
    124     for (my $dd = 0; $dd <= $#{ @{ $detrends{$det_type} } }; $dd++) {
    125         my $det_id = ${ $detrends{$det_type} }[$dd]->{det_id};
    126         my $det_iter=${ $detrends{$det_type} }[$dd]->{iteration};
    127 
    128         my $detselect_command2 = "detselect -select ";
    129         $detselect_command2   .= " -det_id $det_id ";
    130         $detselect_command2   .= " -iteration $det_iter ";
    131         $detselect_command2   .= " -dbname $dbname " if defined($dbname);
    132         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    133             run(command => $detselect_command2, verbose => 0);
    134         unless ($success) {
    135             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    136            
    137             &my_die("No valid detrend available for this image: $det_type $det_id $det_iter",
    138                     $chip_id,$error_code);
    139         }
    140        
    141         my $detImfile = $mdcParser->parse(join "", @$stdout_buf) or
    142             &my_die("Could not parse detrend information for this image: $det_type $det_id $det_iter",
    143                     $chip_id,$error_code);
    144         my $detImfile2= parse_md_list($detImfile);
    145         foreach $detImfile (@$detImfile2) {
    146             my $class_id = $detImfile->{class_id};
    147             my $duri = $detImfile->{uri};
    148            
    149             ${ $detrends{$det_type} }[$dd]->{$class_id} = $duri;
    150         }
    151     }
    152 }
    153 
    154 #print Dumper(%detrends);
     67# Detrend concept holders (name, ppImage option)
     68my %det_types = (
     69    'MASK'      => '-mask',
     70    'FLAT'      => '-flat',
     71    'DARK'      => '-dark',
     72    'VIDEODARK' => '-dark',
     73    'LINEARITY' => '-linearity',
     74    'FRINGE'    => '-fringe',
     75    'NOISEMAP'  => '-noisemap'
     76    );
    15577
    15678my @return_component_list = ("DBINFO.IMFILE","PPIMAGE.STATS","LOG.IMFILE","PPIMAGE.BACKMDL","PPIMAGE.PATTERN");
    15779
    158 #
    159 # Step 1b: Open output files
    160 my $uri_command = $path_base . ".cmd";
     80# STEP 0: Open output files
    16181my $uri_transfer= $path_base . ".transfer";
    16282my $uri_check   = $path_base . ".check";
     
    16585my $uri_return  = $path_base . ".return";
    16686
    167 my $disk_command = $ipprc->file_resolve($uri_command,1);
    16887my $disk_transfer= $ipprc->file_resolve($uri_transfer,1);
    16988my $disk_check   = $ipprc->file_resolve($uri_check,1);
     
    17493my (undef, $remote_config) = uri_convert($uri_config); # Needs to be done after we've created it.
    17594
    176 open(TRANSFER, ">$disk_transfer")  || &my_die("Couldn't open file? $disk_transfer",$chip_id,$PS_EXIT_SYS_ERROR);
    177 open(CHECK,    ">$disk_check")  || &my_die("Couldn't open file? $disk_check",$chip_id,$PS_EXIT_SYS_ERROR);
    178 open(CONFIG,   ">$disk_config")  || &my_die("Couldn't open file? $disk_config",$chip_id,$PS_EXIT_SYS_ERROR);
    179 open(GENERATE, ">$disk_generate") || &my_die("Couldn't open file? $disk_generate",$chip_id,$PS_EXIT_SYS_ERROR);
    180 open(RETURN,   ">$disk_return") || &my_die("Couldn't open file? $disk_return", $chip_id, $PS_EXIT_SYS_ERROR);
    181 
    182 
    183 #
    184 # Step 2: Iterate over all componenets in this remote run.
     95open(TRANSFER, ">$disk_transfer")  || &my_die("Couldn't open file? $disk_transfer", $remote_id, $chip_id, $PS_EXIT_SYS_ERROR, $fail_state);
     96open(CHECK,    ">$disk_check")     || &my_die("Couldn't open file? $disk_check",    $remote_id, $chip_id, $PS_EXIT_SYS_ERROR, $fail_state);
     97open(CONFIG,   ">$disk_config")    || &my_die("Couldn't open file? $disk_config",   $remote_id, $chip_id, $PS_EXIT_SYS_ERROR, $fail_state);
     98open(GENERATE, ">$disk_generate")  || &my_die("Couldn't open file? $disk_generate", $remote_id, $chip_id, $PS_EXIT_SYS_ERROR, $fail_state);
     99open(RETURN,   ">$disk_return")    || &my_die("Couldn't open file? $disk_return",   $remote_id, $chip_id, $PS_EXIT_SYS_ERROR, $fail_state);
     100
    185101my $job_index = 0;
    186 my @pre_commands = ();
    187 my @main_commands = ();
    188 my @post_commands = ();
    189 
    190 foreach my $compEntry (@$compData2) {
    191 
    192     my $chip_id = $compEntry->{stage_id};
    193     my $exp_id ;
    194 # Get exposure level information from the chipRun we're working from.
     102
     103# STEP 1 : Get exposure level information for this chipRun
     104my ($exp_id, $filter, $altfilt, $dateobs);
     105{
    195106    my $command = "$chiptool -listrun -chip_id $chip_id ";
    196107    $command   .= " -dbname $dbname " if defined($dbname);
    197    
    198     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    199         run(command => $command, verbose => 0);
     108
     109    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     110        run(command => $command, verbose => $dbverbose);
    200111    unless ($success) {
    201         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    202        
    203         &my_die("Unable to run chiptool to determine stage parameters.",
    204                 $chip_id,$error_code);
    205     }
    206    
    207 # Parse chipRun level data to determine detrend information
    208     my %detrends_to_use = ();
    209     {
    210         my $chipData = $mdcParser->parse(join "", @$stdout_buf) or
    211             &my_die("Unable to determine chip component information.",
    212                     $chip_id,$PS_EXIT_PROG_ERROR);
    213         my $chipData2= parse_md_list($chipData);
    214         my $chipEntry = ${ $chipData2 }[0];
    215        
    216         $exp_id = $chipEntry->{exp_id};   
    217         my $filter = $chipEntry->{filter};
    218         my $altfilt= $filter;
    219         $altfilt =~ s/.00000//;
    220         my $dateobs= $chipEntry->{dateobs};
    221         my ($date, $time) = split /T/, $dateobs;
    222         my ($year,$month,$day) = split /-/, $date;
    223         my ($hour,$minute,$second) = split /:/, $time; #/;
    224         my $dateobs_obj = DateTime->new(year => $year, month => $month, day => $day, hour => $hour, minute => $minute, second => $second);
    225 
    226         foreach my $det_type (%detrends) {
    227             if (($filter !~ /y/)&&($det_type eq 'FRINGE')) { next; } # We can skip fringe for all but y
    228 
    229             foreach my $det_obj (@{ $detrends{$det_type} }) { # Iterate over the available options
    230                 if (defined($det_obj->{filter})) {
    231                     if (($det_obj->{filter} ne $filter)&&($det_obj->{filter} ne $altfilt)) {
    232                         next; # Skip detrends with a filter that we can't use.
    233                     }
    234                 }
    235                 if (defined($det_obj->{time_begin})) {
    236                     if (DateTime->compare($dateobs_obj,$det_obj->{time_begin}) == -1) {
    237                         next; # Skip detrends that come into effect after this exposure (d1 < d2)
    238                     }
    239                 }
    240                 if (defined($det_obj->{time_end})) {
    241                     if (DateTime->compare($dateobs_obj,$det_obj->{time_end}) == 1) {
    242                         next; # Skip detrends that stop working before this exposure (d1 > d2)
    243                     }
    244                 }
    245                 $detrends_to_use{$det_type} = $det_obj;
    246                 last;
     112        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     113
     114        &my_die("Unable to run chiptool to determine stage parameters.", $remote_id, $chip_id, $error_code, $fail_state);
     115    }
     116
     117    # Parse chipRun level data to determine exposure information
     118    my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or
     119        &my_die("Unable to determine chip component information.", $remote_id, $chip_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
     120    my $metadata = parse_md_list($MDlist);
     121    my $chipEntry = $metadata->[0];
     122
     123    $exp_id  = $chipEntry->{exp_id};
     124    $filter  = $chipEntry->{filter};
     125    $altfilt = $filter;
     126    $altfilt =~ s/.00000//;
     127    $dateobs = $chipEntry->{dateobs};
     128}
     129
     130# STEP 2 : select the det_ids for each desired det_type (appropriate to this exposure)
     131my %det_ids = ();
     132my %det_iters = ();
     133
     134foreach my $det_type (keys (%det_types)) {
     135    if (($filter !~ /y/) && ($det_type eq 'FRINGE')) { next; } # We can skip fringe for all but y
     136
     137    my $command = "detselect -search -det_type $det_type -time $dateobs";
     138    $command   .= " -dbname $dbname " if defined($dbname);
     139
     140    if (($det_type eq 'FLAT') || ($det_type eq 'FRINGE')) {
     141        $command .= " -filter $altfilt";
     142    }
     143
     144    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     145        run(command => $command, verbose => $dbverbose);
     146    unless ($success) {
     147        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     148
     149        &my_die("No valid detrend available for this image: $det_type", $remote_id, $chip_id, $error_code, $fail_state);
     150    }
     151
     152    my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or
     153        &my_die("Could not parse detrend information for this image: $det_type", $remote_id, $chip_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
     154    my $metadata = parse_md_list($MDlist);
     155    my $detEntry = $metadata->[0];
     156
     157    if ($verbose) {
     158        print STDERR "det_id: $detEntry->{det_id}\n";
     159        print STDERR "det_iter: $detEntry->{iteration}\n";
     160    }
     161
     162    # save det_id and iteration
     163    $det_ids{$det_type} = $detEntry->{det_id};
     164    $det_iters{$det_type} = $detEntry->{iteration};
     165}
     166
     167# Step 3: Iterate over the sub-components
     168{
     169    # select chipProcessedImfile entries
     170    my $command = "$chiptool -pendingimfile -chip_id $chip_id";
     171    $command   .= " -dbname $dbname "   if defined($dbname);
     172
     173    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     174        run(command => $command, verbose => $dbverbose);
     175
     176    unless ($success) {
     177        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     178
     179        &my_die("Unable to run chiptool -pendingimfile", $remote_id, $chip_id, $error_code, $fail_state);
     180    }
     181
     182    my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or
     183        &my_die("Unable to parse chiptool -pendingimfile information.", $remote_id, $chip_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
     184    my $metadata = parse_md_list($MDlist);
     185
     186    # Iterate over the chipProcessedImfile level data.
     187    foreach my $chipEntry (@$metadata) {
     188        # Get information we need to pass to ppImage
     189        my $uri            = $chipEntry->{uri};
     190        my $class_id       = $chipEntry->{class_id};
     191        my $video_cells    = $chipEntry->{video_cells};
     192        my $reduction      = $chipEntry->{reduction};
     193        my $exp_tag        = $chipEntry->{exp_tag};
     194        my $workdir        = $chipEntry->{workdir};
     195        my $chip_imfile_id = $chipEntry->{chip_imfile_id};
     196
     197        # Process the image and burntool table
     198        # IMAGE CHECK: Look up the image location, prove it exists, and if not, abort the prep for this object.
     199        my ($ipp_uri, $remote_uri) = uri_convert($uri);
     200        unless (-e $ipp_uri) {
     201            # Try to fix it.
     202            system("neb-repair $uri");
     203            ($ipp_uri, $remote_uri) = uri_convert($uri);
     204            unless (-e $ipp_uri) {
     205                # This image file is missing, so it will require manual intervention.
     206                &my_die("Required image file $ipp_uri ($chip_id, $class_id) not found.  Stopping this prep.",
     207                        $remote_id,$chip_id,$PS_EXIT_CONFIG_ERROR,$hard_fail_state);
    247208            }
    248209        }
    249     }
    250 
    251 #
    252 # Step 3: Iterate over the sub-components
    253 # Iterate over the chipProcessedImfile level data.
    254     my $reg_command = "$chiptool -pendingimfile ";
    255     $reg_command   .= " -chip_id $chip_id " if defined($chip_id);
    256     $reg_command   .= " -dbname $dbname "   if defined($dbname);
    257    
    258     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    259         run(command => $reg_command, verbose => $verbose);
    260     unless ($success) {
    261         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    262        
    263         &my_die("Unable to run chiptool -pendingimfile",
    264                 $chip_id,$error_code);
    265     }
    266    
    267     my $chipData = $mdcParser->parse(join "", @$stdout_buf) or
    268         next;
    269 #       &my_die("Unable to parse chiptool -pendingimfile information.",
    270 #               $chip_id,$error_code);
    271     my $chipData2= parse_md_list($chipData);
    272 
    273    
    274     foreach my $chipEntry (@$chipData2) {
    275         # Get information we need to pass to ppImage
    276         my $uri            = $chipEntry->{uri};
    277         my $class_id       = $chipEntry->{class_id};
    278         my $video_cells    = $chipEntry->{video_cells};
    279         my $reduction      = $chipEntry->{reduction};
    280         my $exp_tag        = $chipEntry->{exp_tag};
    281         my $workdir        = $chipEntry->{workdir};
    282         my $chip_imfile_id = $chipEntry->{chip_imfile_id};
    283        
    284         # Process the image and burntool table
    285         my ($ipp_uri,$remote_uri) = uri_to_outputs_raw($uri);
    286         my $btt = $uri;
    287         $btt =~ s/fits$/burn.tbl/;
    288         my ($ipp_btt,$remote_btt) = uri_to_outputs_raw($btt);
    289        
    290         # Initialize the ppI command
    291         my $ppImage_command = "ppImage -file $remote_uri";
    292         $ppImage_command   .= " -burntool $remote_btt ";
    293        
    294         # Add detrend information to the command line
    295         foreach my $det (keys %detrends_to_use) {
    296             if ((($video_cells)&&($det eq 'DARK'))||
    297                 ((!$video_cells)&&($det eq 'VIDEODARK'))) {
    298                 next;
     210
     211        # The image exists, so continue.  This resets the variables, but also outputs the file locations.
     212        ($ipp_uri, $remote_uri) = uri_to_outputs_raw($uri);
     213        my $btt = $uri;
     214        $btt =~ s/fits$/burn.tbl/;
     215
     216        # Check burntool table for existance, and if it doesn't, regenerate it.
     217        my ($ipp_btt, $remote_btt) = uri_convert($btt);
     218        unless (-e $ipp_btt) {
     219            my $exp_name = $chipEntry->{exp_name};
     220            my $burntool_command = "$ipp_burntool_fix --exp_name $exp_name --class_id $class_id";
     221            $burntool_command   .= " -dbname $dbname" if defined($dbname);
     222            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     223                run(command => $burntool_command, verbose => $dbverbose);
     224            # That command repairs the tables, but the instance we learned about may not be correct. 
     225            # Look up the new one.
     226            ($ipp_btt, $remote_btt) = uri_convert($btt);
     227           
     228            unless (-e $ipp_btt) {
     229                &my_die("Attempted regeneration of burntool table ($chip_id, $class_id) has failed.  Stopping this prep.",
     230                        $remote_id,$chip_id, $PS_EXIT_CONFIG_ERROR, $hard_fail_state);
    299231            }
    300             my $det_code = $det_types{$det};
    301             my $duri = $detrends_to_use{$det}->{$class_id};
    302             my ($ipp_det_uri, $remote_det_uri) = uri_to_outputs_raw($duri);
    303             $ppImage_command .= " $det_code $remote_det_uri ";
    304232        }
    305            
    306        
    307         # Add output root
    308         my $ipp_outroot = "${workdir}/${exp_tag}/${exp_tag}.ch.${chip_id}";
    309         my $remote_outroot = uri_local_to_remote($ipp_outroot);
    310         $ppImage_command .= " $remote_outroot ";
    311         print STDERR "$remote_outroot $ipp_outroot $class_id\n";
    312         # Complete reduction information.
    313         $reduction = 'DEFAULT' unless defined $reduction;
    314         my $recipe_ppImage = $ipprc->reduction($reduction, 'CHIP_PPIMAGE'); # Recipe to use for ppImage
    315         my $recipe_psphot  = $ipprc->reduction($reduction, 'CHIP_PSPHOT'); # Recipe to use for psphot
    316        
    317         $ppImage_command .= " -recipe PPIMAGE $recipe_ppImage ";
    318         $ppImage_command .= " -recipe PSPHOT $recipe_psphot ";
    319         $ppImage_command .= " -recipe PPSTATS CHIPSTATS -stats ${remote_outroot}.${class_id}.stats ";
    320         $ppImage_command .= " -threads 4 ";
    321         $ppImage_command .= " -image_id $chip_imfile_id ";
    322         $ppImage_command .= " -tracedest ${remote_outroot}.${class_id}.trace ";
    323         $ppImage_command .= " -log ${remote_outroot}.${class_id}.log ";
    324 
    325 #       push @main_commands, $ppImage_command;
    326 
    327         # Calculate pre and post commands
    328         my $remote_outroot_dir = dirname($remote_outroot);
    329         my $pre_command =  "mkdir -p $remote_outroot_dir";
    330        
    331         my $post_commandA = "chiptool -addprocessedimfile -exp_id $exp_id -chip_id $chip_id -class_id $class_id ";
    332         $post_commandA   .= " -uri ${ipp_outroot}.ch.${class_id}.ch.fits -path_base $ipp_outroot ";
    333         $post_commandA   .= " -magicked 0 -hostname REMOTE -dtime_script 0 ";
    334         $post_commandA   .= " -dbname $dbname " if defined $dbname;
    335 
    336         my $post_commandB = "echo -n \"$post_commandA\" > ${remote_outroot}.${class_id}.dbinfo  ";
    337         my $post_commandC = "ppStatsFromMetadata ${remote_outroot}.${class_id}.stats - CHIP_IMFILE >> ${remote_outroot}.${class_id}.dbinfo";
    338        
    339 #       push @post_commands, "$post_commandB $post_commandC";
    340 
    341         $job_index++;
    342 
    343         print CONFIG "${pre_command} && ${ppImage_command} && ${post_commandB} && ${post_commandC}";
    344 
    345 
    346         # Determine which output files need to be returned.
    347         foreach my $component (@return_component_list) {
    348 #           uri_convert_and_create( $ipprc->filename($component, $ipp_outroot, $class_id) );
    349             my $filename = $ipprc->filename($component, $ipp_outroot, $class_id);
    350             my ($ipp_disk, $remote_disk) = uri_to_outputs_for_return( $filename );
    351             my $remote_outroot_dir = dirname($ipp_disk);
    352             print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk ";
    353 #           print "  $filename $ipp_disk $remote_disk\n";
    354 #           die;
    355         }
    356 
    357         print CONFIG "\n";
    358     }
    359 }
    360 
    361 # Actually put the commands into the output file.
    362 # my %unique_cmds = ();
    363 # foreach my $cmd (@pre_commands) {
    364 #     unless(exists($unique_cmds{$cmd})) {
    365 #       print CONFIG $cmd . "\n";
    366 #       $unique_cmds{$cmd} = 1;
    367 #     }
    368 # }
    369 # foreach my $cmd (@main_commands) {
    370 #     unless(exists($unique_cmds{$cmd})) {
    371 #       print CONFIG $cmd . "\n";
    372 #       $unique_cmds{$cmd} = 1;
    373 #     }
    374 # }
    375 # foreach my $cmd (@post_commands) {
    376 #     unless(exists($unique_cmds{$cmd})) {
    377 #       print CONFIG $cmd . "\n";
    378 #       $unique_cmds{$cmd} = 1;
    379 #     }
    380 # }
     233        ($ipp_btt, $remote_btt) = uri_to_outputs_raw($btt);
     234
     235        # Initialize the ppI command
     236        my $ppImage_command = "ppImage -file $remote_uri";
     237        $ppImage_command   .= " -burntool $remote_btt ";
     238
     239        foreach my $det_type (keys (%det_types)) {
     240            if (( $video_cells) && ($det_type eq 'DARK')) { next; }
     241            if ((!$video_cells) && ($det_type eq 'VIDEODARK')) { next; }
     242
     243            my $det_id   = $det_ids{$det_type};
     244            my $det_iter = $det_iters{$det_type};
     245
     246            if (not defined $det_id) { next; }
     247
     248            if ($verbose) { print STDERR "det_type, det_id, det_iter: $det_type, $det_id, $det_iter\n"; }
     249
     250            # Add detrend information to the command line
     251            my $detselect_command = "detselect -select ";
     252            $detselect_command   .= " -det_id $det_id";
     253            $detselect_command   .= " -iteration $det_iter";
     254            $detselect_command   .= " -class_id $class_id";
     255            $detselect_command   .= " -dbname $dbname " if defined($dbname);
     256
     257            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     258                run(command => $detselect_command, verbose => $dbverbose);
     259
     260            unless ($success) {
     261                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     262
     263                &my_die("No valid detrend available for this image: $det_type $det_id $det_iter", $remote_id, $chip_id, $error_code, $fail_state);
     264            }
     265
     266            my $detMDlist = $mdcParser->parse(join "", @$stdout_buf) or
     267                &my_die("Could not parse detrend information for this image: $det_type $det_id $det_iter", $remote_id, $chip_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
     268            my $detImfileMD = parse_md_list($detMDlist);
     269            my $detImfile = $detImfileMD->[0];
     270            my $duri = $detImfile->{uri};
     271
     272            my $det_code = $det_types{$det_type};
     273            my ($ipp_det_uri, $remote_det_uri) = uri_to_outputs_raw($duri);
     274            $ppImage_command .= " $det_code $remote_det_uri ";
     275        }
     276
     277        # Add output root
     278        my $ipp_outroot = "${workdir}/${exp_tag}/${exp_tag}.ch.${chip_id}";
     279        my $remote_outroot = uri_local_to_remote($ipp_outroot);
     280        $ppImage_command .= " $remote_outroot ";
     281        print STDERR "$remote_outroot $ipp_outroot $class_id\n";
     282        # Complete reduction information.
     283        $reduction = 'DEFAULT' unless defined $reduction;
     284        my $recipe_ppImage = $ipprc->reduction($reduction, 'CHIP_PPIMAGE'); # Recipe to use for ppImage
     285        my $recipe_psphot  = $ipprc->reduction($reduction, 'CHIP_PSPHOT'); # Recipe to use for psphot
     286
     287        $ppImage_command .= " -recipe PPIMAGE $recipe_ppImage ";
     288        $ppImage_command .= " -recipe PSPHOT $recipe_psphot ";
     289        $ppImage_command .= " -recipe PPSTATS CHIPSTATS -stats ${remote_outroot}.${class_id}.stats ";
     290        $ppImage_command .= " -threads $threads_req ";
     291        $ppImage_command .= " -image_id $chip_imfile_id ";
     292        $ppImage_command .= " -tracedest ${remote_outroot}.${class_id}.trace ";
     293        $ppImage_command .= " -log ${remote_outroot}.${class_id}.log ";
     294
     295        # Calculate pre and post commands
     296        my $remote_outroot_dir = dirname($remote_outroot);
     297        my $pre_command =  "mkdir -p $remote_outroot_dir";
     298
     299        my $post_commandA = "chiptool -addprocessedimfile -exp_id $exp_id -chip_id $chip_id -class_id $class_id ";
     300        $post_commandA   .= " -uri ${ipp_outroot}.ch.${class_id}.ch.fits -path_base $ipp_outroot ";
     301        $post_commandA   .= " -magicked 0 -hostname $remote_hostname -dtime_script 0 ";
     302        $post_commandA   .= " -dbname $dbname " if defined $dbname;
     303
     304        my $post_commandB = "echo -n \"$post_commandA\" > ${remote_outroot}.${class_id}.dbinfo  ";
     305        my $post_commandC = "ppStatsFromMetadata ${remote_outroot}.${class_id}.stats - CHIP_IMFILE >> ${remote_outroot}.${class_id}.dbinfo";
     306
     307        $job_index++;
     308
     309        print CONFIG "${pre_command} && ${ppImage_command} && ${post_commandB} && ${post_commandC}";
     310
     311        # Determine which output files need to be returned.
     312        foreach my $component (@return_component_list) {
     313            my $filename = $ipprc->filename($component, $ipp_outroot, $class_id);
     314            my ($ipp_disk, $remote_disk) = uri_to_outputs_for_return( $filename );
     315            my $remote_outroot_dir = dirname($ipp_disk);
     316            print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk ";
     317        }
     318        print CONFIG "\n";
     319    }
     320}
    381321
    382322close(CONFIG);
     
    386326close(GENERATE);
    387327
    388 #
    389 # Construct the moab command last, so we can use the job_index counter to estimate resources.  Somehow.
    390 my $proc_need = $job_index * $threads;       # how many total processors do we need?
    391 my $node_need = $proc_need / $proc_per_node; # this equals how many nodes?
    392 my $time_need = $job_index * $job_cost;      # How many seconds will this take?
    393 
    394 my $fill_factor = 0.8;  # This is the factor of how much of the time allocation we'd like to fill
    395 my ($time_req,$node_req);
    396 if ($node_need * $job_cost < $fill_factor * $min_nodes * $min_time) {
    397     $time_req = $min_time;
    398     $node_req = $min_nodes;
    399 }
    400 elsif ($node_need * $job_cost > $fill_factor * $max_nodes * $max_time) {
    401     $time_req = $max_time;
    402     $node_req = $max_nodes;
    403     print STDERR "You've requested the construction of a bundle that appears to need $node_need nodes and $job_cost time per job.  This exceeds the max limits ($max_nodes, $max_time).  Using those max values instead.  Good luck.\n";
    404 }
    405 else {
    406     $time_req = int(($node_need * $job_cost) / ($fill_factor * $max_nodes)) + 1;
    407     $node_req = int(($node_need * $job_cost) / ($fill_factor * $time_req)) + 1;
    408 }
    409 $time_req += 1; # Safety addition.
    410 
    411 open(COMMAND,  ">$disk_command") || &my_die("Couldn't open file? $disk_command",$chip_id,$PS_EXIT_SYS_ERROR);
    412 print COMMAND "#!/bin/tcsh\n";
    413 print COMMAND "##### Moab controll lines\n";
    414 print COMMAND "#MSUB -l nodes=${node_req}:ppn=${proc_per_node},walltime=${time_req}:00:00\n"; ## CHECK RESOURCES
    415 print COMMAND "#MSUB -j oe\n";
    416 print COMMAND "#MSUB -V\n";
    417 print COMMAND "#MSUB -o ${remote_root}chip.${remote_id}.out\n";
    418 print COMMAND "date\n";
    419 print COMMAND 'srun -n $SLURM_JOB_NUM_NODES -m cyclic -l /bin/hostname | sort -n | awk \'{printf "%s\n", $2}\' > hosts.${SLURM_JOB_ID}' . "\n";
    420 print COMMAND "${remote_root}/stask_chip.py $remote_config " . 'hosts.${SLURM_JOB_ID} 1' . "\n";
    421 #print COMMAND "validate_processing.pl ${remote_root}chip.${remote_id}.out\n";
    422 print COMMAND "date\n";
    423 close(COMMAND);
    424 
    425 
    426328## We're done here. The execution and handling are done elsewhere.
    427329# Quick review:
     
    429331# auth
    430332unless($no_update) {
    431     my $command = "remotetool -updaterun -remote_id $remote_id ";
    432     $command .= " -set_state pending ";
     333    my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $chip_id ";
     334    $command .= " -set_jobs $job_index";
     335    $command .= " -set_path_base $path_base";
     336    $command .= " -set_state prep_done";
    433337    $command .= " -dbname $dbname " if defined $dbname;
    434338
    435339    system($command);
    436340}
    437 
    438 
    439    
    440 
    441 
     341exit (0);
    442342
    443343sub uri_convert {
     
    445345    my $ipp_disk= $ipprc->file_resolve( $neb_uri );
    446346    my $remote_disk = $ipp_disk;
    447    
     347
    448348    unless(defined($ipp_disk)) {
    449         my_die();
     349        &my_die( "Unable to generate file for $neb_uri ", $remote_id, $chip_id, $PS_EXIT_SYS_ERROR, $fail_state);
    450350    }
    451351
     
    461361    my $ipp_disk= $ipprc->file_resolve( $neb_uri , 1);
    462362    my $remote_disk = $ipp_disk;
    463    
     363
    464364    unless(defined($ipp_disk)) {
    465         my_die();
     365        &my_die( "Unable to generate file for $neb_uri ", $remote_id, $chip_id, $PS_EXIT_SYS_ERROR, $fail_state);
    466366    }
    467367
     
    476376    my $neb_uri = shift;
    477377    my ($ipp_disk, $remote_disk) = uri_convert( $neb_uri );
    478    
    479     unless (exists($file_filter{$neb_uri})) {
    480         $file_filter{$neb_uri} = 1;
    481         print TRANSFER "$ipp_disk\n";
    482         print CHECK    "$remote_disk\n";
    483     }
     378
     379    print TRANSFER "$ipp_disk\n";
     380    print CHECK    "$remote_disk\n";
    484381    return($ipp_disk,$remote_disk);
    485382}
     
    489386    my ($ipp_disk, $remote_disk) = uri_convert( $neb_uri );
    490387    $remote_disk = $remote_raw . $ipp_disk;
    491     unless (exists($file_filter{$neb_uri})) {
    492         $file_filter{$neb_uri} = 1;
    493         print TRANSFER "$ipp_disk\n";
    494         print CHECK    "$remote_disk\n";
    495     }
     388
     389    print TRANSFER "$ipp_disk\n";
     390    print CHECK    "$remote_disk\n";
    496391    return($ipp_disk,$remote_disk);
    497392}
     
    500395    my $neb_uri = shift;
    501396    my ($ipp_disk, $remote_disk) = uri_convert_and_create( $neb_uri );
    502     unless (exists($file_filter{$neb_uri})) {
    503         $file_filter{$neb_uri} = 1;
    504         print RETURN "$ipp_disk\n";
    505         print GENERATE "$remote_disk\n";
    506     }
     397    print RETURN "$ipp_disk\n";
     398    print GENERATE "$remote_disk\n";
    507399    return($ipp_disk,$remote_disk);
    508400}
     
    518410    return($remote_uri);
    519411}
    520  
     412
    521413sub uri_remote_to_local {
    522414    # This needs to replace the remote root directory with the nebulous tag.
     
    524416    $remote_uri =~ s%${remote_root}%%;
    525417    my $local_uri  = "neb:///" . $remote_uri;
    526    
     418
    527419    return($local_uri);
    528420}
     421
    529422sub my_die {
    530423    my $msg = shift;
    531     my $id  = shift;
     424    my $remote_id  = shift;
     425    my $stage_id  = shift;
    532426    my $exit_code = shift;
    533427    my $exit_state = shift;
     
    536430
    537431    carp($msg);
    538    
    539     if (defined $id and not $no_update) {
    540         my $command = "remotetool -updaterun -remote_id $id";
    541         $command .= " -fault $exit_code " if defined $exit_code;
    542         $command .= " -set_state $exit_state " if defined $exit_state;
    543         $command .= " -dbname $dbname " if defined $dbname;
    544 
    545         system($command);
     432
     433    if (defined $remote_id and defined $stage_id and not $no_update) {
     434        my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $stage_id";
     435        $command .= " -set_state $exit_state " if defined $exit_state;
     436        $command .= " -dbname $dbname " if defined $dbname;
     437
     438        system($command);
    546439    }
    547440
  • trunk/ippScripts/scripts/sc_prepare_stack.pl

    r37195 r37833  
    11#! /usr/bin/env perl
     2
     3# generate the input & output files lists and commands for a single stackRun
    24
    35use Carp;
     
    1618use Pod::Usage qw( pod2usage );
    1719
    18 
    1920# Hard coded values
    20 #my $remote_root   = '/scratch3/watersc1/';  # Far side destination base location
    21 my $remote_root   = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
    22 $remote_root = '/scratch3/watersc1/';
    23 my $threads       = 2;                      # How many threads are we going to use?
    24 my $job_cost      = 1500 / 60 / 60;           # Estimate of how long a job runs, in hours.
    25 my $proc_per_node = 24;                     # processors per node
    26 my $min_nodes     = 1;                      # smallest allocation to ask for
    27 my $max_nodes     = 1000;                   # largest allocation to ask for
    28 my $min_time      = 1;                      # shortest allocation to ask for
    29 my $max_time      = 8;                      # longest allocation to ask for
    30 my $remote_hostname   = "LANL/Mustang";         # Name of the remote node.
    31 my @return_component_list = ("DBINFO.EXP", "PPSTACK.UNCONV","PPSTACK.UNCONV.MASK","PPSTACK.UNCONV.VARIANCE",
    32                              "PPSTACK.UNCONV.EXP","PPSTACK.UNCONV.EXPWT","PPSTACK.UNCONV.EXPNUM","PSPHOT.OUTPUT",
    33                              "LOG.EXP", "PSASTRO.STATS",
    34                              "PPSTACK.CONFIG","PPSTACK.TARGET.PSF","PSPHOT.STACK.PSF.SAVE");
    35 #,"PPSTACK.CONV.KERNEL");
     21# my $remote_root   = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
     22my $remote_root     = '/scratch3/watersc1/';  # Far side destination base location
     23my $remote_hostname = "LANL/Mustang";         # Name of the remote node.
     24my $threads_req     = 4;                      # How many threads are we going to use?
     25
     26my $fail_state = "prep_fail";
     27
    3628# Look for programs we need
    3729my $missing_tools;
    38 
    3930my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1);
    40 my $stacktool    = can_run('stacktool') or (warn "Can't find warptool" and $missing_tools = 1);
     31my $stacktool    = can_run('stacktool') or (warn "Can't find stacktool" and $missing_tools = 1);
    4132
    4233if ($missing_tools) {
     
    4839GetOptions(
    4940    'remote_id=s'    => \$remote_id,
     41    'stack_id=s'     => \$stack_id,
    5042    'camera|c=s'     => \$camera,
    5143    'dbname|d=s'     => \$dbname,
     
    5648
    5749pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    58 pod2usage( -msg => "Required options: --remote_id --camera --dbname --path_base", -exitval => 3) unless
     50pod2usage( -msg => "Required options: --remote_id --stack_id --camera --dbname --path_base", -exitval => 3) unless
    5951    defined($remote_id) and
     52    defined($stack_id) and
    6053    defined($camera) and
    6154    defined($path_base) and
    6255    defined($dbname);
    63 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id);
     56
     57my $ipprc = PS::IPP::Config->new( $camera ) or &my_die( "Unable to set up", $remote_id, $stack_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
    6458
    6559my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    6660
    67 #
    68 # Step 1: Get a list of the components that make up this remoteRun
    69 
    70 # SHould this call listrun to ensure we're in state new?
    71 my $rt_cmd = "$remotetool -listcomponent -remote_id $remote_id";
    72 $rt_cmd   .= " -dbname $dbname " if defined($dbname);
    73 
    74 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    75     run(command => $rt_cmd, verbose => $verbose);
    76 unless ($success) {
    77     $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    78     &my_die("Unable to run remotetool to determine stage parameters.",
    79             $remote_id,$error_code);
    80 }
    81 my $compData = $mdcParser->parse(join "", @$stdout_buf) or
    82     &my_die("Unable to determine component information.",
    83             $remote_id,$PS_EXIT_PROG_ERROR);
    84 my $compData2= parse_md_list($compData);
    85 
    86 #
    87 # Step 1b: Open output files
    88 my $uri_command = $path_base . ".cmd";
     61my @return_component_list = ("DBINFO.EXP", "PPSTACK.UNCONV","PPSTACK.UNCONV.MASK","PPSTACK.UNCONV.VARIANCE",
     62                             "PPSTACK.UNCONV.EXP","PPSTACK.UNCONV.EXPWT","PPSTACK.UNCONV.EXPNUM",
     63                             "PSPHOT.OUT.CMF.MEF", # Use this output product to get the one that exists.
     64                             "LOG.EXP", "PSASTRO.STATS",
     65                             "PPSTACK.CONFIG","PPSTACK.TARGET.PSF","PSPHOT.STACK.PSF.SAVE");
     66#,"PPSTACK.CONV.KERNEL");
     67
     68# STEP 0: Open output files
    8969my $uri_transfer= $path_base . ".transfer";
    9070my $uri_check   = $path_base . ".check";
     
    9373my $uri_return  = $path_base . ".return";
    9474
    95 my $disk_command = $ipprc->file_resolve($uri_command,1);
    9675my $disk_transfer= $ipprc->file_resolve($uri_transfer,1);
    9776my $disk_check   = $ipprc->file_resolve($uri_check,1);
     
    10079my $disk_return  = $ipprc->file_resolve($uri_return,1);
    10180
    102 my (undef, $remote_config) = uri_convert($uri_config); # Needs to be done after we've created it.
    103 
    104 open(TRANSFER, ">$disk_transfer")  || &my_die("Couldn't open file? $disk_transfer",$remote_id,$PS_EXIT_SYS_ERROR);
    105 open(CHECK,    ">$disk_check")  || &my_die("Couldn't open file? $disk_check",$remote_id,$PS_EXIT_SYS_ERROR);
    106 open(CONFIG,   ">$disk_config")  || &my_die("Couldn't open file? $disk_config",$remote_id,$PS_EXIT_SYS_ERROR);
    107 open(GENERATE, ">$disk_generate") || &my_die("Couldn't open file? $disk_generate",$remote_id,$PS_EXIT_SYS_ERROR);
    108 open(RETURN,   ">$disk_return") || &my_die("Couldn't open file? $disk_return", $remote_id, $PS_EXIT_SYS_ERROR);
    109 
    110 
    111 #
    112 # Step 2: Iterate over all componenets in this remote run.
     81my (undef, $remote_config) = &uri_convert($uri_config); # Needs to be done after we've created it.
     82
     83open(TRANSFER, ">$disk_transfer")  || &my_die("Couldn't open file? $disk_transfer",$remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state);
     84open(CHECK,    ">$disk_check")     || &my_die("Couldn't open file? $disk_check",   $remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state);
     85open(CONFIG,   ">$disk_config")    || &my_die("Couldn't open file? $disk_config",  $remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state);
     86open(GENERATE, ">$disk_generate")  || &my_die("Couldn't open file? $disk_generate",$remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state);
     87open(RETURN,   ">$disk_return")    || &my_die("Couldn't open file? $disk_return",  $remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state);
     88
    11389my $job_index = 0;
    114 my @pre_commands = ();
    115 my @main_commands = ();
    116 my @post_commands = ();
    117 my %file_filter = ();
    118 
    119 
    120 foreach my $compEntry (@$compData2) {
    121     my $stack_id = $compEntry->{stage_id};
    122 
    123 # Get exposure level information from the stackRun we're working from.
    124     my $run_command = "$stacktool -tosum -stack_id $stack_id";
    125     $run_command .= " -dbname $dbname " if defined($dbname);
    126     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    127         run(command => $run_command, verbose => 0);
     90
     91# STEP 1: Get exposure level information from the stackRun we're working from.
     92my ($reduction, $workdir, $tess_id, $skycell_id);
     93{
     94    my $command = "$stacktool -tosum -stack_id $stack_id";
     95    $command .= " -dbname $dbname " if defined($dbname);
     96    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     97        run(command => $command, verbose => $verbose);
    12898    unless ($success) {
    129         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    130         &my_die("Unable to run stacktool -tosum ",
    131                 $stack_id,$error_code);
    132     }
    133 
    134     my $stackData = $mdcParser->parse(join "", @$stdout_buf) or
    135         &my_die("Unable to determine stack component information.",
    136                 $stack_id,$PS_EXIT_PROG_ERROR);
    137     my $stackData2= parse_md_list($stackData);
    138 
    139     my $stack = ${ $stackData2 }[0];
    140     my $reduction = $stack->{reduction};
     99        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     100        &my_die("Unable to run stacktool -tosum ", $remote_id, $stack_id, $error_code, $fail_state);
     101    }
     102
     103    my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or
     104        &my_die("Unable to determine stack component information.", $remote_id, $stack_id, $PS_EXIT_PROG_ERROR, $fail_state);
     105    my $metadata = parse_md_list($MDlist);
     106
     107    my $stack = $metadata->[0];
     108
     109    $reduction = $stack->{reduction};
    141110    $reduction = 'DEFAULT' unless defined($reduction);
    142     my $workdir   = $stack->{workdir};
    143     my $tess_id   = $stack->{tess_id};
    144     my $skycell_id= $stack->{skycell_id};
    145 
    146     my $ipp_outroot    = "${workdir}/${tess_id}/${skycell_id}/${tess_id}.${skycell_id}.stk.${stack_id}";   
    147     my $remote_outroot = uri_local_to_remote($ipp_outroot);   
    148     my $remote_outdir  = uri_local_to_remote("${workdir}/${tess_id}/${skycell_id}");
     111    $workdir   = $stack->{workdir};
     112    $tess_id   = $stack->{tess_id};
     113    $skycell_id= $stack->{skycell_id};
     114}
     115my $ipp_outroot    = "${workdir}/${tess_id}/${skycell_id}/${tess_id}.${skycell_id}.stk.${stack_id}";
     116my $remote_outroot = &uri_local_to_remote($ipp_outroot);
     117my $remote_outdir  = &uri_local_to_remote("${workdir}/${tess_id}/${skycell_id}");
     118
     119# STEP 2: Get the list of input warps
     120my ($warpData);
     121{
    149122    # This actually returns all the individual stack/skyfiles that comprise this run.  Because consistency.
    150123    my $command = "$stacktool -inputskyfile -stack_id $stack_id ";
    151124    $command .= " -dbname $dbname " if defined($dbname);
    152     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    153         run(command => $command, verbose => 0);
     125    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     126        run(command => $command, verbose => $verbose);
    154127    unless ($success) {
    155         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    156         &my_die("Unable to run stacktool -inputskyfile ",
    157                 $stack_id,$error_code);
    158     }
    159 
    160     my $warpData = $mdcParser->parse(join "", @$stdout_buf) or
    161         &my_die("Unable to determine stack component information.",
    162                 $stack_id,$PS_EXIT_PROG_ERROR);
    163     my $warpData2= parse_md_list($warpData);
    164 
    165 #
    166 # Step 3: Iterate over the sub-components
     128        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     129        &my_die("Unable to run stacktool -inputskyfile ", $remote_id, $stack_id, $error_code, $fail_state);
     130    }
     131
     132    my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or
     133        &my_die("Unable to determine stack component information.", $remote_id, $stack_id, $PS_EXIT_PROG_ERROR, $fail_state);
     134    $warpData = parse_md_list($MDlist);
     135}
     136
     137# STEP 3: Iterate over the sub-components
     138{
     139    # Generate a file mapping the symbolic and "disk" representations of each needed file.
     140    my $uri_compmap   = "${ipp_outroot}.compmap";
     141    my $component_map = $ipprc->file_resolve($uri_compmap,1);   
     142    my ($ipp_compmap, $remote_compmap) = &uri_to_outputs($component_map);
     143    open(COMPMAP,">$ipp_compmap") || &my_die("Couldn't open file? $ipp_compmap",  $remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state);
     144   
     145    # Loop over all needed components for this stack.
    167146    my $warp_path_base_string = "";
    168     foreach my $warpEntry ( @{ $warpData2 } ) {
    169         my $warp_path_base = $warpEntry->{path_base};
    170         my $remote_path_base = uri_local_to_remote($warp_path_base);
    171         $warp_path_base_string .= " $remote_path_base ";
    172 
    173         # Append file names to transfer lists so we can recover if warps are deleted.
    174         uri_to_outputs($warp_path_base . ".fits");
    175         uri_to_outputs($warp_path_base . ".wt.fits");
    176         uri_to_outputs($warp_path_base . ".mask.fits");
    177         uri_to_outputs($warp_path_base . ".cmf");
    178 #       uri_to_outputs($warp_path_base . ".psf");
    179     }
    180     my $mk_mdc_command = "mkdir -p $remote_outdir && sc_mk_stack_mdc.pl $warp_path_base_string > ${remote_outroot}.in.mdc";
    181     my $recipe_ppstack = $ipprc->reduction($reduction, 'STACK_PPSTACK'); # Recipe to use                                                                         
     147    foreach my $warpEntry ( @{ $warpData } ) {
     148        my $warp_path_base = $warpEntry->{path_base};
     149        my $remote_path_base = &uri_local_to_remote($warp_path_base);
     150        $warp_path_base_string .= " $remote_path_base ";
     151
     152        if ($verbose) { print STDERR "$warp_path_base_string\n"; }
     153
     154        # Append file names to transfer lists so we can recover if warps are deleted.
     155        my $remote_file;
     156        my $ipp_disk;
     157        #  ${remote_root}/tmp/${ipp_disk}
     158        (undef,$remote_file) = &uri_to_outputs($warp_path_base . ".fits");
     159        ($ipp_disk,undef)    = &uri_convert($warp_path_base . ".fits");
     160        print COMPMAP "$remote_file ${remote_root}/tmp/${ipp_disk}\n";
     161        (undef,$remote_file) = &uri_to_outputs($warp_path_base . ".wt.fits");
     162        ($ipp_disk,undef)    = &uri_convert($warp_path_base . ".wt.fits");
     163        print COMPMAP "$remote_file ${remote_root}/tmp/${ipp_disk}\n";
     164        (undef,$remote_file) = &uri_to_outputs($warp_path_base . ".mask.fits");
     165        ($ipp_disk,undef)    = &uri_convert($warp_path_base . ".mask.fits");
     166        print COMPMAP "$remote_file ${remote_root}/tmp/${ipp_disk}\n";
     167        (undef,$remote_file) = &uri_to_outputs($warp_path_base . ".cmf");
     168        ($ipp_disk,undef)    = &uri_convert($warp_path_base . ".cmf");
     169        print COMPMAP "$remote_file ${remote_root}/tmp/${ipp_disk}\n";
     170        (undef,$remote_file) = &uri_to_outputs($warp_path_base . ".psf");
     171        ($ipp_disk,undef)    = &uri_convert($warp_path_base . ".psf");
     172        print COMPMAP "$remote_file ${remote_root}/tmp/${ipp_disk}\n";
     173    }
     174
     175    close(COMPMAP);
     176
     177    my $mk_mdc_command = "mkdir -p $remote_outdir && sc_mk_stack_mdc.pl --compmap ${remote_root}/tmp/${component_map} $warp_path_base_string > ${remote_outroot}.in.mdc";
     178    my $recipe_ppstack = $ipprc->reduction($reduction, 'STACK_PPSTACK'); # Recipe to use
    182179    my $ppstack_command  = " ppStack -input ${remote_outroot}.in.mdc ";
    183180    $ppstack_command    .= " ${remote_outroot} -stats ${remote_outroot}.stats ";
     
    191188    $ppstack_command    .= " -R PPSTACK.UNCONV.VARIANCE FITS.TYPE COMP_STACK";
    192189    $ppstack_command    .= " -tracedest ${remote_outroot}.trace -log ${remote_outroot}.log ";
    193     $ppstack_command    .= " -threads 4 ";
     190    $ppstack_command    .= " -threads $threads_req ";
    194191    $ppstack_command    .= " -dumpconfig ${remote_outroot}.mdc ";
    195192    $ppstack_command    .= " -stack_id $stack_id -skycell_id $skycell_id -tess_id $tess_id ";
     
    199196    $post_cmd_echo   .=  " -dbname $dbname " if defined $dbname;
    200197    $post_cmd_echo   .= " -hostname $remote_hostname -dtime_script 0 \" > ${remote_outroot}.dbinfo ";
    201        
     198
    202199    my $post_cmd_SfM  = " ppStatsFromMetadata ${remote_outroot}.stats - STACK_SKYCELL >> ${remote_outroot}.dbinfo ";
    203200
     
    207204    # Determine which output files need to be returned
    208205    foreach my $component(@return_component_list) {
    209         my $filename = $ipprc->filename($component,$ipp_outroot);
    210         my ($ipp_disk, $remote_disk) = uri_to_outputs_for_return( $filename);
    211         my $remote_outroot_dir = dirname($ipp_disk);
    212         print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk ";
    213     }
    214 
    215 #     my $cleanup_cmd   = " (rm -f /scratch3/watersc1/sys_temp/${tess_id}.${skycell_id}.stk.${stack_id}.*conv.*.fits || true) ";   
    216 #     print CONFIG " && ${cleanup_cmd} \n";
    217 
     206        my $filename = $ipprc->filename($component,$ipp_outroot);
     207        my ($ipp_disk, $remote_disk) = &uri_to_outputs_for_return( $filename);
     208        my $remote_outroot_dir = dirname($ipp_disk);
     209        print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk ";
     210    }
    218211    print CONFIG "\n";
    219212}
     
    224217close(GENERATE);
    225218
    226 #
    227 # Construct the moab command last, so we can use the job_index counter to estimate resources.  Somehow.
    228 my $proc_need = $job_index * $threads;       # how many total processors do we need?
    229 my $node_need = $proc_need / $proc_per_node; # this equals how many nodes?
    230 my $time_need = $job_index * $job_cost;      # How many seconds will this take?
    231 
    232 my $fill_factor = 0.8;  # This is the factor of how much of the time allocation we'd like to fill
    233 my ($time_req,$node_req);
    234 if ($node_need * $job_cost < $fill_factor * $min_nodes * $min_time) {
    235     $time_req = $min_time;
    236     $node_req = $min_nodes;
    237 }
    238 elsif ($node_need * $job_cost > $fill_factor * $max_nodes * $max_time) {
    239     $time_req = $max_time;
    240     $node_req = $max_nodes;
    241     print STDERR "You've requested the construction of a bundle that appears to need $node_need nodes and $job_cost time per job.  This exceeds the max limits ($max_nodes, $max_time).  Using those max values instead.  Good luck.\n";
    242 }
    243 else {
    244     $time_req = int(($node_need * $job_cost) / ($fill_factor * $max_nodes)) + 1;
    245     $node_req = int(($node_need * $job_cost) / ($fill_factor * $time_req)) + 1;
    246 }
    247 
    248 $time_req += 2;
    249 $node_req *= 3;
    250 open(COMMAND,  ">$disk_command") || &my_die("Couldn't open file? $disk_command",$remote_id,$PS_EXIT_SYS_ERROR);
    251 print COMMAND "#!/bin/tcsh\n";
    252 print COMMAND "##### Moab controll lines\n";
    253 print COMMAND "#MSUB -l nodes=${node_req}:ppn=${proc_per_node},walltime=${time_req}:00:00\n"; ## CHECK RESOURCES
    254 print COMMAND "#MSUB -j oe\n";
    255 print COMMAND "#MSUB -V\n";
    256 print COMMAND "#MSUB -o ${remote_root}stack.${remote_id}.out\n";
    257 print COMMAND "date\n";
    258 print COMMAND 'srun -n $SLURM_JOB_NUM_NODES -m cyclic -l /bin/hostname | sort -n | awk \'{printf "%s\n", $2}\' > hosts.${SLURM_JOB_ID}' . "\n";
    259 print COMMAND "${remote_root}/stask_chip.py $remote_config " . 'hosts.${SLURM_JOB_ID} 3' . "\n";
    260 print COMMAND "date\n";
    261 close(COMMAND);
    262 
    263219unless($no_update) {
    264     my $command = "remotetool -updaterun -remote_id $remote_id ";
    265     $command .= " -set_state pending ";
     220    my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $stack_id ";
     221    $command .= " -set_jobs $job_index";
     222    $command .= " -set_path_base $path_base";
     223    $command .= " -set_state prep_done";
    266224    $command .= " -dbname $dbname " if defined $dbname;
    267225
     
    269227}
    270228
    271 
    272229## Common SC routines
    273230
     231# KEEP
    274232sub uri_convert { # (ipp_disk,remote_disk) = uri_convert(neb_uri);
    275233    my $neb_uri = shift;
    276234    my $ipp_disk= $ipprc->file_resolve( $neb_uri );
    277235    my $remote_disk = $ipp_disk;
    278    
     236
    279237    unless(defined($ipp_disk)) {
    280         my_die();
     238        &my_die( "Unable to generate file for $neb_uri ", $remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state);
    281239    }
    282240
     
    288246}
    289247
     248# KEEP
    290249sub uri_convert_and_create { # (ipp_disk,remote_disk) = uri_convert_and_create(neb_uri); ipp_disk is created if it doesn't exist
    291250    my $neb_uri = shift;
    292251    my $ipp_disk= $ipprc->file_resolve( $neb_uri , 1);
    293252    my $remote_disk = $ipp_disk;
    294    
     253
    295254    unless(defined($ipp_disk)) {
    296         my_die();
     255        &my_die( "Unable to generate file for $neb_uri ", $remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state);
    297256    }
    298257
     
    304263}
    305264
     265# KEEP
    306266sub uri_to_outputs { # (ipp_disk,remote_disk) = uri_to_output(neb_uri); Appends to TRANSFER and CHECK filehandles
    307267    my $neb_uri = shift;
    308268    my ($ipp_disk, $remote_disk) = uri_convert( $neb_uri );
    309    
    310     unless (exists($file_filter{$neb_uri})) {
    311         $file_filter{$neb_uri} = 1;
    312         print TRANSFER "$ipp_disk\n";
    313         print CHECK    "$remote_disk\n";
    314     }
     269
     270    print TRANSFER "$ipp_disk\n";
     271    print CHECK    "$remote_disk\n";
    315272    return($ipp_disk,$remote_disk);
    316273}
    317274
     275# KEEP
    318276sub uri_to_outputs_for_return { # (ipp_disk,remote_disk) = uri_to_outputs_for_return(neb_uri); create ipp_disk, append to RETURN and GENERATE
    319277    my $neb_uri = shift;
    320278    my ($ipp_disk, $remote_disk) = uri_convert_and_create( $neb_uri );
    321     unless (exists($file_filter{$neb_uri})) {
    322         $file_filter{$neb_uri} = 1;
    323         print RETURN "$ipp_disk\n";
    324         print GENERATE "$remote_disk\n";
    325     }
     279
     280    print RETURN "$ipp_disk\n";
     281    print GENERATE "$remote_disk\n";
    326282    return($ipp_disk,$remote_disk);
    327283}
    328284
     285# KEEP
    329286sub uri_local_to_remote { #(remote_uri) = uri_local_to_remote(local_neb_uri);
    330287    # This needs to replace the nebulous tag with the remote root.
     
    337294    return($remote_uri);
    338295}
    339  
    340 sub uri_remote_to_local { #(local_neb_uri) = uri_remote_to_local(remote_uri);
    341     # This needs to replace the remote root directory with the nebulous tag.
    342     my $remote_uri = shift;
    343     $remote_uri =~ s%${remote_root}%%;
    344     my $local_uri  = "neb:///" . $remote_uri;
    345    
    346     return($local_uri);
    347 }
    348 
    349296
    350297sub my_die { # exit with status; my_die(message,stage_id,exit_code,exit_status);
    351298    my $msg = shift;
    352     my $id  = shift;
     299    my $remote_id  = shift;
     300    my $stage_id  = shift;
    353301    my $exit_code = shift;
    354302    my $exit_state = shift;
     
    357305
    358306    carp($msg);
    359    
    360     if (defined $id and not $no_update) {
    361         my $command = "remotetool -updaterun -remote_id $id";
    362         $command .= " -fault $exit_code " if defined $exit_code;
     307
     308    if (defined $remote_id and defined $stage_id and not $no_update) {
     309        my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $stage_id";
    363310        $command .= " -set_state $exit_state " if defined $exit_state;
    364311        $command .= " -dbname $dbname " if defined $dbname;
  • trunk/ippScripts/scripts/sc_prepare_warp.pl

    r37154 r37833  
    11#! /usr/bin/env perl
     2
     3# generate the input & output files lists and commands for a single warpRun
    24
    35use Carp;
     
    1618use Pod::Usage qw( pod2usage );
    1719
    18 
    1920# Hard coded values
    20 # my $remote_root   = '/scratch3/watersc1/'; 
    21 my $remote_root = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
    22 $remote_root = '/scratch3/watersc1/';
    23 my $threads       = 2;                      # How many threads are we going to use?
    24 my $job_cost      = 110 / 60 / 60;          # Estimate of how long a job runs, in hours.
    25 my $proc_per_node = 24;                     # processors per node
    26 my $min_nodes     = 1;                      # smallest allocation to ask for
    27 my $max_nodes     = 1000;                   # largest allocation to ask for
    28 my $min_time      = 1;                      # shortest allocation to ask for
    29 my $max_time      = 8;                      # longest allocation to ask for
    30 my $remote_hostname= "LANL/Mustang";         # Name of the remote node.
    31 my @return_component_list = ("DBINFO.EXP", "PSWARP.CONFIG", "PSWARP.OUTPUT", "PSWARP.OUTPUT.MASK", "PSWARP.OUTPUT.VARIANCE", "PSWARP.OUTPUT.SOURCES","PSPHOT.PSF.SKY.SAVE","LOG.EXP");
     21# my $remote_root = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
     22my $remote_root     = '/scratch3/watersc1/';
     23my $remote_hostname = "LANL/Mustang";         # Name of the remote node.
     24my $threads_req     = 4;                      # How many threads are we going to use?
     25
     26my $fail_state = "prep_fail";
     27
    3228# Look for programs we need
    3329my $missing_tools;
    34 
    3530my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1);
    3631my $warptool    = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1);
     
    4136}
    4237
    43 my ($remote_id,$warp_id,,$camera,$dbname,$verbose,$path_base,$no_update);
     38my ($remote_id,$warp_id,$camera,$dbname,$verbose,$path_base,$no_update);
    4439GetOptions(
    4540    'remote_id=s'    => \$remote_id,
     41    'warp_id=s'      => \$warp_id,
    4642    'camera|c=s'     => \$camera,
    4743    'dbname|d=s'     => \$dbname,
     
    5248
    5349pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    54 pod2usage( -msg => "Required options: --remote_id --camera --dbname --path_base", -exitval => 3) unless
     50pod2usage( -msg => "Required options: --remote_id -warp_id --camera --dbname --path_base", -exitval => 3) unless
    5551    defined($remote_id) and
     52    defined($warp_id) and
    5653    defined($camera) and
    5754    defined($path_base) and
    5855    defined($dbname);
    59 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $warp_id);
     56
     57my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id, $warp_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
    6058
    6159my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    6260
    63 #
    64 # Step 1: Get a list of the components that make up this remoteRun
    65 
    66 # SHould this call listrun to ensure we're in state new?
    67 my $rt_cmd = "$remotetool -listcomponent -remote_id $remote_id";
    68 $rt_cmd   .= " -dbname $dbname " if defined($dbname);
    69 
    70 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    71     run(command => $rt_cmd, verbose => $verbose);
    72 unless ($success) {
    73     $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    74     &my_die("Unable to run remotetool to determine stage parameters.",
    75             $remote_id,$error_code);
    76 }
    77 my $compData = $mdcParser->parse(join "", @$stdout_buf) or
    78     &my_die("Unable to determine component information.",
    79             $remote_id,$PS_EXIT_PROG_ERROR);
    80 my $compData2= parse_md_list($compData);
    81 
    82 #
    83 # Step 1b: Open output files
    84 my $uri_command = $path_base . ".cmd";
     61my @return_component_list = ("DBINFO.EXP", "PSWARP.CONFIG", "PSWARP.OUTPUT", "PSWARP.OUTPUT.MASK", "PSWARP.OUTPUT.VARIANCE", "PSWARP.OUTPUT.SOURCES","PSPHOT.PSF.SKY.SAVE","LOG.EXP");
     62
     63# STEP 0: Open output files
    8564my $uri_transfer= $path_base . ".transfer";
    8665my $uri_check   = $path_base . ".check";
     
    8968my $uri_return  = $path_base . ".return";
    9069
    91 my $disk_command = $ipprc->file_resolve($uri_command,1);
    9270my $disk_transfer= $ipprc->file_resolve($uri_transfer,1);
    9371my $disk_check   = $ipprc->file_resolve($uri_check,1);
     
    9674my $disk_return  = $ipprc->file_resolve($uri_return,1);
    9775
    98 my (undef, $remote_config) = uri_convert($uri_config); # Needs to be done after we've created it.
    99 
    100 open(TRANSFER, ">$disk_transfer")  || &my_die("Couldn't open file? $disk_transfer",$remote_id,$PS_EXIT_SYS_ERROR);
    101 open(CHECK,    ">$disk_check")  || &my_die("Couldn't open file? $disk_check",$remote_id,$PS_EXIT_SYS_ERROR);
    102 open(CONFIG,   ">$disk_config")  || &my_die("Couldn't open file? $disk_config",$remote_id,$PS_EXIT_SYS_ERROR);
    103 open(GENERATE, ">$disk_generate") || &my_die("Couldn't open file? $disk_generate",$remote_id,$PS_EXIT_SYS_ERROR);
    104 open(RETURN,   ">$disk_return") || &my_die("Couldn't open file? $disk_return", $remote_id, $PS_EXIT_SYS_ERROR);
    105 
    106 
    107 #
    108 # Step 2: Iterate over all componenets in this remote run.
     76my (undef, $remote_config) = &uri_convert($uri_config); # Needs to be done after we've created it.
     77
     78open(TRANSFER, ">$disk_transfer")  || &my_die("Couldn't open file? $disk_transfer",$remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
     79open(CHECK,    ">$disk_check")     || &my_die("Couldn't open file? $disk_check",   $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
     80open(CONFIG,   ">$disk_config")    || &my_die("Couldn't open file? $disk_config",  $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
     81open(GENERATE, ">$disk_generate")  || &my_die("Couldn't open file? $disk_generate",$remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
     82open(RETURN,   ">$disk_return")    || &my_die("Couldn't open file? $disk_return",  $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
     83
    10984my $job_index = 0;
    110 my @pre_commands = ();
    111 my @main_commands = ();
    112 my @post_commands = ();
    113 
    114 my %file_filter = ();
    115 
    116 foreach my $compEntry (@$compData2) {
    117     my $warp_id = $compEntry->{stage_id};
    118 
    119 # Get exposure level information from the warpRun we're working from.
     85
     86# STEP 1: Get exposure level information from the warpRun we're working from.
     87my ($warpData);
     88{
    12089    # This actually returns all the individual warp/skyfiles that comprise this run.  Because consistency.
    12190    my $command = "$warptool -towarped -warp_id $warp_id ";
    12291    $command   .= " -dbname $dbname " if defined($dbname);
    123     ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    124         run(command => $command, verbose => 0);
     92
     93    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     94        run(command => $command, verbose => $verbose);
    12595    unless ($success) {
    126         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    127         &my_die("Unable to run warptool -pendingimfile ",
    128                 $warp_id,$error_code);
    129     }
    130     my $warpData = $mdcParser->parse(join "", @$stdout_buf) or
    131         &my_die("Unable to determine warp component information.",
    132                 $warp_id,$PS_EXIT_PROG_ERROR);
    133     my $warpData2= parse_md_list($warpData);
    134 
    135 #
    136 # Step 3: Iterate over the sub-components
    137     foreach my $warpEntry ( @{ $warpData2 } ) {
    138         my $workdir = $warpEntry->{workdir};
    139         my $exp_tag = $warpEntry->{exp_tag};
    140         my $skycell_id = $warpEntry->{skycell_id};
    141         my $tess_id = $warpEntry->{tess_id};
    142         my $reduction = 'DEFAULT' unless defined $warpEntry->{reduction};
    143         my $recipe_pswarp = $ipprc->reduction($reduction, 'WARP_PSWARP'); # Recipe to use                                                                         
    144         my $ipp_outroot = "${workdir}/${exp_tag}/${exp_tag}.wrp.${warp_id}.${skycell_id}";
    145         print "$ipp_outroot\n";
    146         my $remote_outroot = uri_local_to_remote($ipp_outroot);
    147 
    148         my $reg_command = "$warptool -scmap -warp_id $warp_id -skycell_id ${skycell_id}";
    149         $reg_command   .= " -dbname $dbname " if defined($dbname);
    150        
    151         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    152             run(command => $reg_command, verbose => 0);
    153         unless ($success) {
    154             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    155             &my_die("Unable to run warptool -pendingimfile: $reg_command ",
    156                     $warp_id,$error_code);
    157         }
    158    
    159         my $inpData = $mdcParser->parse(join "", @$stdout_buf) or
    160             &my_die("Unable to determine warp component information.",
    161                     $warp_id, $PS_EXIT_PROG_ERROR);
    162         my $inpData2=parse_md_list($inpData);
    163        
    164         my $pre_cmd_ims = "ls -1 ";
    165         my $pre_cmd_masks= "ls -1 ";
    166         my $pre_cmd_vars = "ls -1 ";
    167         my $pre_cmd_astrom = "";
    168 
    169         foreach my $imfile (@{ $inpData2 }) {
    170             my $image = $ipprc->filename("PPIMAGE.CHIP", $imfile->{chip_path_base}, $imfile->{class_id});
    171             my $mask  = $ipprc->filename("PSASTRO.OUTPUT.MASK", $imfile->{cam_path_base}, $imfile->{class_id});
    172             my $var   = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $imfile->{chip_path_base}, $imfile->{class_id});
    173 
    174             my $astrom= $ipprc->filename("PSASTRO.OUTPUT", $imfile->{cam_path_base});
    175            
    176             my $remote_image = uri_local_to_remote($image);
    177             my $remote_mask  = uri_local_to_remote($mask);
    178             my $remote_var   = uri_local_to_remote($var);
    179             my $remote_astrom= uri_local_to_remote($astrom);
    180 
    181             $pre_cmd_ims     .= " $remote_image ";
    182             $pre_cmd_masks   .= " $remote_mask  ";
    183             $pre_cmd_vars    .= " $remote_var   ";
    184             $pre_cmd_astrom   = "echo $remote_astrom > ${remote_outroot}.astrom ";
    185         }
    186         $pre_cmd_ims   .= "  > ${remote_outroot}.imlist ";
    187         $pre_cmd_masks .= "  > ${remote_outroot}.masklist ";
    188         $pre_cmd_vars  .= "  > ${remote_outroot}.varlist ";
    189 
    190         my $skycell_command = " dvoImageExtract -D CATDIR /turquoise/usr/projects/ps1/watersc1/tess/${tess_id} $skycell_id -o ${remote_outroot}.skyfile ";
    191 
    192         my $pswarp_command  = " pswarp -list ${remote_outroot}.imlist ";
    193         $pswarp_command    .= " -masklist ${remote_outroot}.masklist -variancelist ${remote_outroot}.varlist ";
    194         $pswarp_command    .= " -astromlist ${remote_outroot}.astrom ";
    195         $pswarp_command    .= " ${remote_outroot} ${remote_outroot}.skyfile ";
    196         $pswarp_command    .= " -F PSPHOT.PSF.SAVE PSPHOT.PSF.SKY.SAVE ";
    197         $pswarp_command    .= " -F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF ";
    198         $pswarp_command    .= " -F PSPHOT.BACKMDL PSPHOT.BACKMDL.MEF ";
    199         $pswarp_command    .= " -F SOURCE.PLOT.MOMENTS SOURCE.PLOT.SKY.MOMENTS ";
    200         $pswarp_command    .= " -F SOURCE.PLOT.PSFMODEL SOURCE.PLOT.SKY.PSFMODEL ";
    201         $pswarp_command    .= " -F SOURCE.PLOT.APRESID SOURCE.PLOT.SKY.APRESID ";
    202         $pswarp_command    .= " -recipe PSWARP $recipe_pswarp ";
    203         $pswarp_command    .= " -tracedest ${remote_outroot}.trace -log ${remote_outroot}.log ";
    204         $pswarp_command    .= " -threads 4 "; # -image_id ${image_id} -source_id ${source_id} ";
    205         $pswarp_command    .= " -recipe PPSTATS WARPSTATS ";
    206         $pswarp_command    .= " -dumpconfig ${remote_outroot}.pswarp.mdc -stats ${remote_outroot}.stats ";
    207 
    208 #       print "$pswarp_command \n";
    209        
    210         my $post_cmd_echo = " echo -n \"warptool  -addwarped -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_id ";
    211         $post_cmd_echo   .= " -path_base $remote_outroot -uri UNKNOWN ";
    212         $post_cmd_echo   .=  " -dbname $dbname " if defined $dbname;
    213         $post_cmd_echo   .= " -path_base $ipp_outroot -hostname $remote_hostname -dtime_script 0 \" > ${remote_outroot}.dbinfo ";
    214        
    215         my $post_cmd_SfM  = " ppStatsFromMetadata ${remote_outroot}.stats - WARP_SKYCELL >> ${remote_outroot}.dbinfo ";
    216 
    217         print CONFIG "${pre_cmd_ims} && ${pre_cmd_masks} && ${pre_cmd_vars} && ${pre_cmd_astrom} && ${skycell_command} && ${pswarp_command} && ${post_cmd_echo} && ${post_cmd_SfM} ";
    218         $job_index++;
    219 
    220         # Determine which output files need to be returned
    221         foreach my $component(@return_component_list) {
    222             my $filename = $ipprc->filename($component,$ipp_outroot,$skycell_id);
    223             my ($ipp_disk, $remote_disk) = uri_to_outputs_for_return( $filename);
    224             my $remote_outroot_dir = dirname($ipp_disk);
    225             print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk ";
    226         }
    227 
    228         print CONFIG "\n";
    229 #       die();
     96        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     97        &my_die("Unable to run warptool -pendingimfile ", $remote_id, $warp_id, $error_code, $fail_state);
     98    }
     99
     100    my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or
     101        &my_die("Unable to determine warp component information.", $remote_id, $warp_id, $PS_EXIT_PROG_ERROR, $fail_state);
     102    $warpData = parse_md_list($MDlist);
     103}
     104
     105# STEP 2: Iterate over the sub-components
     106{
     107    foreach my $warpEntry ( @{ $warpData } ) {
     108        my $workdir = $warpEntry->{workdir};
     109        my $exp_tag = $warpEntry->{exp_tag};
     110        my $skycell_id = $warpEntry->{skycell_id};
     111        my $tess_id = $warpEntry->{tess_id};
     112
     113        my $reduction = $warpEntry->{reduction};
     114        $reduction = 'DEFAULT' unless defined $warpEntry->{reduction};
     115
     116        my $recipe_pswarp = $ipprc->reduction($reduction, 'WARP_PSWARP'); # Recipe to use
     117        if ($recipe_pswarp eq "") {
     118            &my_die("Unable to determine PSWARP recipe for $reduction", $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
     119        }
     120
     121        my $ipp_outroot = "${workdir}/${exp_tag}/${exp_tag}.wrp.${warp_id}.${skycell_id}";
     122        print "$ipp_outroot\n";
     123        my $remote_outroot = &uri_local_to_remote($ipp_outroot);
     124
     125        my $command = "$warptool -scmap -warp_id $warp_id -skycell_id ${skycell_id}";
     126        $command   .= " -dbname $dbname " if defined($dbname);
     127
     128        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     129            run(command => $command, verbose => $verbose);
     130        unless ($success) {
     131            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     132            &my_die("Unable to run warptool -pendingimfile: $command ", $remote_id, $warp_id, $error_code, $fail_state);
     133        }
     134
     135        my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or
     136            &my_die("Unable to determine warp component information.", $remote_id, $warp_id, $PS_EXIT_PROG_ERROR, $fail_state);
     137        my $inData = parse_md_list($MDlist);
     138
     139        my $pre_cmd_ims = "ls -1 ";
     140        my $pre_cmd_masks= "ls -1 ";
     141        my $pre_cmd_vars = "ls -1 ";
     142        my $pre_cmd_astrom = "";
     143
     144        foreach my $imfile (@{ $inData }) {
     145            my $image = $ipprc->filename("PPIMAGE.CHIP", $imfile->{chip_path_base}, $imfile->{class_id});
     146            my $mask  = $ipprc->filename("PSASTRO.OUTPUT.MASK", $imfile->{cam_path_base}, $imfile->{class_id});
     147            my $var   = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $imfile->{chip_path_base}, $imfile->{class_id});
     148
     149            my $astrom= $ipprc->filename("PSASTRO.OUTPUT", $imfile->{cam_path_base});
     150
     151            my $remote_image = &uri_local_to_remote($image);
     152            my $remote_mask  = &uri_local_to_remote($mask);
     153            my $remote_var   = &uri_local_to_remote($var);
     154            my $remote_astrom= &uri_local_to_remote($astrom);
     155
     156            $pre_cmd_ims     .= " $remote_image ";
     157            $pre_cmd_masks   .= " $remote_mask  ";
     158            $pre_cmd_vars    .= " $remote_var   ";
     159            $pre_cmd_astrom   = "echo $remote_astrom > ${remote_outroot}.astrom ";
     160        }
     161        $pre_cmd_ims   .= "  > ${remote_outroot}.imlist ";
     162        $pre_cmd_masks .= "  > ${remote_outroot}.masklist ";
     163        $pre_cmd_vars  .= "  > ${remote_outroot}.varlist ";
     164
     165        my $skycell_command = " dvoImageExtract -D CATDIR /turquoise/usr/projects/ps1/watersc1/tess/${tess_id} $skycell_id -o ${remote_outroot}.skyfile ";
     166
     167        my $pswarp_command  = " pswarp -list ${remote_outroot}.imlist ";
     168        $pswarp_command    .= " -masklist ${remote_outroot}.masklist -variancelist ${remote_outroot}.varlist ";
     169        $pswarp_command    .= " -astromlist ${remote_outroot}.astrom ";
     170        $pswarp_command    .= " ${remote_outroot} ${remote_outroot}.skyfile ";
     171        $pswarp_command    .= " -F PSPHOT.PSF.SAVE PSPHOT.PSF.SKY.SAVE ";
     172        $pswarp_command    .= " -F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF ";
     173        $pswarp_command    .= " -F PSPHOT.BACKMDL PSPHOT.BACKMDL.MEF ";
     174        $pswarp_command    .= " -F SOURCE.PLOT.MOMENTS SOURCE.PLOT.SKY.MOMENTS ";
     175        $pswarp_command    .= " -F SOURCE.PLOT.PSFMODEL SOURCE.PLOT.SKY.PSFMODEL ";
     176        $pswarp_command    .= " -F SOURCE.PLOT.APRESID SOURCE.PLOT.SKY.APRESID ";
     177        $pswarp_command    .= " -recipe PSWARP $recipe_pswarp ";
     178        $pswarp_command    .= " -tracedest ${remote_outroot}.trace -log ${remote_outroot}.log ";
     179        $pswarp_command    .= " -threads $threads_req "; # -image_id ${image_id} -source_id ${source_id} ";
     180        $pswarp_command    .= " -recipe PPSTATS WARPSTATS ";
     181        $pswarp_command    .= " -dumpconfig ${remote_outroot}.pswarp.mdc -stats ${remote_outroot}.stats ";
     182
     183#       print "$pswarp_command \n";
     184
     185        my $post_cmd_echo = " echo -n \"warptool  -addwarped -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_id ";
     186        $post_cmd_echo   .=  " -dbname $dbname " if defined $dbname;
     187        $post_cmd_echo   .= " -uri ${ipp_outroot}.fits ";
     188        $post_cmd_echo   .= " -path_base $ipp_outroot -hostname $remote_hostname -dtime_script 0 \" > ${remote_outroot}.dbinfo ";
     189
     190        my $post_cmd_SfM  = " ppStatsFromMetadata ${remote_outroot}.stats - WARP_SKYCELL >> ${remote_outroot}.dbinfo ";
     191
     192        print CONFIG "${pre_cmd_ims} && ${pre_cmd_masks} && ${pre_cmd_vars} && ${pre_cmd_astrom} && ${skycell_command} && ${pswarp_command} && ${post_cmd_echo} && ${post_cmd_SfM} ";
     193        $job_index++;
     194
     195        # Determine which output files need to be returned
     196        foreach my $component(@return_component_list) {
     197            my $filename = $ipprc->filename($component,$ipp_outroot,$skycell_id);
     198            my ($ipp_disk, $remote_disk) = &uri_to_outputs_for_return( $filename);
     199            my $remote_outroot_dir = dirname($ipp_disk);
     200            print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk ";
     201        }
     202        print CONFIG "\n";
     203#       die();
    230204    }
    231205}
     
    236210close(GENERATE);
    237211
    238 #
    239 # Construct the moab command last, so we can use the job_index counter to estimate resources.  Somehow.
    240 my $proc_need = $job_index * $threads;       # how many total processors do we need?
    241 my $node_need = $proc_need / $proc_per_node; # this equals how many nodes?
    242 my $time_need = $job_index * $job_cost;      # How many seconds will this take?
    243 
    244 my $fill_factor = 0.8;  # This is the factor of how much of the time allocation we'd like to fill
    245 my ($time_req,$node_req);
    246 if ($node_need * $job_cost < $fill_factor * $min_nodes * $min_time) {
    247     $time_req = $min_time;
    248     $node_req = $min_nodes;
    249 }
    250 elsif ($node_need * $job_cost > $fill_factor * $max_nodes * $max_time) {
    251     $time_req = $max_time;
    252     $node_req = $max_nodes;
    253     print STDERR "You've requested the construction of a bundle that appears to need $node_need nodes and $job_cost time per job.  This exceeds the max limits ($max_nodes, $max_time).  Using those max values instead.  Good luck.\n";
    254 }
    255 else {
    256     $time_req = int(($node_need * $job_cost) / ($fill_factor * $max_nodes)) + 1;
    257     $node_req = int(($node_need * $job_cost) / ($fill_factor * $time_req)) + 1;
    258 }
    259 $time_req += 1; # Safety addition.
    260 
    261 open(COMMAND,  ">$disk_command") || &my_die("Couldn't open file? $disk_command",$remote_id,$PS_EXIT_SYS_ERROR);
    262 print COMMAND "#!/bin/tcsh\n";
    263 print COMMAND "##### Moab controll lines\n";
    264 print COMMAND "#MSUB -l nodes=${node_req}:ppn=${proc_per_node},walltime=${time_req}:00:00\n"; ## CHECK RESOURCES
    265 print COMMAND "#MSUB -j oe\n";
    266 print COMMAND "#MSUB -V\n";
    267 print COMMAND "#MSUB -o ${remote_root}warp.${remote_id}.out\n";
    268 print COMMAND "date\n";
    269 print COMMAND 'srun -n $SLURM_JOB_NUM_NODES -m cyclic -l /bin/hostname | sort -n | awk \'{printf "%s\n", $2}\' > hosts.${SLURM_JOB_ID}' . "\n";
    270 print COMMAND "${remote_root}/stask_chip.py $remote_config " . 'hosts.${SLURM_JOB_ID} 1' . "\n";
    271 print COMMAND "date\n";
    272 close(COMMAND);
    273 
    274212unless($no_update) {
    275     my $command = "remotetool -updaterun -remote_id $remote_id ";
    276     $command .= " -set_state pending ";
     213    my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $warp_id ";
     214    $command .= " -set_jobs $job_index";
     215    $command .= " -set_path_base $path_base";
     216    $command .= " -set_state prep_done";
    277217    $command .= " -dbname $dbname " if defined $dbname;
    278218
    279219    system($command);
    280220}
    281 
     221exit (0);
    282222
    283223## Common SC routines
     
    287227    my $ipp_disk= $ipprc->file_resolve( $neb_uri );
    288228    my $remote_disk = $ipp_disk;
    289    
     229
    290230    unless(defined($ipp_disk)) {
    291         my_die();
     231        &my_die( "Unable to generate file for $neb_uri ", $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
    292232    }
    293233
     
    303243    my $ipp_disk= $ipprc->file_resolve( $neb_uri , 1);
    304244    my $remote_disk = $ipp_disk;
    305    
     245
    306246    unless(defined($ipp_disk)) {
    307         my_die();
     247        &my_die( "Unable to generate file for $neb_uri ", $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state);
    308248    }
    309249
     
    317257sub uri_to_outputs { # (ipp_disk,remote_disk) = uri_to_output(neb_uri); Appends to TRANSFER and CHECK filehandles
    318258    my $neb_uri = shift;
    319     my ($ipp_disk, $remote_disk) = uri_convert( $neb_uri );
    320    
    321     unless (exists($file_filter{$neb_uri})) {
    322         $file_filter{$neb_uri} = 1;
    323         print TRANSFER "$ipp_disk\n";
    324         print CHECK    "$remote_disk\n";
    325     }
     259    my ($ipp_disk, $remote_disk) = &uri_convert( $neb_uri );
     260
     261    print TRANSFER "$ipp_disk\n";
     262    print CHECK    "$remote_disk\n";
    326263    return($ipp_disk,$remote_disk);
    327264}
     
    329266sub uri_to_outputs_for_return { # (ipp_disk,remote_disk) = uri_to_outputs_for_return(neb_uri); create ipp_disk, append to RETURN and GENERATE
    330267    my $neb_uri = shift;
    331     my ($ipp_disk, $remote_disk) = uri_convert_and_create( $neb_uri );
    332     unless (exists($file_filter{$neb_uri})) {
    333         $file_filter{$neb_uri} = 1;
    334         print RETURN "$ipp_disk\n";
    335         print GENERATE "$remote_disk\n";
    336     }
     268    my ($ipp_disk, $remote_disk) = &uri_convert_and_create( $neb_uri );
     269
     270    print RETURN "$ipp_disk\n";
     271    print GENERATE "$remote_disk\n";
    337272    return($ipp_disk,$remote_disk);
    338273}
     
    348283    return($remote_uri);
    349284}
    350  
     285
    351286sub uri_remote_to_local { #(local_neb_uri) = uri_remote_to_local(remote_uri);
    352287    # This needs to replace the remote root directory with the nebulous tag.
     
    354289    $remote_uri =~ s%${remote_root}%%;
    355290    my $local_uri  = "neb:///" . $remote_uri;
    356    
     291
    357292    return($local_uri);
    358293}
     
    361296sub my_die { # exit with status; my_die(message,stage_id,exit_code,exit_status);
    362297    my $msg = shift;
    363     my $id  = shift;
     298    my $remote_id  = shift;
     299    my $stage_id  = shift;
    364300    my $exit_code = shift;
    365301    my $exit_state = shift;
     
    368304
    369305    carp($msg);
    370    
    371     if (defined $id and not $no_update) {
    372         my $command = "remotetool -updaterun -remote_id $id";
    373         $command .= " -fault $exit_code " if defined $exit_code;
     306
     307    if (defined $remote_id and defined $stage_id and not $no_update) {
     308        my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $stage_id";
    374309        $command .= " -set_state $exit_state " if defined $exit_state;
    375310        $command .= " -dbname $dbname " if defined $dbname;
  • trunk/ippScripts/scripts/sc_remote_exec.pl

    r37812 r37833  
    1 #!/usr/bin/env perl 
     1#!/usr/bin/env perl
    22
    33use Carp;
     
    1616# Hard coded values
    1717my $DMZ_HOST = 'wtrw';
    18 my $SEC_HOST = 'mu-fe';
     18my @SEC_HOSTS= ('mu-fe1','mu-fe2','mu-fe3'
     19                # ,'mu-fe4'
     20    );
     21my $SEC_HOST = $SEC_HOSTS[int(rand(@SEC_HOSTS))]; # 'mu-fe';
    1922my $IPP_PATH = '/turquoise/usr/projects/cosmo/mswarren/ipp/';
    2023my $remote_root  = '/scratch3/watersc1/';
     
    3235
    3336# Options
    34 my ($remote_id,$path_base,$policy,$poll,$force,$job_id,$dbname,$verbose,$no_update,$camera);
    35 $force = 0;
     37my ($remote_id,$job_id,$path_base,$dbname,$verbose,$no_update,$camera);
    3638$verbose = 0;
    3739GetOptions(
    3840    'remote_id=s'   => \$remote_id,
    39     'job_id=s'      => \$job_id,
    4041    'path_base=s'   => \$path_base,
    41     'policy=s'      => \$policy,
    42     'poll'          => \$poll,
    43     'force-poll'    => \$force,
    4442    'camera=s'      => \$camera,
    4543    'dbname=s'      => \$dbname,
     
    5452
    5553my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id);
    56 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files                                   
     54my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    5755
    5856# Phase 1: See if we can actually do anything.
     
    6967unless ($rt_success) {
    7068    $rt_error_code = (($rt_error_code >> 8) or $PS_EXIT_PROG_ERROR);
    71     &my_die("UNable to run remotetool to determine remote run status",
    72             $remote_id,$rt_error_code);
    73 }
    74 my $rrData = $mdcParser->parse(join "", @$rt_stdout_buf) or
    75     &my_die("UNable to run remotetool to determine remote run status",
    76             $remote_id,$rt_error_code);
     69    &my_die("Unable to run remotetool to determine remote run status", $remote_id, $rt_error_code);
     70}
     71my $rrData = $mdcParser->parse(join "", @$rt_stdout_buf) or
     72    &my_die("Unable to run remotetool to determine remote run status", $remote_id, $rt_error_code);
    7773my $rrData2 = parse_md_list($rrData);
    7874my $runData = ${ $rrData2 }[0]; # There should be only one
    7975
    80 # These are operations we only need to do on the first call, not on subsequent poll operations.
    81 unless ($poll) {
     76my ($remote_path) = &uri_local_to_remote($path_base);
     77print "REMOTE PATH: $remote_path\n";
     78
    8279# Phase 2: Ensure files are in place:
    8380# Copy command files
    84     my @files = ();
    85    
    86     my $uri_command = $path_base . ".cmd";
    87     my $uri_transfer= $path_base . ".transfer";
    88     my $uri_check   = $path_base . ".check";
    89     my $uri_config  = $path_base . ".config";
    90     my $uri_generate= $path_base . ".generate";
    91     my $uri_return  = $path_base . ".return";
    92 
    93     my $disk_command = $ipprc->file_resolve($uri_command);
    94     my $disk_transfer= $ipprc->file_resolve($uri_transfer);
    95     my $disk_check   = $ipprc->file_resolve($uri_check);
    96     my $disk_config  = $ipprc->file_resolve($uri_config);
    97     my $disk_generate= $ipprc->file_resolve($uri_generate);
    98     my $disk_return  = $ipprc->file_resolve($uri_return);
    99    
    100     scp_put($disk_command,uri_local_to_remote($uri_command));
    101     scp_put($disk_transfer,uri_local_to_remote($uri_transfer));
    102     scp_put($disk_check,uri_local_to_remote($uri_check));
    103     scp_put($disk_config,uri_local_to_remote($uri_config));
    104     scp_put($disk_generate,uri_local_to_remote($uri_generate));
    105     scp_put($disk_return, uri_local_to_remote($uri_return));
    106    
    107 # Run check command
    108     my (undef,$remote_check) = uri_convert($uri_check);
    109     my (undef,$remote_transfer)= uri_convert($uri_transfer);
    110 
    111     my $ssh_check_stdout = ssh_exec_command("${remote_root}/sc_transfer_tool.pl --input $remote_check --fetch $remote_transfer");
    112     # We no longer need to parse this output, as it retrieves files itself.
    113     foreach my $l (split /\n/, (join '', @$ssh_check_stdout)) {
    114         print "$l\n";
    115     }
     81my @files = ();
     82
     83my $uri_command = $path_base . ".cmd";
     84my $uri_transfer= $path_base . ".transfer";
     85my $uri_check   = $path_base . ".check";
     86my $uri_config  = $path_base . ".config";
     87my $uri_generate= $path_base . ".generate";
     88my $uri_return  = $path_base . ".return";
     89
     90my $disk_command = $ipprc->file_resolve($uri_command);
     91my $disk_transfer= $ipprc->file_resolve($uri_transfer);
     92my $disk_check   = $ipprc->file_resolve($uri_check);
     93my $disk_config  = $ipprc->file_resolve($uri_config);
     94my $disk_generate= $ipprc->file_resolve($uri_generate);
     95my $disk_return  = $ipprc->file_resolve($uri_return);
     96
     97&scp_put($disk_command,  &uri_local_to_remote($uri_command));
     98&scp_put($disk_transfer, &uri_local_to_remote($uri_transfer));
     99&scp_put($disk_check,    &uri_local_to_remote($uri_check));
     100&scp_put($disk_config,   &uri_local_to_remote($uri_config));
     101&scp_put($disk_generate, &uri_local_to_remote($uri_generate));
     102&scp_put($disk_return,   &uri_local_to_remote($uri_return));
     103
     104my $ssh_check_stdout = &ssh_exec_command("${remote_root}/sc_transfer_tool.pl --input $remote_path --fetch");
     105
     106# We no longer need to parse this output, as it retrieves files itself.
     107foreach my $l (split /\n/, (join '', @$ssh_check_stdout)) {
     108    print "$l\n";
     109}
    116110
    117111# Run real command
    118     my (undef,$remote_command) = uri_convert($uri_command);
    119     my $ssh_exec_stdout = ssh_exec_command("msub -V $remote_command");
    120     if ($#{ $ssh_exec_stdout } != -1) { # Parse the output
    121         $job_id = ${ $ssh_exec_stdout }[0];
    122         chomp($job_id);
    123         $job_id =~ s/\s+//g;
    124     }
    125 
    126     unless(defined($job_id)) { # If we don't have a job_id from this command, it didn't run correctly.
    127         &my_die("No job_id returned.  Sorry.",$remote_id,$PS_EXIT_PROG_ERROR);
    128     }
    129 
    130     # Notify the database that this entry is currently running.
    131     my $command = "$remotetool -updaterun -remote_id $remote_id ";
    132     $command .= " -set_state run ";
    133     $command .= " -job_id $job_id ";
    134     $command .= " -dbname $dbname " if defined $dbname;
    135    
    136     system($command);
    137    
    138 } # End of exec phase
    139 
    140 # Check that we have a valid job_id, either from the command line, or from the msub command.
     112my (undef,$remote_command) = &uri_convert($uri_command);
     113my $ssh_exec_stdout = &ssh_exec_command("msub -V $remote_command");
     114if ($#{ $ssh_exec_stdout } != -1) { # Parse the output
     115    $job_id = ${ $ssh_exec_stdout }[0];
     116    chomp($job_id);
     117    $job_id =~ s/\s+//g;
     118}
     119
    141120unless(defined($job_id)) { # If we don't have a job_id from this command, it didn't run correctly.
    142     &my_die("No job_id returned.  Sorry.",$remote_id,$PS_EXIT_PROG_ERROR);
    143 }
    144 
    145 
    146 # Poll the job status?
    147 my $poll_count = 0;
    148 my $poll_max   = 1; # If it isn't finished now, it's unlikely to magically finish in the next five minutes.
    149 my $poll_sleep = 60;
    150 my $poll_response = 0;
    151 my $poll_word  = "nothing";
    152 
    153 if ($force) {
    154     $poll_response = 1;
    155     $poll_word     = "Completed";
    156 }
    157 
    158 while (($poll_count < $poll_max)&&($poll_response != 1)&&($poll_response != -1)&&($force != 1)) {
    159     if ($verbose) {
    160         print "Polling code.  Sleeping.  $poll_count of $poll_max $poll_response\n";
    161     }
    162     unless ($poll_count == 0) {
    163         sleep($poll_sleep);
    164     }
    165     ($poll_response,$poll_word) = poll_job($job_id);
    166 
    167     if ($poll_response == 1) { # This job has completed
    168         last;
    169     }
    170     elsif ($poll_response == -1) { # This job has an error
    171         warn("The job exited incorrectly: $remote_id $job_id $poll_word.  Attempting to recover what we can.");
    172         $poll_response = 1; # To fool the check later into proceding
    173     }
    174     $poll_count++;
    175 }
    176 if ($verbose) {
    177     print "Stopped Polling code.  $poll_count of $poll_max $poll_response\n";
    178 }
    179 if ($poll_response != 1) {
    180     &my_die("Job hasn't completed.  Ending polling.", $remote_id, 0, "run", $job_id);
    181 }
    182 
    183 
    184 # Initialize the remote side to sync things
    185 
    186 # Once sync completes, execute all the database commands
    187 # Grab the return list
    188 my $uri_return  = $path_base . ".return";
    189 my ($ipp_return,$remote_return) = uri_convert($uri_return);
    190 # We shouldn't need to get this file.  We made that file.
    191 #scp_get($remote_return,$ipp_return);
    192 
    193 # Construct list of dbinfo files we'll need to execute.
    194 my @returned_files = ();
    195 my @dbinfo_files   = ();
    196 my @dbindex        = ();
    197 my $iter           = 0;
    198 open(RETURN,   "$ipp_return") || &my_die("Couldn't open file? $ipp_return", $remote_id,$PS_EXIT_SYS_ERROR);
    199 while (<RETURN>) {
    200     chomp;
    201     push @returned_files, $_;
    202     if ($_ =~ /dbinfo/) {
    203         push @dbinfo_files, $_;
    204         push @dbindex, $iter;
    205     }
    206     $iter++;
    207 
    208 }
    209 close(RETURN);
    210 print STDERR "Expect $#dbinfo_files dbinfo files\n";
    211 
    212 my $first = 0;
    213 my $last  = $#dbinfo_files;
    214 my $mid   = 0;
    215 my $range = 20;  # How wide of a chunk to look through to catch threading drops
    216 my $offset = 0;  # Offset to start from.
    217 
    218 # Feed the return list into the transfer tool
    219 # If this fails, we should go to an auth wait point.
    220 if ($poll_word eq 'Completed') { 
    221     # We're complete.  All files should exist on disk
    222     my $iter = 0;
    223     my $transfer_success = 1;
    224     do {
    225         $transfer_success = 1;
    226         $iter++;
    227         check_ssh_connection();
    228         my $return_push_output = ssh_exec_command("${remote_root}/sc_transfer_tool.pl --input $remote_return --offset $offset");
    229         my $return_push_output_print = join "\n", @{ $return_push_output };
    230         if ($return_push_output_print =~ /exited with value 255/) { $transfer_success = 0; }
    231         print "$return_push_output_print\n";
    232     } while (($transfer_success != 1) &&  ($iter < 10));  # Try harder;
    233 }
    234 else {
    235     # Just try and fetch things, because we didn't complete correctly, it seems.
    236     my $return_push_output = ssh_exec_command("${remote_root}/sc_transfer_tool.pl --input $remote_return --offset $offset");
    237     my $return_push_output_print = join "\n", @{ $return_push_output };
    238     print "$return_push_output_print\n";
    239 }
    240 
    241 foreach my $file (@dbinfo_files) {
    242     open(DBF,"$file") || warn "Missing file $file\n";
    243     my $cmd = <DBF>;
    244     close(DBF);
    245     chomp($cmd);
    246 #    print STDERR "$file $cmd\n";
    247     $cmd =~ s/-/ -/g; # This is just a safety check for missing space.
    248     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    249         run(command => $cmd, verbose => $verbose);
    250     unless ($success) {
    251 
    252         # This shouldn't fail, but we also can't suddenly abort if something does fail. 
    253         # Now we're going to drop the component that owns this dbinfo, which should force a retry.
    254         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    255         warn("The command that shouldn't fail has failed: $file $cmd $remote_id $error_code");
    256         if ($poll_word ne 'Completed') {  # If the job claims it completed, then we're fighting the network.
    257             drop_component($remote_id,$cmd,$file);
    258         }
    259     }
    260 
    261 }
    262 
    263 # We're done, so set the state and exit.
    264 &my_die("Finished",$remote_id,0,"full");
    265 
     121    &my_die("No job_id returned.  Sorry.", $remote_id, $PS_EXIT_PROG_ERROR);
     122}
     123
     124# Notify the database that this entry is currently running.
     125&my_die("Finished", $remote_id, 0, "run", $job_id);
    266126
    267127# END PROGRAM
    268 
    269128
    270129sub check_ssh_connection {
     
    272131
    273132    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    274         run(command => $cmd, verbose => $verbose);
    275     unless ($success) {
    276         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    277         &my_die("Authorization check failed.",$remote_id,0,'auth');
     133        run(command => $cmd, verbose => $verbose);
     134    unless ($success) {
     135        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     136        &my_die("Authorization check failed.", $remote_id, 0, 'pending');
    278137    }
    279138}
     
    285144
    286145    my $directory = dirname($destination);
    287     ssh_exec_command("mkdir -p $directory");
    288 
    289     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    290         run(command => $cmd, verbose => $verbose);
    291     unless ($success) {
    292         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    293         &my_die();
     146    &ssh_exec_command("mkdir -p $directory");
     147
     148    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     149        run(command => $cmd, verbose => $verbose);
     150    unless ($success) {
     151        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     152        &my_die("failed to send file $file to LANL", $remote_id, $error_code);
    294153    }
    295154}
     
    302161
    303162    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    304         run(command => $cmd, verbose => $verbose);
    305     unless ($success) {
    306         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    307         &my_die();
     163        run(command => $cmd, verbose => $verbose);
     164    unless ($success) {
     165        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     166        &my_die("failed to get file $file from LANL", $remote_id, $error_code);
    308167    }
    309168}
     
    311170sub ssh_exec_command {
    312171    my $cmd = shift;
    313     $cmd = "$ssh $DMZ_HOST ssh  ${SEC_HOST} $cmd";
     172    $cmd = "$ssh -n $DMZ_HOST ssh  ${SEC_HOST} $cmd";
    314173    print "EXEC: $cmd\n";
    315174    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    316         run(command => $cmd, verbose => $verbose);
    317     unless ($success) {
    318         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    319         # If we failed, see if we failed due to authorization.
    320         check_ssh_connection();
    321         &my_die("Failed to execute command: >>$cmd<<");
     175        run(command => $cmd, verbose => $verbose);
     176    unless ($success) {
     177        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     178        # If we failed, see if we failed due to authorization.
     179        check_ssh_connection();
     180        &my_die("Failed to execute remote command: >>$cmd<<", $remote_id, $error_code);
    322181    }
    323182    return ($stdout_buf);
    324 }   
    325 
    326 sub poll_job {
    327     my $job_id = shift;
    328     my $response_array = ssh_exec_command("checkjob -v $job_id");
    329     my $response = join "\n", @$response_array;
    330    
    331     if ($response =~ /State: Running/) {
    332         return(0,"Running");
    333     }
    334     elsif ($response =~ /State: Completed/) {
    335         return(1,"Completed");
    336     }
    337     elsif ($response =~ /State: Idle/) {
    338         return(-2,"Idle");
    339     }
    340     else {
    341         my $response_word = $response;
    342         $response_word =~ s/.*State: //;
    343         $response_word =~ s/\n.*//;
    344         return(-1,$response_word);
    345     }
    346 }
    347 
    348 
     183}
     184
     185# neb URI to (ipp_disk,remote_disk)
    349186sub uri_convert {
    350187    my $neb_uri = shift;
    351188    my $ipp_disk= $ipprc->file_resolve( $neb_uri );
    352189    my $remote_disk = $ipp_disk;
    353    
     190
    354191    unless(defined($ipp_disk)) {
    355         my_die();
     192        &my_die("Failed to generate or find uri $neb_uri", $remote_id, $PS_EXIT_SYS_ERROR);
    356193    }
    357194
     
    363200}
    364201
    365 sub uri_to_outputs {
    366     my $neb_uri = shift;
    367     my ($ipp_disk, $remote_disk) = uri_convert( $neb_uri );
    368 
    369 #    print TRANSFER "$ipp_disk\n";
    370 #    print CHECK    "$remote_disk\n";
    371     return($ipp_disk,$remote_disk);
    372 }
    373 
     202# neb URI to remote URI-on-disk
    374203sub uri_local_to_remote {
    375204    # This needs to replace the nebulous tag with the remote root.
     
    382211    return($remote_uri);
    383212}
    384  
    385 sub uri_remote_to_local {
    386     # This needs to replace the remote root directory with the nebulous tag.
    387     my $remote_uri = shift;
    388     $remote_uri =~ s%${remote_root}%%;
    389     my $local_uri  = "neb:///" . $remote_uri;
    390    
    391     return($local_uri);
    392 }
    393 
    394 sub drop_component {
    395     my $remote_id = shift;
    396     my $cmd = shift;
    397     my $file = shift;
    398 
    399     if ($cmd eq '') {
    400         # Zero byte file.  This dbinfo was never constructed properly.
    401        
    402         # Steal the stage_id from the filename.  This isn't something I'm happy about.
    403         my $stage = $runData->{stage};
    404         my $stage_id = $file;
    405         if ($stage eq 'chip') {
    406             $stage_id =~ s/^.*ch\.//;
    407         }
    408         elsif ($stage eq 'camera') {
    409             $stage_id =~ s/^.*cm\.//;
    410         }
    411         elsif ($stage eq 'warp') {
    412             $stage_id =~ s/^.*wrp\.//;
    413         }
    414         elsif ($stage eq 'stack') {
    415             $stage_id =~ s/^.*stk\.//;
    416         }
    417         $stage_id =~ s/\..*$//;
    418        
    419         # Drop this from the database
    420         my $drop_cmd = "$remotetool -dropcomponent -remote_id $remote_id -stage_id $stage_id ";
    421         $drop_cmd   .= " -dbname $dbname " if defined($dbname);
    422         system($drop_cmd);
    423     }
    424 
    425 }
    426213
    427214sub my_die {
     
    434221
    435222    carp($msg);
    436    
     223
    437224    if (defined $id and not $no_update) {
    438         my $command = "$remotetool -updaterun -remote_id $id";
    439         $command .= " -fault $exit_code " if defined $exit_code;
    440         $command .= " -job_id $job_id " if defined $jobid;
    441         $command .= " -set_state $exit_state " if defined $exit_state;
    442         $command .= " -dbname $dbname " if defined $dbname;
    443 
    444         system($command);
     225        my $command = "$remotetool -updaterun -remote_id $id";
     226        $command .= " -fault $exit_code " if defined $exit_code;
     227        $command .= " -job_id $job_id " if defined $jobid;
     228        $command .= " -set_state $exit_state " if defined $exit_state;
     229        $command .= " -dbname $dbname " if defined $dbname;
     230
     231        system($command);
    445232    }
    446233
  • trunk/ippScripts/scripts/sc_transfer_tool.pl

    r37125 r37833  
    1010use Sys::Hostname;
    1111
     12my $scp_cmd = "/usr/projects/cosmo/amd6100/bin/scp";
     13my $ssh_cmd = "/usr/projects/cosmo/amd6100/bin/ssh";
     14
    1215my $remote_root = '/lustre/scratch1/turquoise/watersc1/ps1/';
    13 $remote_root = '/scratch3/watersc1/';
    14 my $local_raw = "${remote_root}/raw/";
     16   $remote_root = '/scratch3/watersc1/';
     17
     18#my $local_raw = "${remote_root}/tmp/";
    1519my $local_tmp = "${remote_root}/tmp/";
    16 my $threads = 10;
    17 my @hosts = ('ippc20.ipp.ifa.hawaii.edu','ippc24.ipp.ifa.hawaii.edu','ippc28.ipp.ifa.hawaii.edu',
    18              'ippc21.ipp.ifa.hawaii.edu','ippc25.ipp.ifa.hawaii.edu','ippc29.ipp.ifa.hawaii.edu',
    19              'ippc22.ipp.ifa.hawaii.edu','ippc26.ipp.ifa.hawaii.edu',
    20              'ippc23.ipp.ifa.hawaii.edu','ippc27.ipp.ifa.hawaii.edu'    );
     20my $threads = 11;
     21my @hosts = (
     22    'ippc20.ipp.ifa.hawaii.edu',
     23    'ippc21.ipp.ifa.hawaii.edu',
     24    'ippc22.ipp.ifa.hawaii.edu',
     25    'ippc23.ipp.ifa.hawaii.edu',
     26    'ippc24.ipp.ifa.hawaii.edu',
     27    'ippc25.ipp.ifa.hawaii.edu',
     28    'ippc26.ipp.ifa.hawaii.edu',
     29    'ippc27.ipp.ifa.hawaii.edu',
     30    'ippc28.ipp.ifa.hawaii.edu',       
     31#'ippc29.ipp.ifa.hawaii.edu', (mark's hi-mem test machine)
     32#'ippc30.ipp.ifa.hawaii.edu', (postage stamp server)   
     33    'ippc31.ipp.ifa.hawaii.edu',       
     34    'ippc32.ipp.ifa.hawaii.edu'   
     35    );
    2136@hosts = (@hosts, @hosts, @hosts, @hosts, @hosts);
    22 my $input_file;
     37my %server_options = (
     38    'ippc20.ipp.ifa.hawaii.edu' => '',
     39    'ippc21.ipp.ifa.hawaii.edu' => '',
     40    'ippc22.ipp.ifa.hawaii.edu' => '',
     41    'ippc23.ipp.ifa.hawaii.edu' => '',
     42    'ippc24.ipp.ifa.hawaii.edu' => '',
     43    'ippc25.ipp.ifa.hawaii.edu' => '',
     44    'ippc26.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes',
     45    'ippc27.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes',
     46    'ippc28.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes',
     47    'ippc29.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes',
     48    'ippc30.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes',
     49    'ippc31.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes',
     50    'ippc32.ipp.ifa.hawaii.edu' => '', # -o NoneSwitch=yes -o NoneEnabled=yes'
     51    );
     52
     53my $input_path;
     54my $local_file;
     55my $remote_file;
     56
    2357my $verbose = 0;
    2458my $fetch = 0;
    2559my $offset = 0;
     60my $retry = 0;
     61my $quickfetch = 0;
    2662
    2763GetOptions(
    2864    'threads=s'   => \$threads,
    29     'input=s'     => \$input_file,
    30     'fetch=s'     => \$fetch,
     65    'input=s'     => \$input_path,
    3166    'offset=s'    => \$offset,
     67    'fetch'       => \$fetch,
    3268    'verbose'     => \$verbose,
     69    'retry'       => \$retry,
     70    'quickfetch'  => \$quickfetch,
    3371    ) or pod2usage( 2 );
    3472pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2) if @ARGV;
    3573pod2usage( -msg => "Required options: --input", -exitval => 3) unless
    36     defined($input_file);
     74    defined($input_path);
    3775
    3876my $hostname = hostname;
     
    4179# split in input file list
    4280unless(-d $local_tmp) { system("mkdir -p $local_tmp"); }
    43 unless(-d $local_raw) { system("mkdir -p $local_raw"); }
    44 
    45 open(I,$input_file) || die "Couldn't find input file specified\n";
     81#unless(-d $local_raw) { system("mkdir -p $local_raw"); }
     82
     83# we have two modes: fetch (-> LANL) and return (-> IPP)
     84
    4685if ($fetch) {
    47     open(F,$fetch) || die "Couldn't find fetch file specified\n";
    48 }
    49 my $input_base = basename($input_file);
    50 my @filehandles;
     86    $local_file = "$input_path.check";
     87    $remote_file = "$input_path.transfer";
     88} else {
     89    $local_file = "$input_path.generate";
     90    $remote_file = "$input_path.return";
     91}
     92my $input_base = basename($local_file);
     93
     94unless ($retry) {
     95  # open the input file list
     96  open (LOCAL,$local_file) || die "Couldn't find input file specified $local_file\n";
     97  open (REMOTE,$remote_file) || die "Couldn't find input file specified $remote_file\n";
     98 
     99  # generate N output files (to be fed to the N rsync / tar threads)
     100  my @filehandles;
     101  my $i;
     102  my $line = 0;
     103  for ($i = 0; $i < $threads; $i++) {
     104      open($filehandles[$i], ">${local_tmp}/${input_base}.${i}");
     105  }
     106 
     107  unless ($fetch) {
     108      my $stat_file = "$input_path.stat";
     109      print "STATFILE: $stat_file\n";
     110      open (STATFILE, ">$stat_file");
     111  }
     112 
     113  $i = 0;
     114  while (my $Lname = <LOCAL>) {
     115      my $Rname = <REMOTE>;
     116 
     117      chomp $Lname;
     118      chomp $Rname;
     119 
     120      $line++;
     121      if ($line < $offset) { next; } # I think this is off-by-one in a safe direction
     122 
     123      if ($line % 250 == 0)  { print STDERR "line $line : $Lname\n"; }
     124 
     125      $i = int(rand($#filehandles + 1));
     126      if ($i >= $threads) {
     127        print STDERR "HUH: impossible file handle?\n";
     128        die;
     129      }
     130 
     131      # if we are fetching, and 'quickfetch' is requested, skip file if it exists
     132      # NOTE: this does not check that the transfer was complete or the file is current
     133 
     134      if ($fetch) {
     135        # We are fetching, and do not already have this file.
     136        if ($quickfetch && (-e $Lname)) { next; }
     137        print { $filehandles[$i] } "$Rname\n";
     138      } else {
     139        # We are pushing, but only send back files we actually have
     140        # we cannot have the remote file unless the local file exists
     141        # (it is a link to the local file and is generated after the local file)
     142        my $haveRemote = -e "$local_tmp/$Rname";
     143        if ($haveRemote) {
     144            print { $filehandles[$i] } "$Rname\n";
     145            print STATFILE "$Rname PASS\n";
     146        } else {
     147            my $haveLocal = -e $Lname;
     148            if ($haveLocal) {
     149                print STATFILE "$Rname PART\n";
     150            } else {
     151                print STATFILE "$Rname FAIL\n";
     152            }
     153        }
     154      }
     155  }
     156  close(LOCAL);
     157  close(REMOTE);
     158  unless ($fetch) { close(STATFILE); }
     159 
     160  for ($i = 0; $i < $threads; $i++) {
     161      close($filehandles[$i]);
     162  }
     163}
     164
    51165my $i;
    52 my $line = 0;
    53 for ($i = 0; $i < $threads; $i++) {
    54     open($filehandles[$i], ">${local_tmp}/${input_base}.${i}");
    55 }
    56 $i = 0;
    57 while(<I>) {
    58     chomp;
    59     $line++;
    60     if ($line < $offset) { next; } # I think this is off-by-one in a safe direction
    61 
    62     $i = int(rand($#filehandles + 1));
    63 
    64     my $fline;
    65     if ($fetch) {
    66         $fline = <F>;
    67     }
    68     if (($fetch)&&(!(-e $_))) {  # We are fetching, and do not already have this file.
    69         print { $filehandles[$i] } $fline;
    70     }
    71     elsif (!($fetch)) { # We are pushing
    72         # The rsync call expects to find files of a given name in the directory specified.
    73 #       print { $filehandles[$i] } "${local_tmp}/$_" . "\n";
    74         print { $filehandles[$i] } "$_" . "\n";
    75     }
    76 }
    77 close(I);
    78 
    79 for ($i = 0; $i < $threads; $i++) {
    80     close($filehandles[$i]);
    81 }
    82 
    83 # fork the tars
     166# fork the rsync
    84167my @pids = ();
    85168for ($i = 0; $i < $threads; $i++) {
     
    89172        my $code = 0;
    90173        if ($fetch) {
    91             $code = fetch_task($host,"${input_base}.${i}", 0);
    92         }
    93         else {
     174            $code = fetch_task($host,"${local_tmp}/${input_base}.${i}", 0);
     175        } else {
    94176            $code = transfer_task($host,"${local_tmp}/${input_base}.${i}", 0);
    95177        }
     178        print STDERR "$host $input_base $i $code\n";
    96179        exit($code);
    97180    }
    98181}
     182
     183my $global_status = 0;
    99184for ($i = 0; $i < $threads; $i++) {
    100185    waitpid($pids[$i],0);
     186    my $this_status = $?;
     187    print "exit status $hosts[$i] : $this_status\n";
     188    if ($this_status) { $global_status = ($this_status >> 8); }
    101189}
    102190
     
    105193}
    106194
     195# my $scp_command = "$scp_cmd $option ${local_tmp}/${input_base}.stat $hosts[0]:/tmp/";
     196# print "$scp_command\n";
     197# system("$scp_command");
     198# XXX check return status
     199
     200print "global status: $global_status\n";
     201exit ($global_status);
    107202
    108203# distribute bundles to nodes
     
    115210    my $error = shift;
    116211
    117     # the transform bit is there because it looks like the ' gets dropped, so the * is interpreted, and why is our tar so out of date?
    118 #    my $command = "tar cf - --ignore-failed-read --dereference --files-from=${transfer_filelist} | /usr/projects/cosmo/amd6100/bin/ssh -o NoneSwitch=yes -o NoneEnabled=yes $destination_host tar xf - -C /data/ --transform '" . 's,^.\*/data/,,' . "' --dereference";
    119     my $command = "rsync -Lpt -e '/usr/projects/cosmo/amd6100/bin/ssh -o NoneSwitch=yes -o NoneEnabled=yes' --files-from=${transfer_filelist} ${local_tmp} ${destination_host}:/";
     212    my $option = $server_options{$destination_host};
     213
     214    my $command = "rsync -L --size-only --omit-dir-times -e '$ssh_cmd ${option}' --files-from=${transfer_filelist} ${local_tmp} ${destination_host}:/";
    120215    print STDERR "$command\n";
    121 
     216   
    122217    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    123218        run(command => $command, verbose => $verbose);
     219
     220    my $return_value = 0;
    124221    unless ($success) {
    125         print STDERR "ERROR:  $error_code\n";
    126 #       my $std = join "\n", @{ $stdout_buf };
    127 #       print "STDOUT: $std\n";
    128 #       $std = join "\n", @{ $stderr_buf };
    129 #       print "STDERR: $std\n";
    130 
    131 #       foreach my $line (@{ $stderr_buf }) {  # This is a hack.  A messy ugly hack.
    132 #           if ($line =~ /No such file or directory/) {
    133 #               my $file = (split /\s+/, $line)[1];
    134 #               $file =~ s/:$//;
    135 #               if ($file !~ /nebulous/) { next; }
    136 #               print STDERR "Touching $file so tar can continue.\n";
    137 #               system("touch $file");
    138 #           }
    139 #       }
    140 
    141         warn("Transfer of $transfer_filelist to $destination_host failed with error $error_code.");
    142         $error++;
    143         if ($error < 4) {
    144             $error_code = transfer_task($destination_host,$transfer_filelist,$error);
    145         }
    146         else {
    147             die("Failed too many times $error $destination_host $transfer_filelist");
     222        if ($error_code =~ /value 23/) {
     223            print STDERR "Some files failed to transfer.  Partial run?\n";
     224            $error = 23;
     225            $return_value = 23;
     226        } else {
     227            print STDERR "ERROR:  $error_code\n";
     228            warn("Transfer of $transfer_filelist to $destination_host failed with error $error_code.");
     229            sleep(5);
     230            $error++;
     231            if ($error < 4) {
     232                $error_code = transfer_task($destination_host,$transfer_filelist,$error);
     233            }
     234            else {
     235                die("Failed too many times $error $destination_host $transfer_filelist");
     236            }
     237            $return_value = 1;
    148238        }
    149239    }
    150     return($error_code);
     240    return($return_value);
    151241}
    152242   
     
    156246    my $error = shift;
    157247
    158     system("/usr/projects/cosmo/amd6100/bin/scp -o NoneSwitch=yes -o NoneEnabled=yes ${local_tmp}/${transfer_filelist} ${destination_host}:/tmp/");
    159     my $command = "/usr/projects/cosmo/amd6100/bin/ssh -o NoneSwitch=yes -o NoneEnabled=yes $destination_host tar cf - --ignore-failed-read  --dereference --files-from=/tmp/${transfer_filelist} | tar xf - -C ${local_raw} --skip-old-files --warning=existing-file --dereference ";
     248    my $option = $server_options{$destination_host};
     249
     250    my $command = "rsync --size-only -e '$ssh_cmd ${option}' --files-from=${transfer_filelist} ${destination_host}:/ ${local_tmp}";
    160251    print STDERR "$command\n";
    161252
    162     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     253    my $error_code = 0;
     254    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    163255        run(command => $command, verbose => $verbose);
    164256    unless ($success) {
    165         $error_code = (($error_code >> 8) or 4);
    166         warn("Transfer of $transfer_filelist to $destination_host failed with error $error_code.");
    167         $error++;
    168         if ($error < 4) {
    169             $error_code = fetch_task($destination_host,$transfer_filelist,$error);
    170         }
    171         else {
    172             die("Failed too many times $error $destination_host $transfer_filelist");
     257        print "raw error_msg: $error_msg...\n";
     258        ($error_code) = $error_msg =~ m/exited with value (\d+)/;
     259        warn("Transfer of files in $transfer_filelist from $destination_host failed with error ($error_code) $error_msg.");
     260        print "*** stdout: *** \n";
     261        foreach my $line (@$stdout_buf) {
     262            print STDERR "stdout: $line\n";
     263        }
     264        print "*** stderr: *** \n";
     265        foreach my $line (@$stderr_buf) {
     266            print STDERR "stderr: $line\n";
     267        }
     268        if ($error_code == 23) {
     269            print STDERR "Some files failed to transfer\n";
     270        } else {
     271            $error++;
     272            if ($error < 4) {
     273                $error_code = fetch_task($destination_host,$transfer_filelist,$error);
     274            } else {
     275                print STDERR "Failed too many times $error $destination_host $transfer_filelist\n";
     276            }
    173277        }
    174278    }
  • trunk/ippScripts/scripts/stack_skycell.pl

    r36397 r37833  
    225225    $num++;
    226226
    227     my $image = $file->{uri};   # Image name
     227#    my $image = $file->{uri};   # Image name
     228    my $image = $ipprc->filename("PSWARP.OUTPUT", $file->{path_base} ); # Image name
    228229    my $mask = $ipprc->filename( "PSWARP.OUTPUT.MASK", $file->{path_base} ); # Mask name
    229230    my $weight = $ipprc->filename( "PSWARP.OUTPUT.VARIANCE", $file->{path_base} ); # Weight name
  • trunk/ippTools/share/Makefile.am

    r37551 r37833  
    524524        remotetool_definebyquery_warp.sql \
    525525        remotetool_definebyquery_stack.sql \
     526        remotetool_definebyquery_staticsky.sql \
    526527        remotetool_dropcomponent.sql \
     528        remotetool_listcomponent.sql \
     529        remotetool_doneprep.sql \
    527530        remotetool_updatepoll.sql
  • trunk/ippTools/share/laptool_exposures.sql

  • trunk/ippTools/share/pxadmin_create_tables.sql

    r37769 r37833  
    23852385    remote_id BIGINT,
    23862386    stage_id  BIGINT,
     2387    jobs      INT
     2388    state     VARCHAR(64) NOT NULL,
     2389    path_base VARCHAR(255),
    23872390    KEY (stage_id),
    23882391    FOREIGN KEY (remote_id) REFERENCES remoteRun(remote_id)
  • trunk/ippTools/share/remotetool_definebyquery_cam.sql

    r36968 r37833  
    1111LEFT JOIN
    1212
    13 (SELECT remote_id,remoteRun.stage,remoteRun.label,remoteComponent.stage_id,remoteRun.state 
    14    FROM remoteRun 
     13(SELECT remote_id,remoteRun.stage,remoteRun.label,remoteComponent.stage_id,remoteRun.state
     14   FROM remoteRun
    1515   JOIN remoteComponent USING (remote_id)
    1616WHERE
    17 remoteRun.stage = 'camera'
     17remoteRun.stage = 'camera' and remoteComponent.state != 'retry'
    1818-- where hook %s
    1919) AS R
  • trunk/ippTools/share/remotetool_definebyquery_chip.sql

    r36968 r37833  
    1111LEFT JOIN
    1212
    13 (SELECT remote_id,remoteRun.stage,remoteRun.label,remoteComponent.stage_id,remoteRun.state 
    14    FROM remoteRun 
     13(SELECT remote_id,remoteRun.stage,remoteRun.label,remoteComponent.stage_id,remoteRun.state
     14   FROM remoteRun
    1515   JOIN remoteComponent USING (remote_id)
    1616WHERE
    17 remoteRun.stage = 'chip'
     17remoteRun.stage = 'chip' and remoteComponent.state != 'retry'
    1818-- where hook %s
    1919) AS R
     
    2424
    2525
    26        
     26
  • trunk/ippTools/share/remotetool_definebyquery_stack.sql

    r36968 r37833  
    1515   JOIN remoteComponent USING (remote_id)
    1616WHERE
    17 remoteRun.stage = 'stack'
     17remoteRun.stage = 'stack' and remoteComponent.state != 'retry'
    1818-- where hook %s
    1919) AS R
  • trunk/ippTools/share/remotetool_definebyquery_warp.sql

    r36968 r37833  
    1717   JOIN remoteComponent USING (remote_id)
    1818WHERE
    19 remoteRun.stage = 'warp'
     19remoteRun.stage = 'warp' and remoteComponent.state != 'retry'
    2020-- where hook %s
    2121) AS R
  • trunk/ippTools/src/remotetool.c

    r37054 r37833  
    2121static bool listrunMode(pxConfig *config);
    2222static bool listcomponentMode(pxConfig *config);
     23
     24// list remoteRuns with all remoteComponents in state 'prep_done' or 'prep_fail'
     25static bool doneprepMode(pxConfig *config);
    2326
    2427// Update
     
    2629static bool updaterunMode(pxConfig *config);
    2730static bool updatepollMode(pxConfig *config);
     31static bool updatecomponentMode(pxConfig *config);
    2832static bool revertrunMode(pxConfig *config);
    2933static bool revertauthMode(pxConfig *config);
     34static bool revertcomponentMode(pxConfig *config);
    3035
    3136# define MODECASE(caseName, func) \
     
    4752
    4853  switch (config->mode) {
    49     MODECASE(REMOTETOOL_MODE_DEFINEBYQUERY, definebyqueryMode);
    50     MODECASE(REMOTETOOL_MODE_LISTRUN,       listrunMode);
    51     MODECASE(REMOTETOOL_MODE_LISTCOMPONENT, listcomponentMode);
    52     MODECASE(REMOTETOOL_MODE_DROPCOMPONENT, dropcomponentMode);
    53     MODECASE(REMOTETOOL_MODE_UPDATERUN,     updaterunMode);
    54     MODECASE(REMOTETOOL_MODE_UPDATEPOLL,    updatepollMode);
    55     MODECASE(REMOTETOOL_MODE_REVERTRUN,     revertrunMode);
    56     MODECASE(REMOTETOOL_MODE_REVERTAUTH,    revertauthMode);
     54    MODECASE(REMOTETOOL_MODE_DEFINEBYQUERY,   definebyqueryMode);
     55    MODECASE(REMOTETOOL_MODE_LISTRUN,         listrunMode);
     56    MODECASE(REMOTETOOL_MODE_DONEPREP,         doneprepMode);
     57    MODECASE(REMOTETOOL_MODE_LISTCOMPONENT,   listcomponentMode);
     58    MODECASE(REMOTETOOL_MODE_DROPCOMPONENT,   dropcomponentMode);
     59    MODECASE(REMOTETOOL_MODE_UPDATERUN,       updaterunMode);
     60    MODECASE(REMOTETOOL_MODE_UPDATEPOLL,      updatepollMode);
     61    MODECASE(REMOTETOOL_MODE_UPDATECOMPONENT, updatecomponentMode);
     62    MODECASE(REMOTETOOL_MODE_REVERTRUN,       revertrunMode);
     63    MODECASE(REMOTETOOL_MODE_REVERTAUTH,      revertauthMode);
     64    MODECASE(REMOTETOOL_MODE_REVERTCOMPONENT, revertcomponentMode);
    5765
    5866  default:
     
    92100  PXOPT_LOOKUP_BOOL(simple,    config->args, "-simple",       false);
    93101  PXOPT_LOOKUP_BOOL(pretend,   config->args, "-pretend",      false);
    94  
     102
    95103  set_label = set_label ? set_label : label;
    96104
     
    105113      return(false);
    106114    }
    107    
     115
    108116    if (label) {
    109117      psStringAppend(&whereOption, "\n AND (label = '%s')", label);
     
    116124      return(false);
    117125    }
    118    
     126
    119127    if (label) {
    120128      psStringAppend(&whereOption, "\n AND (label = '%s')", label);
    121129    }
    122   }   
     130  }
    123131  else if (!strcmp(stage,"warp")) {
    124132    query = pxDataGet("remotetool_definebyquery_warp.sql");
     
    127135      return(false);
    128136    }
    129    
     137
    130138    if (label) {
    131139      // Because warp has to check to see if something other than the state is set correctly, I have to use this wonky way to pass the label in.
     
    133141      psStringAppend(&whereOption, "\n AND (label = '%s')", label);
    134142    }
    135   }   
     143  }
    136144  else if (!strcmp(stage,"stack")) {
    137145    query = pxDataGet("remotetool_definebyquery_stack.sql");
     
    140148      return(false);
    141149    }
    142    
     150
    143151    if (label) {
    144152      psStringAppend(&whereOption, "\n AND (label = '%s')", label);
    145153    }
    146   }   
     154  }
     155  else if (!strcmp(stage,"staticsky")) {
     156    query = pxDataGet("remotetool_definebyquery_staticsky.sql");
     157    if (!query) {
     158      psError(PXTOOLS_ERR_SYS,false, "failed to retreive SQL statement");
     159      return(false);
     160    }
     161
     162    if (label) {
     163      psStringAppend(&whereOption, "\n AND (label = '%s')", label);
     164    }
     165  }
    147166  else {
    148167    psError(PS_ERR_UNKNOWN, true, "unknown value for stage: %s", stage);
     
    191210  // Insert the top level run object
    192211  remoteRunRow *run = remoteRunRowAlloc(0, // remote_id
    193                                         "new", // state
    194                                         stage,
    195                                         set_label,
    196                                         path_base,
    197                                         -1, // job_id
    198                                         NULL, // last_poll
    199                                         0   // fault
    200                                           );
     212                                        "new", // state
     213                                        stage,
     214                                        set_label,
     215                                        path_base,
     216                                        -1, // job_id
     217                                        NULL, // last_poll
     218                                        0   // fault
     219                                          );
    201220  if (!run) {
    202     psError(PS_ERR_UNKNOWN, false, "failed to alloc lapRun object");
     221    psError(PS_ERR_UNKNOWN, false, "failed to alloc remoteRun object");
    203222    return(true);
    204223  }
    205  
     224
    206225  if (!remoteRunInsertObject(config->dbh, run)) {
    207226    if (!psDBRollback(config->dbh)) {
     
    213232  }
    214233  psS64 remote_id = psDBLastInsertID(config->dbh);
    215  
     234
    216235  psArray *list = psArrayAllocEmpty(limit);
    217236  for (long i=0; i < psArrayLength(output); i++) {
     
    219238    psS64 stage_id = psMetadataLookupS64(NULL, md, "stage_id");
    220239
    221     remoteComponentRow *comp = remoteComponentRowAlloc(remote_id,
    222                                                        stage_id);
     240    remoteComponentRow *comp = remoteComponentRowAlloc(remote_id, stage_id, 0, "new", NULL);
    223241    if (!comp) {
    224       psError(PS_ERR_UNKNOWN, false, "failed to alloc lapRun object");
     242      psError(PS_ERR_UNKNOWN, false, "failed to alloc remoteComponent object");
    225243      return(true);
    226244    }
    227    
     245
    228246    if (!remoteComponentInsertObject(config->dbh, comp)) {
    229247      if (!psDBRollback(config->dbh)) {
    230         psError(PS_ERR_UNKNOWN, false, "database error");
     248        psError(PS_ERR_UNKNOWN, false, "database error");
    231249      }
    232250      psError(PS_ERR_UNKNOWN, false, "database error");
     
    237255    psArrayAdd(list, list->n, comp);
    238256    psFree(comp);
    239    
     257
    240258  }
    241259  psFree(run);
     
    245263    return false;
    246264  }
    247  
     265
    248266  if (!remoteComponentPrintObjects(stdout, list, !simple)) {
    249267    if (!psDBRollback(config->dbh)) {
     
    254272    return false;
    255273  }
    256  
     274
    257275  psFree(list);
    258276  psFree(output);
    259                                        
     277
    260278  return true;
    261279}
     
    265283{
    266284  psMetadata *where = psMetadataAlloc();
    267  
     285
    268286  PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "==");
    269287  PXOPT_COPY_STR(config->args, where, "-state", "state", "==");
     
    274292  PXOPT_COPY_TIME(config->args, where, "-poll_begin", "last_poll", ">=");
    275293  PXOPT_COPY_TIME(config->args, where, "-poll_end", "last_poll", "<=");
    276  
     294
    277295  PXOPT_COPY_S16(config->args, where, "-fault", "fault", "==");
    278296
    279297  PXOPT_LOOKUP_S16(limit,   config->args, "-limit",  false, false);
    280298  PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    281  
    282299
    283300  psArray *remRuns = NULL;
    284301  remRuns = psDBSelectRows(config->dbh, "remoteRun", where, limit);
    285  
     302
    286303  if (!ippdbPrintMetadatas(stdout, remRuns, "remoteRun", !simple)) {
    287304    psError(PS_ERR_UNKNOWN, false, "failed to print array");
     
    299316
    300317  PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "==");
     318  PXOPT_COPY_S64(config->args, where, "-stage_id",  "stage_id",  "==");
     319  PXOPT_COPY_S64(config->args, where, "-jobs",      "jobs",      "==");
     320
     321  PXOPT_COPY_STR(config->args, where, "-state", "remoteComponent.state", "==");
     322  PXOPT_COPY_STR(config->args, where, "-label", "remoteRun.label", "==");
     323
    301324  PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    302  
    303   psArray *remComps = NULL;
    304   remComps = psDBSelectRows(config->dbh, "remoteComponent", where, 0);
    305  
    306   if (!ippdbPrintMetadatas(stdout, remComps, "remoteComponent", !simple)) {
     325  PXOPT_LOOKUP_S16(limit,   config->args, "-limit",  false, false);
     326
     327  psString query = pxDataGet("remotetool_listcomponent.sql");
     328  if (!query) {
     329      psError(PXTOOLS_ERR_SYS,false, "failed to retreive SQL statement");
     330      return(false);
     331  }
     332
     333  if (psListLength(where->list)) {
     334      psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     335      psStringAppend(&query, " WHERE %s", whereClause);
     336      psFree(whereClause);
     337  }
     338  psFree(where);
     339
     340  if (limit) {
     341    psString limitString = psDBGenerateLimitSQL(limit);
     342    psStringAppend(&query, " %s", limitString);
     343    psFree(limitString);
     344  }
     345
     346  if (!p_psDBRunQuery(config->dbh, query)) {
     347      psError(PS_ERR_UNKNOWN, false, "database error");
     348      psFree(query);
     349      return false;
     350  }
     351  psFree(query);
     352
     353  psArray *output = p_psDBFetchResult(config->dbh);
     354  if (!output) {
     355      psError(PS_ERR_UNKNOWN, false, "database error");
     356      return false;
     357  }
     358  if (!psArrayLength(output)) {
     359    psTrace("remotetool", PS_LOG_INFO, "no rows found");
     360    psFree(output);
     361    return true;
     362  }
     363
     364  if (!ippdbPrintMetadatas(stdout, output, "remoteComponent", !simple)) {
    307365    psError(PS_ERR_UNKNOWN, false, "failed to print array");
    308     psFree(remComps);
    309     return false;
    310   }
    311   psFree(remComps);
     366    psFree(output);
     367    return false;
     368  }
     369  psFree(output);
    312370
    313371  return true;
    314372}
    315373
     374// List
     375static bool doneprepMode(pxConfig *config)
     376{
     377  psMetadata *where = psMetadataAlloc();
     378
     379  PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "==");
     380  PXOPT_COPY_S64(config->args, where, "-job_id", "job_id", "==");
     381
     382  PXOPT_COPY_STR(config->args, where, "-stage",  "stage",  "==");
     383  PXOPT_COPY_STR(config->args, where, "-state", "remoteRun.state", "==");
     384  PXOPT_COPY_STR(config->args, where, "-label",  "label",  "==");
     385
     386  PXOPT_LOOKUP_S16(limit,   config->args, "-limit",  false, false);
     387  PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     388
     389  psString query = pxDataGet("remotetool_doneprep.sql");
     390  if (!query) {
     391      psError(PXTOOLS_ERR_SYS,false, "failed to retreive SQL statement");
     392      return(false);
     393  }
     394
     395  psString whereDone = NULL;
     396  psString whereJobs = NULL;
     397  if (psListLength(where->list)) {
     398      psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     399      psStringAppend(&whereDone, " \n AND %s", whereClause);
     400      psStringAppend(&whereJobs, " \n WHERE %s", whereClause);
     401      psFree(whereClause);
     402  }
     403
     404  if (limit) {
     405    psString limitString = psDBGenerateLimitSQL(limit);
     406    psStringAppend(&query, " %s", limitString);
     407    psFree(limitString);
     408  }
     409
     410  // fprintf (stderr, "query: %s\n", query);
     411  // fprintf (stderr, "whereDone: %s\n", whereDone);
     412  // fprintf (stderr, "whereJobs: %s\n", whereJobs);
     413
     414  if (!p_psDBRunQueryF(config->dbh, query, whereDone, whereJobs)) {
     415      psError(PS_ERR_UNKNOWN, false, "database error");
     416      psFree(whereDone);
     417      psFree(whereJobs);
     418      psFree(query);
     419      return false;
     420  }
     421  psFree(whereDone);
     422  psFree(whereJobs);
     423  psFree(query);
     424
     425  psArray *output = p_psDBFetchResult(config->dbh);
     426  if (!output) {
     427      psError(PS_ERR_UNKNOWN, false, "database error");
     428      return false;
     429  }
     430  if (!psArrayLength(output)) {
     431    psTrace("remotetool", PS_LOG_INFO, "no rows found");
     432    psFree(output);
     433    return true;
     434  }
     435
     436  if (!ippdbPrintMetadatas(stdout, output, "remoteRun", !simple)) {
     437    psError(PS_ERR_UNKNOWN, false, "failed to print array");
     438    psFree(output);
     439    return false;
     440  }
     441  psFree(output);
     442
     443  return true;
     444}
     445
    316446// Update
    317447
    318448static bool dropcomponentMode(pxConfig *config)
    319449{
     450  fprintf (stderr, "do we really want to use -dropcomponent?\n");
     451  exit (1);
     452
    320453  // Assert that we have a unique component to operate on.
    321454  PXOPT_LOOKUP_S64(remote_id,config->args, "-remote_id",true, false);
     
    329462    return false;
    330463  }
    331  
     464
    332465  if (!psDBTransaction(config->dbh)) {
    333466    psError(PS_ERR_UNKNOWN, false, "database error");
     
    341474  }
    342475  psFree(query);
    343  
    344  
    345476
    346477  // point of no return
     
    349480    return false;
    350481  }
    351  
     482
    352483  return true;
    353484}
     
    364495  // Wheres
    365496  PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "==");
    366  
     497
    367498  // Values to set
    368499  PXOPT_COPY_STR(config->args, values, "-set_label", "label", "==");
     
    374505  psFree(values);
    375506
    376   if (rows < 1) {
    377     psError(PS_ERR_UNKNOWN,false, "no rows affected");
    378     return(false);
    379   }
    380  
     507  if (rows < 1) fprintf (stderr, "no rows changed (run may already be in desired state)\n");
    381508  return(true);
    382509}
     
    393520  psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    394521  psFree(where);
    395  
     522
    396523  psString query = NULL;
    397524  query = pxDataGet("remotetool_updatepoll.sql");
     
    412539  return(true);
    413540}
    414  
    415 
    416  
     541
     542static bool updatecomponentMode(pxConfig *config)
     543{
     544  PS_ASSERT_PTR_NON_NULL(config, false);
     545  PXOPT_LOOKUP_S64(remote_id,  config->args, "-remote_id",    true, false);
     546  psAssert(remote_id,"This should have failed before this point.");
     547
     548  psMetadata *where = psMetadataAlloc();
     549  psMetadata *values = psMetadataAlloc();
     550
     551  // Wheres
     552  PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "==");
     553  PXOPT_COPY_S64(config->args, where, "-stage_id",  "stage_id",  "==");
     554  PXOPT_COPY_STR(config->args, where, "-state",     "state",     "==");
     555
     556  // Values to set
     557  PXOPT_COPY_S32(config->args, values, "-set_jobs",      "jobs",      "==");
     558  PXOPT_COPY_STR(config->args, values, "-set_path_base", "path_base", "==");
     559  PXOPT_COPY_STR(config->args, values, "-set_state", "state", "==");
     560
     561  long rows = psDBUpdateRows(config->dbh, "remoteComponent", where, values);
     562  psFree(values);
     563
     564  if (rows < 1) fprintf (stderr, "no rows changed (component may already be in desired state)\n");
     565  return true;
     566}
    417567
    418568static bool revertrunMode(pxConfig *config)
     
    426576  PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "==");
    427577  PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
    428  
     578  PXOPT_COPY_S16(config->args, where, "-fault", "fault", "==");
    429579  // Value to set
    430   PXOPT_COPY_S16(config->args, values, "-fault", "fault", "==");
    431   long rows = psDBUpdateRows(config->dbh, "remoteRun", where, values);
    432   psFree(values);
    433   psFree(where);
    434   if (rows < 1) {
    435     psError(PS_ERR_UNKNOWN,false, "no rows affected");
    436     return(false);
    437   }
    438 
    439   return(true);
    440 }
    441 
    442 static bool revertauthMode(pxConfig *config)
    443 {
    444   PS_ASSERT_PTR_NON_NULL(config, false);
    445 
    446   psMetadata *where = psMetadataAlloc();
    447   psMetadata *values = psMetadataAlloc();
    448 
    449   // required
    450   PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "==");
    451   PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
    452 
    453   psMetadataAddStr(where, PS_LIST_TAIL, "state", 0, "==", "auth");
    454 
    455   // Value to set
    456   psMetadataAddStr(values, PS_LIST_TAIL, "state", 0, "==", "run");
     580  psMetadataAddS16(values,PS_LIST_TAIL,"fault",0, "==", 0);
    457581 
    458582  long rows = psDBUpdateRows(config->dbh, "remoteRun", where, values);
     
    466590  return(true);
    467591}
    468    
     592
     593static bool revertcomponentMode(pxConfig *config)
     594{
     595  PS_ASSERT_PTR_NON_NULL(config,false);
     596  psMetadata *where = psMetadataAlloc();
     597  psMetadata *values = psMetadataAlloc();
     598
     599  // required
     600  PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "==");
     601  PXOPT_COPY_S64(config->args, where, "-stage_id", "stage_id", "==");
     602  psMetadataAddStr(where,PS_LIST_TAIL,"state",0, "LIKE", "%fail");
     603 
     604  // value to set
     605  psMetadataAddStr(values, PS_LIST_TAIL, "state",0, "==", "retry");
     606 
     607
     608  long rows = psDBUpdateRows(config->dbh, "remoteComponent", where, values);
     609  psFree(values);
     610  psFree(where);
     611  if (rows < 1) {
     612    psError(PS_ERR_UNKNOWN,false, "no rows affected");
     613    return(false);
     614  }
     615
     616  return(true);
     617}
     618 
     619 
     620
     621static bool revertauthMode(pxConfig *config)
     622{
     623  PS_ASSERT_PTR_NON_NULL(config, false);
     624
     625  psMetadata *where = psMetadataAlloc();
     626  psMetadata *values = psMetadataAlloc();
     627
     628  // required
     629  PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "==");
     630  PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     631
     632  psMetadataAddStr(where, PS_LIST_TAIL, "state", 0, "==", "auth");
     633
     634  // Value to set
     635  psMetadataAddStr(values, PS_LIST_TAIL, "state", 0, "==", "run");
     636
     637  long rows = psDBUpdateRows(config->dbh, "remoteRun", where, values);
     638  psFree(values);
     639  psFree(where);
     640  if (rows < 1) {
     641    psError(PS_ERR_UNKNOWN,false, "no rows affected");
     642    return(false);
     643  }
     644
     645  return(true);
     646}
     647
  • trunk/ippTools/src/remotetool.h

    r36981 r37833  
    1212  REMOTETOOL_MODE_DEFINEBYQUERY,
    1313  REMOTETOOL_MODE_LISTRUN,
     14  REMOTETOOL_MODE_DONEPREP,
    1415  REMOTETOOL_MODE_LISTCOMPONENT,
    1516  REMOTETOOL_MODE_DROPCOMPONENT,
    1617  REMOTETOOL_MODE_UPDATERUN,
    1718  REMOTETOOL_MODE_UPDATEPOLL,
    18   REMOTETOOL_MODE_REVERTRUN,   
    19   REMOTETOOL_MODE_REVERTAUTH,   
     19  REMOTETOOL_MODE_UPDATECOMPONENT,
     20  REMOTETOOL_MODE_REVERTRUN,
     21  REMOTETOOL_MODE_REVERTAUTH,
     22  REMOTETOOL_MODE_REVERTCOMPONENT,
    2023} remotetoolMode;
    2124
  • trunk/ippTools/src/remotetoolConfig.c

    r36981 r37833  
    4040  ADD_OPT(Bool, definebyqueryArgs, "-pretend",       "pretend to do this.", 0);
    4141  ADD_OPT(Bool, definebyqueryArgs,"-simple",         "simple print format",0);
    42  
     42
    4343  // -listrun
    4444  psMetadata *listrunArgs = psMetadataAlloc();
     
    5959  ADD_OPT(S16, listrunArgs,  "-limit",             "limit to number of runs to display", 0);
    6060
     61  // -doneprep
     62  psMetadata *doneprepArgs = psMetadataAlloc();
     63  ADD_OPT(S64, doneprepArgs, "-remote_id",          "run to list", 0);
     64  ADD_OPT(S64, doneprepArgs, "-job_id",             "job_id", 0);
     65  ADD_OPT(Str, doneprepArgs, "-stage",              "stage to return", NULL);
     66  ADD_OPT(Str, doneprepArgs, "-state",              "state to return", NULL);
     67  ADD_OPT(Str, doneprepArgs, "-label",              "remRun label to use", NULL);
     68
     69  ADD_OPT(Bool, doneprepArgs, "-simple",            "simple print format", false);
     70  ADD_OPT(S16, doneprepArgs,  "-limit",             "limit to number of runs to display", 0);
     71
     72  // -revertcomponent
     73  psMetadata   *revertcomponentArgs = psMetadataAlloc();
     74  ADD_OPT(S64,  revertcomponentArgs, "-remote_id",       "run to revert components from", 0);
     75  ADD_OPT(S64,  revertcomponentArgs, "-stage_id",        "component stage_id to revert", 0);
     76 
     77 
    6178  // -listcomponents
    62   psMetadata *listcomponentArgs = psMetadataAlloc();
    63   ADD_OPT(S64, listcomponentArgs, "-remote_id",             "run to list", 0);
    64   ADD_OPT(S16, listcomponentArgs, "-limit",              "limit to number of runs to display", 0);
     79  psMetadata   *listcomponentArgs = psMetadataAlloc();
     80  ADD_OPT(S64,  listcomponentArgs, "-remote_id",         "run to list", 0);
     81  ADD_OPT(S64,  listcomponentArgs, "-stage_id",          "run to list", 0);
     82  ADD_OPT(S32,  listcomponentArgs, "-jobs",              "run to list", 0);
     83  ADD_OPT(Str,  listcomponentArgs, "-state",             "run to list", NULL);
     84  ADD_OPT(S16,  listcomponentArgs, "-limit",             "limit to number of runs to display", 0);
    6585  ADD_OPT(Bool, listcomponentArgs, "-simple",            "simple print format", false);
     86  ADD_OPT(Str,  listcomponentArgs, "-label",             "label to use", NULL);
    6687
    6788  // -dropcomponent
     
    6990  ADD_OPT(S64, dropcomponentArgs, "-remote_id",         "run to update", 0);
    7091  ADD_OPT(S64, dropcomponentArgs, "-stage_id",          "stage_id to remote", 0);
    71  
     92
    7293  // -updaterun
    7394  psMetadata *updaterunArgs = psMetadataAlloc();
     
    83104  psMetadata *updatepollArgs = psMetadataAlloc();
    84105  ADD_OPT(S64, updatepollArgs, "-remote_id",            "run to update", 0);
    85  
     106
     107  // -updatecomponent
     108  psMetadata  *updatecomponentArgs = psMetadataAlloc();
     109  ADD_OPT(S64, updatecomponentArgs, "-remote_id",     "remote_id to update", 0);
     110  ADD_OPT(S64, updatecomponentArgs, "-stage_id",      "stage_id to update", 0);
     111  ADD_OPT(Str, updatecomponentArgs, "-state",         "limit to this remoteComponent state", NULL);
     112  ADD_OPT(Str, updatecomponentArgs, "-set_state",     "remoteComponent state to assign", NULL);
     113  ADD_OPT(Str, updatecomponentArgs, "-set_path_base", "remoteRun path_base to assign", NULL);
     114  ADD_OPT(S32, updatecomponentArgs, "-set_jobs",      "number of jobs for this stage_id", 0);
     115
    86116  // -revertrun
    87117  psMetadata *revertrunArgs = psMetadataAlloc();
     
    89119  ADD_OPT(Str, revertrunArgs, "-label",      "remRun label to use", NULL);
    90120  ADD_OPT(S16, revertrunArgs, "-fault",              "fault code", 0);
    91  
     121
    92122  // -revertauth
    93123  psMetadata *revertauthArgs = psMetadataAlloc();
     
    98128  psMetadata *modes   = psMetadataAlloc();
    99129
    100   PXOPT_ADD_MODE("-definebyquery",     "", REMOTETOOL_MODE_DEFINEBYQUERY,  definebyqueryArgs);
    101   PXOPT_ADD_MODE("-listrun",           "", REMOTETOOL_MODE_LISTRUN,        listrunArgs);
    102   PXOPT_ADD_MODE("-listcomponent",     "", REMOTETOOL_MODE_LISTCOMPONENT,  listcomponentArgs);
    103   PXOPT_ADD_MODE("-dropcomponent",     "", REMOTETOOL_MODE_DROPCOMPONENT,  dropcomponentArgs);
    104   PXOPT_ADD_MODE("-updaterun",         "", REMOTETOOL_MODE_UPDATERUN,      updaterunArgs);
    105   PXOPT_ADD_MODE("-updatepoll",        "", REMOTETOOL_MODE_UPDATEPOLL,     updatepollArgs);
    106   PXOPT_ADD_MODE("-revertrun",         "", REMOTETOOL_MODE_REVERTRUN,      revertrunArgs);
    107   PXOPT_ADD_MODE("-revertauth",        "", REMOTETOOL_MODE_REVERTAUTH,     revertauthArgs);
     130  PXOPT_ADD_MODE("-definebyquery",     "", REMOTETOOL_MODE_DEFINEBYQUERY,   definebyqueryArgs);
     131  PXOPT_ADD_MODE("-listrun",           "", REMOTETOOL_MODE_LISTRUN,         listrunArgs);
     132  PXOPT_ADD_MODE("-doneprep",          "", REMOTETOOL_MODE_DONEPREP,        doneprepArgs);
     133  PXOPT_ADD_MODE("-listcomponent",     "", REMOTETOOL_MODE_LISTCOMPONENT,   listcomponentArgs);
     134  PXOPT_ADD_MODE("-revertcomponent",   "", REMOTETOOL_MODE_REVERTCOMPONENT, revertcomponentArgs);
     135  PXOPT_ADD_MODE("-dropcomponent",     "", REMOTETOOL_MODE_DROPCOMPONENT,   dropcomponentArgs);
     136  PXOPT_ADD_MODE("-updaterun",         "", REMOTETOOL_MODE_UPDATERUN,       updaterunArgs);
     137  PXOPT_ADD_MODE("-updatepoll",        "", REMOTETOOL_MODE_UPDATEPOLL,      updatepollArgs);
     138  PXOPT_ADD_MODE("-updatecomponent",   "", REMOTETOOL_MODE_UPDATECOMPONENT, updatecomponentArgs);
     139  PXOPT_ADD_MODE("-revertrun",         "", REMOTETOOL_MODE_REVERTRUN,       revertrunArgs);
     140  PXOPT_ADD_MODE("-revertauth",        "", REMOTETOOL_MODE_REVERTAUTH,      revertauthArgs);
    108141
    109142
  • trunk/ippTools/src/stacktool.c

  • trunk/ippTools/src/stacktoolConfig.c

Note: See TracChangeset for help on using the changeset viewer.