Changeset 37291
- Timestamp:
- Aug 22, 2014, 4:49:46 PM (12 years ago)
- Location:
- tags/ipp-pv3-20140717/ippScripts/scripts
- Files:
-
- 5 edited
-
sc_prepare_camera.pl (modified) (15 diffs)
-
sc_prepare_chip.pl (modified) (4 diffs)
-
sc_prepare_run.pl (modified) (11 diffs)
-
sc_prepare_stack.pl (modified) (14 diffs)
-
sc_prepare_warp.pl (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-pv3-20140717/ippScripts/scripts/sc_prepare_camera.pl
r37126 r37291 1 1 #! /usr/bin/env perl 2 3 # generate the input & output files lists and commands for a single camRun 2 4 3 5 use Carp; … … 16 18 use Pod::Usage qw( pod2usage ); 17 19 18 19 20 # 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 22 my $remote_root = '/scratch3/watersc1/'; # Far side destination base location 23 my $threads_req = 0; # How many threads are we going to use? 24 25 my $fail_state = "prep_fail"; 26 32 27 # Look for programs we need 33 28 my $missing_tools; 34 35 29 my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1); 36 30 my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1); … … 41 35 } 42 36 43 my ($remote_id,$cam_id, ,$camera,$dbname,$verbose,$path_base,$no_update);37 my ($remote_id,$cam_id,$camera,$dbname,$verbose,$path_base,$no_update); 44 38 GetOptions( 45 39 'remote_id=s' => \$remote_id, 40 'cam_d=s' => \$cam_id, 46 41 'camera|c=s' => \$camera, 47 42 'dbname|d=s' => \$dbname, … … 52 47 53 48 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 54 pod2usage( -msg => "Required options: --remote_id --cam era --dbname --path_base", -exitval => 3) unless49 pod2usage( -msg => "Required options: --remote_id --cam_id --camera --dbname --path_base", -exitval => 3) unless 55 50 defined($remote_id) and 51 defined($cam_id) and 56 52 defined($camera) and 57 53 defined($path_base) and 58 54 defined($dbname); 59 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id); 55 56 my $ipprc = PS::IPP::Config->new( $camera ) or &my_die( "Unable to set up", $remote_id, $cam_id, $PS_EXIT_CONFIG_ERROR, $fail_state); 60 57 61 58 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 62 59 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"; 60 my @return_component_list = ("DBINFO.EXP", "PSASTRO.CONFIG", "PSASTRO.OUTPUT", "LOG.EXP", "PSASTRO.STATS"); 61 62 # STEP 0: Open output files 85 63 my $uri_transfer= $path_base . ".transfer"; 86 64 my $uri_check = $path_base . ".check"; … … 89 67 my $uri_return = $path_base . ".return"; 90 68 91 my $disk_command = $ipprc->file_resolve($uri_command,1);92 69 my $disk_transfer= $ipprc->file_resolve($uri_transfer,1); 93 70 my $disk_check = $ipprc->file_resolve($uri_check,1); … … 98 75 my (undef, $remote_config) = uri_convert($uri_config); # Needs to be done after we've created it. 99 76 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);77 open(TRANSFER, ">$disk_transfer") || &my_die("Couldn't open file? $disk_transfer",$remote_id, $cam_id, $PS_EXIT_SYS_ERROR, $fail_state); 78 open(CHECK, ">$disk_check") || &my_die("Couldn't open file? $disk_check", $remote_id, $cam_id, $PS_EXIT_SYS_ERROR, $fail_state); 79 open(CONFIG, ">$disk_config") || &my_die("Couldn't open file? $disk_config", $remote_id, $cam_id, $PS_EXIT_SYS_ERROR, $fail_state); 80 open(GENERATE, ">$disk_generate") || &my_die("Couldn't open file? $disk_generate",$remote_id, $cam_id, $PS_EXIT_SYS_ERROR, $fail_state); 81 open(RETURN, ">$disk_return") || &my_die("Couldn't open file? $disk_return", $remote_id, $cam_id, $PS_EXIT_SYS_ERROR, $fail_state); 105 82 my %file_filter = (); 106 83 107 #108 # Step 2: Iterate over all componenets in this remote run.109 84 my $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 85 86 # STEP 1: Get exposure level information for this camRun 87 my ($workdir,$exp_tag); 88 { 119 89 my $command = "$camtool -pendingexp -cam_id $cam_id "; 120 90 $command .= " -dbname $dbname " if defined($dbname); … … 125 95 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 126 96 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 &my_die("Unable to run camtool to determine stage parameters.", $remote_id, $cam_id, $error_code, $fail_state); 98 } 99 100 my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or 101 &my_die("Unable to determine cam component information.", $remote_id, $cam_id, $PS_EXIT_PROG_ERROR, $fail_state); 102 my $metadata = parse_md_list($MDlist); 103 my $camEntry = $metadata->[0]; 104 105 $workdir = $camEntry->{workdir}; 106 $exp_tag = $camEntry->{exp_tag}; 139 107 unless (defined($workdir)) { 140 108 while( my ($k, $v) = each %$camEntry ) { 141 109 print "key: $k, value: $v.\n"; 142 110 } 143 144 111 print "%{ $camEntry }\n"; 145 112 die; 146 113 } 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 # 114 } 115 116 my $ipp_outroot = "${workdir}/${exp_tag}/${exp_tag}.cm.${cam_id}"; 117 my $remote_outroot = uri_local_to_remote($ipp_outroot); 118 152 119 # 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);120 { 121 my $command = "$camtool -pendingimfile -cam_id $cam_id "; 122 $command .= " -dbname $dbname " if defined($dbname); 156 123 157 124 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 158 run(command => $ reg_command, verbose => 0);125 run(command => $command, verbose => 0); 159 126 unless ($success) { 160 127 $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 128 &my_die("Unable to run camtool -pendingimfile ", $remote_id, $cam_id, $error_code, $fail_state); 129 } 165 130 166 131 # 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) or168 &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];132 my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or 133 &my_die("Unable to determine cam component information.", $remote_id, $cam_id, $PS_EXIT_PROG_ERROR, $fail_state); 134 135 my $metadata = parse_md_list($MDlist); 136 my $chipProto = $metadata->[0]; 172 137 my $chip_path = $chipProto->{path_base}; 173 138 my $remote_chip_path = uri_local_to_remote( $chip_path ); … … 180 145 my $psastro_command = " psastro -list ${remote_outroot}.cmflist "; 181 146 $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. 147 # $psastro_command .= " -refmasklist ${remote_outroot}.masklist ${remote_outroot} "; 148 # 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 149 # Uncomment when remote psastro supports this 184 150 $psastro_command .= " -kh-correct /turquoise/usr/projects/ps1/watersc1/references/khcorrect.20140606.v0.fits "; 185 151 $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 ";152 # $psastro_command .= " -astrommodel /turquoise/usr/projects/ps1/watersc1/references/gpc1.20080909.asm "; 187 153 $psastro_command .= " -astrommodel /turquoise/usr/projects/ps1/watersc1/references/gpc1.20140505.asm "; 188 154 $psastro_command .= " -recipe PSASTRO $recipe_psastro "; … … 192 158 193 159 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 "; 160 $camtool_post_cmd .= " -dbname $dbname " if defined $dbname; 161 $camtool_post_cmd .= " -path_base $ipp_outroot -hostname $remote_hostname -dtime_script 0 "; 195 162 my $post_cmd_echo = " echo -n \"$camtool_post_cmd\" > ${remote_outroot}.dbinfo "; 196 163 my $post_cmd_SfM = " ppStatsFromMetadata ${remote_outroot}.stats - CAMERA_EXP_FPA >> ${remote_outroot}.dbinfo "; … … 206 173 print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk "; 207 174 } 208 foreach my $chipInfo (@{ $ inpData2}) {175 foreach my $chipInfo (@{ $metadata }) { 209 176 my $filename = $ipprc->filename("PSASTRO.OUTPUT.MASK",$ipp_outroot,$chipInfo->{class_id}); 210 177 my ($ipp_disk, $remote_disk) = uri_to_outputs_for_return( $filename); … … 220 187 close(GENERATE); 221 188 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 fill229 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 RESOURCES249 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 258 189 unless($no_update) { 259 my $command = "remotetool -updaterun -remote_id $remote_id "; 260 $command .= " -set_state pending "; 261 $command .= " -dbname $dbname " if defined $dbname; 262 190 my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $cam_id "; 191 $command .= " -set_jobs $job_index"; 192 $command .= " -set_path_base $path_base"; 193 $command .= " -set_state prep_done"; 194 $command .= " -dbname $dbname " if defined $dbname; 263 195 system($command); 264 196 } 265 197 198 exit (0); 266 199 267 200 ## Common SC routines … … 273 206 274 207 unless(defined($ipp_disk)) { 275 my_die();208 &my_die( "Unable to generate file for $neb_uri ", $remote_id, $cam_id, $PS_EXIT_SYS_ERROR, $fail_state); 276 209 } 277 210 … … 289 222 290 223 unless(defined($ipp_disk)) { 291 my_die();224 &my_die( "Unable to generate file for $neb_uri ", $remote_id, $cam_id, $PS_EXIT_SYS_ERROR, $fail_state); 292 225 } 293 226 … … 345 278 sub my_die { # exit with status; my_die(message,stage_id,exit_code,exit_status); 346 279 my $msg = shift; 347 my $id = shift; 280 my $remote_id = shift; 281 my $stage_id = shift; 348 282 my $exit_code = shift; 349 283 my $exit_state = shift; … … 353 287 carp($msg); 354 288 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; 289 if (defined $remote_id and defined $stage_id and not $no_update) { 290 my $command = "remotetool -updatecomponent -remote_id $id -stage_id $stage_id"; 358 291 $command .= " -set_state $exit_state " if defined $exit_state; 359 292 $command .= " -dbname $dbname " if defined $dbname; -
tags/ipp-pv3-20140717/ippScripts/scripts/sc_prepare_chip.pl
r37280 r37291 58 58 defined($dbname); 59 59 60 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id, $chip_id, $PS_EXIT_CONFIG_ERROR, $fail_state);60 my $ipprc = PS::IPP::Config->new( $camera ) or &my_die( "Unable to set up", $remote_id, $chip_id, $PS_EXIT_CONFIG_ERROR, $fail_state); 61 61 62 62 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 304 304 system($command); 305 305 } 306 307 306 exit (0); 308 307 … … 313 312 314 313 unless(defined($ipp_disk)) { 315 my_die( "Unable to generate file for $neb_uri ", $remote_id, $chip_id, $PS_EXIT_SYS_ERROR, $fail_state);314 &my_die( "Unable to generate file for $neb_uri ", $remote_id, $chip_id, $PS_EXIT_SYS_ERROR, $fail_state); 316 315 } 317 316 … … 329 328 330 329 unless(defined($ipp_disk)) { 331 my_die( "Unable to generate file for $neb_uri ", $remote_id, $chip_id, $PS_EXIT_SYS_ERROR, $fail_state);330 &my_die( "Unable to generate file for $neb_uri ", $remote_id, $chip_id, $PS_EXIT_SYS_ERROR, $fail_state); 332 331 } 333 332 -
tags/ipp-pv3-20140717/ippScripts/scripts/sc_prepare_run.pl
r37284 r37291 26 26 my $remote_raw = "${remote_root}/raw/"; # Directory to find raw data in. 27 27 28 # value for chip:29 28 my $threads = 2; # How many threads are we going to use? 30 my $job_cost = 150 / 60 / 60; # Estimate of how long a job runs, in hours. 29 30 my $fail_state = "prep_fail"; 31 32 # Estimate of how long a job runs, in hours (depends on stage) 33 my %job_cost = (); 34 $job_cost{"camera"} = 1700 / 60 / 60; 35 $job_cost{"chip"} = 150 / 60 / 60; 36 $job_cost{"warp"} = 110 / 60 / 60; 37 $job_cost{"stack"} = 1500 / 60 / 60; 31 38 32 39 my $proc_per_node = 24; # processors per node … … 35 42 my $min_time = 1; # shortest allocation to ask for 36 43 my $max_time = 8; # longest allocation to ask for 44 my $remote_hostname= "LANL/Mustang"; # Name of the remote node. 37 45 38 46 # We need to ensure we only ever try to transfer a file once. … … 41 49 # Look for programs we need 42 50 my $missing_tools; 43 my $chiptool = can_run('chiptool') or (warn "Can't find chiptool" and $missing_tools = 1);44 my $detselect= can_run('detselect') or (warn "Can't find detselect" and $missing_tools = 1);45 51 my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1); 46 52 … … 51 57 52 58 # Options 53 my ($ exp_id,$exp_name,$remote_id,$chip_id,$detrends,$camera,$dbname,$verbose,$path_base,$no_update);59 my ($remote_id,$stage,$camera,$path_base,$dbname,$verbose,$no_update); 54 60 GetOptions( 55 61 'remote_id=s' => \$remote_id, 62 'stage=s' => \$stage, 56 63 'camera|c=s' => \$camera, 64 'path_base=s' => \$path_base, 57 65 'dbname|d=s' => \$dbname, 58 ' path_base=s' => \$path_base,66 'verbose' => \$verbose, 59 67 'no_update' => \$no_update, 60 'verbose' => \$verbose,61 68 ) or pod2usage( 2 ); 62 69 63 70 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 64 pod2usage( -msg => "Required options: --remote_id -- camera --dbname --path_base", -exitval => 3) unless71 pod2usage( -msg => "Required options: --remote_id --stage --camera --dbname --path_base", -exitval => 3) unless 65 72 defined($remote_id) and 73 defined($stage) and 66 74 defined($camera) and 67 75 defined($path_base) and 68 76 defined($dbname); 69 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $exp_id); 77 78 my $ipprc = PS::IPP::Config->new( $camera ) or &my_die( "Unable to set up", $remote_id, $PS_EXIT_CONFIG_ERROR, $fail_state); 70 79 71 80 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 82 91 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 83 92 84 &my_die("Unable to run chiptool to determine stage parameters.", $remote_id, $error_code);93 &my_die("Unable to run remotetool to determine stage parameters.", $remote_id, $error_code, $fail_state); 85 94 } 86 95 my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or 87 &my_die("Unable to determine component information.", $remote_id, $PS_EXIT_PROG_ERROR);96 &my_die("Unable to determine component information.", $remote_id, $PS_EXIT_PROG_ERROR, $fail_state); 88 97 $compData = parse_md_list($MDlist); 89 98 } … … 112 121 my (undef, $remote_config) = uri_convert($uri_config); # Needs to be done after we've created it. 113 122 114 open(TRANSFER, ">$disk_transfer") || &my_die("Couldn't open file? $disk_transfer",$ chip_id,$PS_EXIT_SYS_ERROR);115 open(CHECK, ">$disk_check") || &my_die("Couldn't open file? $disk_check", $ chip_id,$PS_EXIT_SYS_ERROR);116 open(CONFIG, ">$disk_config") || &my_die("Couldn't open file? $disk_config", $ chip_id,$PS_EXIT_SYS_ERROR);117 open(GENERATE, ">$disk_generate") || &my_die("Couldn't open file? $disk_generate",$ chip_id,$PS_EXIT_SYS_ERROR);118 open(RETURN, ">$disk_return") || &my_die("Couldn't open file? $disk_return", $ chip_id,$PS_EXIT_SYS_ERROR);123 open(TRANSFER, ">$disk_transfer") || &my_die("Couldn't open file? $disk_transfer",$remote_id, $PS_EXIT_SYS_ERROR, $fail_state); 124 open(CHECK, ">$disk_check") || &my_die("Couldn't open file? $disk_check", $remote_id, $PS_EXIT_SYS_ERROR, $fail_state); 125 open(CONFIG, ">$disk_config") || &my_die("Couldn't open file? $disk_config", $remote_id, $PS_EXIT_SYS_ERROR, $fail_state); 126 open(GENERATE, ">$disk_generate") || &my_die("Couldn't open file? $disk_generate",$remote_id, $PS_EXIT_SYS_ERROR, $fail_state); 127 open(RETURN, ">$disk_return") || &my_die("Couldn't open file? $disk_return", $remote_id, $PS_EXIT_SYS_ERROR, $fail_state); 119 128 120 129 # Step 2: Iterate over all componenets in this remote run. … … 194 203 my $proc_need = $job_index * $threads; # how many total processors do we need? 195 204 my $node_need = $proc_need / $proc_per_node; # this equals how many nodes? 196 my $time_need = $job_index * $job_cost ; # How many seconds will this take?205 my $time_need = $job_index * $job_cost{$stage}; # How many seconds will this take? 197 206 198 207 my $fill_factor = 0.8; # This is the factor of how much of the time allocation we'd like to fill 199 208 my ($time_req,$node_req); 200 if ($node_need * $job_cost < $fill_factor * $min_nodes * $min_time) {209 if ($node_need * $job_cost{$stage} < $fill_factor * $min_nodes * $min_time) { 201 210 $time_req = $min_time; 202 211 $node_req = $min_nodes; 203 212 } 204 elsif ($node_need * $job_cost > $fill_factor * $max_nodes * $max_time) {213 elsif ($node_need * $job_cost{$stage} > $fill_factor * $max_nodes * $max_time) { 205 214 $time_req = $max_time; 206 215 $node_req = $max_nodes; 207 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";216 print STDERR "You've requested the construction of a bundle that appears to need $node_need nodes and $job_cost{$stage} time per job. This exceeds the max limits ($max_nodes, $max_time). Using those max values instead. Good luck.\n"; 208 217 } 209 218 else { 210 $time_req = int(($node_need * $job_cost) / ($fill_factor * $max_nodes)) + 1; 211 $node_req = int(($node_need * $job_cost) / ($fill_factor * $time_req)) + 1; 212 } 213 $time_req += 1; # Safety addition. 214 215 open(COMMAND, ">$disk_command") || &my_die("Couldn't open file? $disk_command",$chip_id,$PS_EXIT_SYS_ERROR); 219 $time_req = int(($node_need * $job_cost{$stage}) / ($fill_factor * $max_nodes)) + 1; 220 $node_req = int(($node_need * $job_cost{$stage}) / ($fill_factor * $time_req)) + 1; 221 } 222 223 if ($stage eq "stack") { 224 $time_req += 2; 225 $node_req *= 3; 226 } else { 227 $time_req += 1; # Safety addition. 228 } 229 230 open(COMMAND, ">$disk_command") || &my_die("Couldn't open file? $disk_command", $remote_id, $PS_EXIT_SYS_ERROR, $fail_state); 216 231 print COMMAND "#!/bin/tcsh\n"; 217 232 print COMMAND "##### Moab controll lines\n"; … … 219 234 print COMMAND "#MSUB -j oe\n"; 220 235 print COMMAND "#MSUB -V\n"; 221 print COMMAND "#MSUB -o ${remote_root} chip.${remote_id}.out\n";236 print COMMAND "#MSUB -o ${remote_root}/${stage}.${remote_id}.out\n"; 222 237 print COMMAND "date\n"; 223 238 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"; … … 246 261 247 262 unless(defined($ipp_disk)) { 248 my_die();263 &my_die( "Unable to generate file for $neb_uri ", $remote_id, $PS_EXIT_SYS_ERROR, $fail_state); 249 264 } 250 265 … … 258 273 sub my_die { 259 274 my $msg = shift; 260 my $ id = shift;275 my $remote_id = shift; 261 276 my $exit_code = shift; 262 277 my $exit_state = shift; … … 266 281 carp($msg); 267 282 268 if (defined $ id and not $no_update) {269 my $command = "remotetool -updaterun -remote_id $ id";283 if (defined $remote_id and not $no_update) { 284 my $command = "remotetool -updaterun -remote_id $remote_id"; 270 285 $command .= " -fault $exit_code " if defined $exit_code; 271 286 $command .= " -set_state $exit_state " if defined $exit_state; -
tags/ipp-pv3-20140717/ippScripts/scripts/sc_prepare_stack.pl
r37196 r37291 1 1 #! /usr/bin/env perl 2 3 # generate the input & output files lists and commands for a single stackRun 2 4 3 5 use Carp; … … 16 18 use Pod::Usage qw( pod2usage ); 17 19 18 19 20 # 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 22 my $remote_root = '/scratch3/watersc1/'; # Far side destination base location 23 my $threads_req = 4; # How many threads are we going to use? 24 25 my $fail_state = "prep_fail"; 26 36 27 # Look for programs we need 37 28 my $missing_tools; 38 39 29 my $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);30 my $stacktool = can_run('stacktool') or (warn "Can't find stacktool" and $missing_tools = 1); 41 31 42 32 if ($missing_tools) { … … 48 38 GetOptions( 49 39 'remote_id=s' => \$remote_id, 40 'stack_id=s' => \$stack_id, 50 41 'camera|c=s' => \$camera, 51 42 'dbname|d=s' => \$dbname, … … 56 47 57 48 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 58 pod2usage( -msg => "Required options: --remote_id -- camera --dbname --path_base", -exitval => 3) unless49 pod2usage( -msg => "Required options: --remote_id --stack_id --camera --dbname --path_base", -exitval => 3) unless 59 50 defined($remote_id) and 51 defined($stack_id) and 60 52 defined($camera) and 61 53 defined($path_base) and 62 54 defined($dbname); 63 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id); 55 56 my $ipprc = PS::IPP::Config->new( $camera ) or &my_die( "Unable to set up", $remote_id, $stack_id, $PS_EXIT_CONFIG_ERROR, $fail_state); 64 57 65 58 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 66 59 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"; 60 my @return_component_list = ("DBINFO.EXP", "PPSTACK.UNCONV","PPSTACK.UNCONV.MASK","PPSTACK.UNCONV.VARIANCE", 61 "PPSTACK.UNCONV.EXP","PPSTACK.UNCONV.EXPWT","PPSTACK.UNCONV.EXPNUM","PSPHOT.OUTPUT", 62 "LOG.EXP", "PSASTRO.STATS", 63 "PPSTACK.CONFIG","PPSTACK.TARGET.PSF","PSPHOT.STACK.PSF.SAVE"); 64 #,"PPSTACK.CONV.KERNEL"); 65 66 # STEP 0: Open output files 89 67 my $uri_transfer= $path_base . ".transfer"; 90 68 my $uri_check = $path_base . ".check"; … … 93 71 my $uri_return = $path_base . ".return"; 94 72 95 my $disk_command = $ipprc->file_resolve($uri_command,1);96 73 my $disk_transfer= $ipprc->file_resolve($uri_transfer,1); 97 74 my $disk_check = $ipprc->file_resolve($uri_check,1); … … 102 79 my (undef, $remote_config) = uri_convert($uri_config); # Needs to be done after we've created it. 103 80 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. 81 open(TRANSFER, ">$disk_transfer") || &my_die("Couldn't open file? $disk_transfer",$remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state); 82 open(CHECK, ">$disk_check") || &my_die("Couldn't open file? $disk_check", $remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state); 83 open(CONFIG, ">$disk_config") || &my_die("Couldn't open file? $disk_config", $remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state); 84 open(GENERATE, ">$disk_generate") || &my_die("Couldn't open file? $disk_generate",$remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state); 85 open(RETURN, ">$disk_return") || &my_die("Couldn't open file? $disk_return", $remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state); 86 113 87 my $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); 88 89 # STEP 1: Get exposure level information from the stackRun we're working from. 90 my ($reduction, $workdir, $tess_id, $skycell_id); 91 { 92 my $command = "$stacktool -tosum -stack_id $stack_id"; 93 $command .= " -dbname $dbname " if defined($dbname); 126 94 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 127 run(command => $ run_command, verbose => 0);95 run(command => $command, verbose => 0); 128 96 unless ($success) { 129 97 $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}; 98 &my_die("Unable to run stacktool -tosum ", $remote_id, $stack_id, $error_code, $fail_state); 99 } 100 101 my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or 102 &my_die("Unable to determine stack component information.", $remote_id, $stack_id, $PS_EXIT_PROG_ERROR, $fail_state); 103 my $metadata = parse_md_list($MDlist); 104 105 my $stack = $metadata->[0]; 106 107 $reduction = $stack->{reduction}; 141 108 $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}"); 109 $workdir = $stack->{workdir}; 110 $tess_id = $stack->{tess_id}; 111 $skycell_id= $stack->{skycell_id}; 112 } 113 my $ipp_outroot = "${workdir}/${tess_id}/${skycell_id}/${tess_id}.${skycell_id}.stk.${stack_id}"; 114 my $remote_outroot = uri_local_to_remote($ipp_outroot); 115 my $remote_outdir = uri_local_to_remote("${workdir}/${tess_id}/${skycell_id}"); 116 117 # STEP 2: Get the list of input warps 118 my ($warpData); 119 { 149 120 # This actually returns all the individual stack/skyfiles that comprise this run. Because consistency. 150 121 my $command = "$stacktool -inputskyfile -stack_id $stack_id "; … … 154 125 unless ($success) { 155 126 $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 127 &my_die("Unable to run stacktool -inputskyfile ", $remote_id, $stack_id, $error_code, $fail_state); 128 } 129 130 my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or 131 &my_die("Unable to determine stack component information.", $remote_id, $stack_id, $PS_EXIT_PROG_ERROR, $fail_state); 132 my $warpData = parse_md_list($MDlist); 133 } 134 135 # STEP 3: Iterate over the sub-components 136 { 167 137 my $warp_path_base_string = ""; 168 foreach my $warpEntry ( @{ $warpData 2} ) {138 foreach my $warpEntry ( @{ $warpData } ) { 169 139 my $warp_path_base = $warpEntry->{path_base}; 170 140 my $remote_path_base = uri_local_to_remote($warp_path_base); … … 191 161 $ppstack_command .= " -R PPSTACK.UNCONV.VARIANCE FITS.TYPE COMP_STACK"; 192 162 $ppstack_command .= " -tracedest ${remote_outroot}.trace -log ${remote_outroot}.log "; 193 $ppstack_command .= " -threads 4";163 $ppstack_command .= " -threads $threads_req "; 194 164 $ppstack_command .= " -dumpconfig ${remote_outroot}.mdc "; 195 165 $ppstack_command .= " -stack_id $stack_id -skycell_id $skycell_id -tess_id $tess_id "; … … 212 182 print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk "; 213 183 } 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 218 184 print CONFIG "\n"; 219 185 } … … 224 190 close(GENERATE); 225 191 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 fill233 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 RESOURCES254 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 263 192 unless($no_update) { 264 my $command = "remotetool -updaterun -remote_id $remote_id "; 265 $command .= " -set_state pending "; 193 my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $stack_id "; 194 $command .= " -set_jobs $job_index"; 195 $command .= " -set_path_base $path_base"; 196 $command .= " -set_state prep_done"; 266 197 $command .= " -dbname $dbname " if defined $dbname; 267 198 268 199 system($command); 269 200 } 270 271 201 272 202 ## Common SC routines … … 278 208 279 209 unless(defined($ipp_disk)) { 280 my_die();210 &my_die( "Unable to generate file for $neb_uri ", $remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state); 281 211 } 282 212 … … 294 224 295 225 unless(defined($ipp_disk)) { 296 my_die();226 &my_die( "Unable to generate file for $neb_uri ", $remote_id, $stack_id, $PS_EXIT_SYS_ERROR, $fail_state); 297 227 } 298 228 … … 350 280 sub my_die { # exit with status; my_die(message,stage_id,exit_code,exit_status); 351 281 my $msg = shift; 352 my $id = shift; 282 my $remote_id = shift; 283 my $stage_id = shift; 353 284 my $exit_code = shift; 354 285 my $exit_state = shift; … … 358 289 carp($msg); 359 290 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; 291 if (defined $remote_id and defined $stage_id and not $no_update) { 292 my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $stage_id"; 363 293 $command .= " -set_state $exit_state " if defined $exit_state; 364 294 $command .= " -dbname $dbname " if defined $dbname; -
tags/ipp-pv3-20140717/ippScripts/scripts/sc_prepare_warp.pl
r37155 r37291 1 1 #! /usr/bin/env perl 2 3 # generate the input & output files lists and commands for a single warpRun 2 4 3 5 use Carp; … … 16 18 use Pod::Usage qw( pod2usage ); 17 19 18 19 20 # 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 22 my $remote_root = '/scratch3/watersc1/'; 23 my $threads_req = 4; # How many threads are we going to use? 24 25 my $fail_state = "prep_fail"; 26 32 27 # Look for programs we need 33 28 my $missing_tools; 34 35 29 my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1); 36 30 my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1); … … 41 35 } 42 36 43 my ($remote_id,$warp_id, ,$camera,$dbname,$verbose,$path_base,$no_update);37 my ($remote_id,$warp_id,$camera,$dbname,$verbose,$path_base,$no_update); 44 38 GetOptions( 45 39 'remote_id=s' => \$remote_id, 40 'warp_id=s' => \$warp_id, 46 41 'camera|c=s' => \$camera, 47 42 'dbname|d=s' => \$dbname, … … 52 47 53 48 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 54 pod2usage( -msg => "Required options: --remote_id - -camera --dbname --path_base", -exitval => 3) unless49 pod2usage( -msg => "Required options: --remote_id -warp_id --camera --dbname --path_base", -exitval => 3) unless 55 50 defined($remote_id) and 51 defined($warp_id) and 56 52 defined($camera) and 57 53 defined($path_base) and 58 54 defined($dbname); 59 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $warp_id); 55 56 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id, $warp_id, $PS_EXIT_CONFIG_ERROR, $fail_state); 60 57 61 58 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 62 59 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"; 60 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"); 61 62 # STEP 0: Open output files 85 63 my $uri_transfer= $path_base . ".transfer"; 86 64 my $uri_check = $path_base . ".check"; … … 89 67 my $uri_return = $path_base . ".return"; 90 68 91 my $disk_command = $ipprc->file_resolve($uri_command,1);92 69 my $disk_transfer= $ipprc->file_resolve($uri_transfer,1); 93 70 my $disk_check = $ipprc->file_resolve($uri_check,1); … … 98 75 my (undef, $remote_config) = uri_convert($uri_config); # Needs to be done after we've created it. 99 76 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. 77 open(TRANSFER, ">$disk_transfer") || &my_die("Couldn't open file? $disk_transfer",$remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state); 78 open(CHECK, ">$disk_check") || &my_die("Couldn't open file? $disk_check", $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state); 79 open(CONFIG, ">$disk_config") || &my_die("Couldn't open file? $disk_config", $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state); 80 open(GENERATE, ">$disk_generate") || &my_die("Couldn't open file? $disk_generate",$remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state); 81 open(RETURN, ">$disk_return") || &my_die("Couldn't open file? $disk_return", $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state); 82 109 83 my $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. 84 85 # STEP 1: Get exposure level information from the warpRun we're working from. 86 my ($warpData); 87 { 120 88 # This actually returns all the individual warp/skyfiles that comprise this run. Because consistency. 121 89 my $command = "$warptool -towarped -warp_id $warp_id "; … … 125 93 unless ($success) { 126 94 $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 } ) { 95 &my_die("Unable to run warptool -pendingimfile ", $remote_id, $warp_id, $error_code, $fail_state); 96 } 97 my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or 98 &my_die("Unable to determine warp component information.", $remote_id, $warp_id, $PS_EXIT_PROG_ERROR, $fail_state); 99 $warpData = parse_md_list($MDlist); 100 } 101 102 # STEP 2: Iterate over the sub-components 103 { 104 foreach my $warpEntry ( @{ $warpData } ) { 138 105 my $workdir = $warpEntry->{workdir}; 139 106 my $exp_tag = $warpEntry->{exp_tag}; … … 146 113 my $remote_outroot = uri_local_to_remote($ipp_outroot); 147 114 148 my $ reg_command = "$warptool -scmap -warp_id $warp_id -skycell_id ${skycell_id}";149 $ reg_command .= " -dbname $dbname " if defined($dbname);115 my $command = "$warptool -scmap -warp_id $warp_id -skycell_id ${skycell_id}"; 116 $command .= " -dbname $dbname " if defined($dbname); 150 117 151 118 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 152 run(command => $ reg_command, verbose => 0);119 run(command => $command, verbose => 0); 153 120 unless ($success) { 154 121 $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); 122 &my_die("Unable to run warptool -pendingimfile: $command ", $remote_id, $warp_id, $error_code, $fail_state); 157 123 } 158 124 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); 125 my $MDlist = $mdcParser->parse(join "", @$stdout_buf) or 126 &my_die("Unable to determine warp component information.", $remote_id, $warp_id, $PS_EXIT_PROG_ERROR, $fail_state); 127 my $inData = parse_md_list($MDlist); 163 128 164 129 my $pre_cmd_ims = "ls -1 "; … … 167 132 my $pre_cmd_astrom = ""; 168 133 169 foreach my $imfile (@{ $in pData2 }) {134 foreach my $imfile (@{ $inData2 }) { 170 135 my $image = $ipprc->filename("PPIMAGE.CHIP", $imfile->{chip_path_base}, $imfile->{class_id}); 171 136 my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $imfile->{cam_path_base}, $imfile->{class_id}); … … 202 167 $pswarp_command .= " -recipe PSWARP $recipe_pswarp "; 203 168 $pswarp_command .= " -tracedest ${remote_outroot}.trace -log ${remote_outroot}.log "; 204 $pswarp_command .= " -threads 4"; # -image_id ${image_id} -source_id ${source_id} ";169 $pswarp_command .= " -threads $threads_req "; # -image_id ${image_id} -source_id ${source_id} "; 205 170 $pswarp_command .= " -recipe PPSTATS WARPSTATS "; 206 171 $pswarp_command .= " -dumpconfig ${remote_outroot}.pswarp.mdc -stats ${remote_outroot}.stats "; … … 225 190 print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} && touch $remote_disk "; 226 191 } 227 228 192 print CONFIG "\n"; 229 193 # die(); … … 236 200 close(GENERATE); 237 201 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 fill245 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 RESOURCES265 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 274 202 unless($no_update) { 275 my $command = "remotetool -updaterun -remote_id $remote_id "; 276 $command .= " -set_state pending "; 203 my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $warp_id "; 204 $command .= " -set_jobs $job_index"; 205 $command .= " -set_path_base $path_base"; 206 $command .= " -set_state prep_done"; 277 207 $command .= " -dbname $dbname " if defined $dbname; 278 208 279 209 system($command); 280 210 } 281 211 exit (0); 282 212 283 213 ## Common SC routines … … 289 219 290 220 unless(defined($ipp_disk)) { 291 my_die();221 &my_die( "Unable to generate file for $neb_uri ", $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state); 292 222 } 293 223 … … 305 235 306 236 unless(defined($ipp_disk)) { 307 my_die();237 &my_die( "Unable to generate file for $neb_uri ", $remote_id, $warp_id, $PS_EXIT_SYS_ERROR, $fail_state); 308 238 } 309 239 … … 361 291 sub my_die { # exit with status; my_die(message,stage_id,exit_code,exit_status); 362 292 my $msg = shift; 363 my $id = shift; 293 my $remote_id = shift; 294 my $stage_id = shift; 364 295 my $exit_code = shift; 365 296 my $exit_state = shift; … … 369 300 carp($msg); 370 301 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; 302 if (defined $remote_id and defined $stage_id and not $no_update) { 303 my $command = "remotetool -updatecomponent -remote_id $remote_id -stage_id $stage_id"; 374 304 $command .= " -set_state $exit_state " if defined $exit_state; 375 305 $command .= " -dbname $dbname " if defined $dbname;
Note:
See TracChangeset
for help on using the changeset viewer.
