Changeset 36844 for trunk/ippScripts/scripts
- Timestamp:
- Jun 9, 2014, 6:17:18 PM (12 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 4 added
- 2 edited
-
sc_mk_stack_mdc.pl (added)
-
sc_prepare_camera.pl (added)
-
sc_prepare_chip.pl (modified) (13 diffs)
-
sc_prepare_warp.pl (added)
-
sc_remote_exec.pl (modified) (11 diffs)
-
sc_transfer_tool.pl (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/sc_prepare_chip.pl
r36596 r36844 19 19 # Hard coded values 20 20 my $remote_root = '/scratch3/watersc1/'; # Far side destination base location 21 my $remote_raw = "${remote_root}/raw/"; # Directory to find raw data in. 21 22 my $threads = 2; # How many threads are we going to use? 22 23 my $job_cost = 150 / 60 / 60; # Estimate of how long a job runs, in hours. … … 150 151 #print Dumper(%detrends); 151 152 153 my @return_component_list = ("DBINFO.IMFILE","PPIMAGE.STATS","LOG.IMFILE","TRACE.IMFILE","PPIMAGE.BACKMDL","PPIMAGE.PATTERN"); 152 154 153 155 # … … 157 159 my $uri_check = $path_base . ".check"; 158 160 my $uri_config = $path_base . ".config"; 161 my $uri_generate= $path_base . ".generate"; 162 my $uri_return = $path_base . ".return"; 159 163 160 164 my $disk_command = $ipprc->file_resolve($uri_command,1); … … 162 166 my $disk_check = $ipprc->file_resolve($uri_check,1); 163 167 my $disk_config = $ipprc->file_resolve($uri_config,1); 168 my $disk_generate= $ipprc->file_resolve($uri_generate,1); 169 my $disk_return = $ipprc->file_resolve($uri_return,1); 164 170 165 171 my (undef, $remote_config) = uri_convert($uri_config); # Needs to be done after we've created it. … … 168 174 open(CHECK, ">$disk_check") || &my_die("Couldn't open file? $disk_check",$chip_id,$PS_EXIT_SYS_ERROR); 169 175 open(CONFIG, ">$disk_config") || &my_die("Couldn't open file? $disk_config",$chip_id,$PS_EXIT_SYS_ERROR); 176 open(GENERATE, ">$disk_generate") || &my_die("Couldn't open file? $disk_generate",$chip_id,$PS_EXIT_SYS_ERROR); 177 open(RETURN, ">$disk_return") || &my_die("Couldn't open file? $disk_return", $chip_id, $PS_EXIT_SYS_ERROR); 178 170 179 171 180 # … … 185 194 186 195 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 187 run(command => $command, verbose => $verbose);196 run(command => $command, verbose => 0); 188 197 unless ($success) { 189 198 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); … … 254 263 255 264 my $chipData = $mdcParser->parse(join "", @$stdout_buf) or 256 &my_die("Unable to parse chiptool -pendingimfile information.", 257 $chip_id,$error_code); 265 next; 266 # &my_die("Unable to parse chiptool -pendingimfile information.", 267 # $chip_id,$error_code); 258 268 my $chipData2= parse_md_list($chipData); 259 269 … … 270 280 271 281 # Process the image and burntool table 272 my ( undef,$remote_uri) = uri_to_outputs($uri);282 my ($ipp_uri,$remote_uri) = uri_to_outputs_raw($uri); 273 283 my $btt = $uri; 274 284 $btt =~ s/fits$/burn.tbl/; 275 my ( undef,$remote_btt) = uri_to_outputs($btt);285 my ($ipp_btt,$remote_btt) = uri_to_outputs_raw($btt); 276 286 277 287 # Initialize the ppI command … … 287 297 my $det_code = $det_types{$det}; 288 298 my $duri = $detrends_to_use{$det}->{$class_id}; 289 my ( undef, $remote_det_uri) = uri_to_outputs($duri);299 my ($ipp_det_uri, $remote_det_uri) = uri_to_outputs_raw($duri); 290 300 $ppImage_command .= " $det_code $remote_det_uri "; 291 301 } … … 310 320 $ppImage_command .= " -log ${remote_outroot}.${class_id}.log "; 311 321 312 push @main_commands, $ppImage_command;322 # push @main_commands, $ppImage_command; 313 323 314 324 # Calculate pre and post commands 315 325 my $remote_outroot_dir = dirname($remote_outroot); 316 push @pre_commands,"mkdir -p $remote_outroot_dir";326 my $pre_command = "mkdir -p $remote_outroot_dir"; 317 327 318 328 my $post_commandA = "chiptool -addprocessedimfile -exp_id $exp_id -chip_id $chip_id -class_id $class_id "; … … 321 331 $post_commandA .= " -dbname $dbname " if defined $dbname; 322 332 323 my $post_commandB = "echo -n $post_commandA > ${remote_outroot}.${class_id}.dbinfo &&";333 my $post_commandB = "echo -n \"$post_commandA\" > ${remote_outroot}.${class_id}.dbinfo "; 324 334 my $post_commandC = "ppStatsFromMetadata ${remote_outroot}.${class_id}.stats - CHIP_IMFILE >> ${remote_outroot}.${class_id}.dbinfo"; 325 335 326 push @post_commands, "$post_commandB $post_commandC";336 # push @post_commands, "$post_commandB $post_commandC"; 327 337 328 338 $job_index++; 339 340 print CONFIG "${pre_command} && ${ppImage_command} && ${post_commandB} && ${post_commandC}"; 341 342 343 # Determine which output files need to be returned. 344 foreach my $component (@return_component_list) { 345 # uri_convert_and_create( $ipprc->filename($component, $ipp_outroot, $class_id) ); 346 my $filename = $ipprc->filename($component, $ipp_outroot, $class_id); 347 my ($ipp_disk, $remote_disk) = uri_to_outputs_for_return( $filename ); 348 my $remote_outroot_dir = dirname($ipp_disk); 349 print CONFIG " && mkdir -p ${remote_root}/tmp/${remote_outroot_dir} && ln -sf $remote_disk ${remote_root}/tmp/${ipp_disk} "; 350 # print " $filename $ipp_disk $remote_disk\n"; 351 # die; 352 } 353 354 print CONFIG "\n"; 329 355 } 330 356 } 331 357 332 358 # Actually put the commands into the output file. 333 my %unique_cmds = ();334 foreach my $cmd (@pre_commands) {335 unless(exists($unique_cmds{$cmd})) {336 print CONFIG $cmd . "\n";337 $unique_cmds{$cmd} = 1;338 }339 }340 foreach my $cmd (@main_commands) {341 unless(exists($unique_cmds{$cmd})) {342 print CONFIG $cmd . "\n";343 $unique_cmds{$cmd} = 1;344 }345 }346 foreach my $cmd (@post_commands) {347 unless(exists($unique_cmds{$cmd})) {348 print CONFIG $cmd . "\n";349 $unique_cmds{$cmd} = 1;350 }351 }359 # my %unique_cmds = (); 360 # foreach my $cmd (@pre_commands) { 361 # unless(exists($unique_cmds{$cmd})) { 362 # print CONFIG $cmd . "\n"; 363 # $unique_cmds{$cmd} = 1; 364 # } 365 # } 366 # foreach my $cmd (@main_commands) { 367 # unless(exists($unique_cmds{$cmd})) { 368 # print CONFIG $cmd . "\n"; 369 # $unique_cmds{$cmd} = 1; 370 # } 371 # } 372 # foreach my $cmd (@post_commands) { 373 # unless(exists($unique_cmds{$cmd})) { 374 # print CONFIG $cmd . "\n"; 375 # $unique_cmds{$cmd} = 1; 376 # } 377 # } 352 378 353 379 close(CONFIG); 354 380 close(TRANSFER); 355 381 close(CHECK); 382 close(RETURN); 383 close(GENERATE); 356 384 357 385 # … … 425 453 } 426 454 455 sub uri_convert_and_create { 456 my $neb_uri = shift; 457 my $ipp_disk= $ipprc->file_resolve( $neb_uri , 1); 458 my $remote_disk = $ipp_disk; 459 460 unless(defined($ipp_disk)) { 461 my_die(); 462 } 463 464 $remote_disk =~ s%^.*/%%; # Remove nebulous path 465 $remote_disk =~ s%^\d+\.%%; # Remove ins_id 466 $remote_disk =~ s%:%/%g; # Replace colons with directories 467 $remote_disk = "${remote_root}/${remote_disk}"; 468 return($ipp_disk,$remote_disk); 469 } 470 427 471 sub uri_to_outputs { 428 472 my $neb_uri = shift; … … 433 477 print TRANSFER "$ipp_disk\n"; 434 478 print CHECK "$remote_disk\n"; 479 } 480 return($ipp_disk,$remote_disk); 481 } 482 483 sub uri_to_outputs_raw { 484 my $neb_uri = shift; 485 my ($ipp_disk, $remote_disk) = uri_convert( $neb_uri ); 486 $remote_disk = $remote_raw . $ipp_disk; 487 unless (exists($file_filter{$neb_uri})) { 488 $file_filter{$neb_uri} = 1; 489 print TRANSFER "$ipp_disk\n"; 490 print CHECK "$remote_disk\n"; 491 } 492 return($ipp_disk,$remote_disk); 493 } 494 495 sub uri_to_outputs_for_return { 496 my $neb_uri = shift; 497 my ($ipp_disk, $remote_disk) = uri_convert_and_create( $neb_uri ); 498 unless (exists($file_filter{$neb_uri})) { 499 $file_filter{$neb_uri} = 1; 500 print RETURN "$ipp_disk\n"; 501 print GENERATE "$remote_disk\n"; 435 502 } 436 503 return($ipp_disk,$remote_disk); -
trunk/ippScripts/scripts/sc_remote_exec.pl
r36583 r36844 16 16 # Hard coded values 17 17 my $DMZ_HOST = 'wtrw'; 18 my $SEC_HOST = 'mu-fe ';18 my $SEC_HOST = 'mu-fe4'; 19 19 my $IPP_PATH = '/turquoise/usr/projects/cosmo/mswarren/ipp/'; 20 20 my $remote_root = '/scratch3/watersc1/'; … … 24 24 my $ssh = can_run('ssh') or (warn "Can't find ssh" and $missing_tools = 1); 25 25 my $scp = can_run('scp') or (warn "Can't find scp" and $missing_tools = 1); 26 my $remotetool = can_run(' echo') or (warn "Can't find remotetool" and $missing_tools = 1);26 my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1); 27 27 28 28 if ($missing_tools) { … … 72 72 my $uri_check = $path_base . ".check"; 73 73 my $uri_config = $path_base . ".config"; 74 my $uri_generate= $path_base . ".generate"; 75 my $uri_return = $path_base . ".return"; 74 76 75 77 my $disk_command = $ipprc->file_resolve($uri_command); … … 77 79 my $disk_check = $ipprc->file_resolve($uri_check); 78 80 my $disk_config = $ipprc->file_resolve($uri_config); 81 my $disk_generate= $ipprc->file_resolve($uri_generate); 82 my $disk_return = $ipprc->file_resolve($uri_return); 79 83 80 84 scp_put($disk_command,uri_local_to_remote($uri_command)); … … 82 86 scp_put($disk_check,uri_local_to_remote($uri_check)); 83 87 scp_put($disk_config,uri_local_to_remote($uri_config)); 88 scp_put($disk_generate,uri_local_to_remote($uri_generate)); 89 scp_put($disk_return, uri_local_to_remote($uri_return)); 84 90 85 91 # Run check command 86 92 my (undef,$remote_check) = uri_convert($uri_check); 87 my $ssh_check_stdout = ssh_exec_command("${remote_root}/sc_validate_files.pl --check_list $remote_check"); 88 89 # Parse stdout for files to transfer. 90 if ($#{ $ssh_check_stdout } != -1) { # There were files not found. 91 # Someone was missing. Use the check and transfer lists to identify the local version, and send it. 92 # What was missing? 93 my %missing_files = (); 94 foreach my $l (split /\n/, (join '', @$ssh_check_stdout)) { 95 print "Missing!: $l\n"; 96 $missing_files{$l} = 1; 97 } 98 99 # Do we have that file? 100 my @check_files = (); 101 open(CHECK,$disk_check); 102 while(<CHECK>) { 103 chomp; 104 push @check_files, $_; 105 } 106 close(CHECK); 107 108 my @trans_files = (); 109 open(TRANS,$disk_transfer); 110 while(<TRANS>) { 111 chomp; 112 push @trans_files, $_; 113 } 114 close(TRANS); 115 116 if ($#trans_files != $#check_files) { &my_die("The transfer file list and check file list are different sizes", 117 $remote_id,$PS_EXIT_DATA_ERROR); } 118 119 for (my $i = 0; $i <= $#check_files; $i++) { 120 if (exists($missing_files{$check_files[$i]})) { 121 if ($trans_files[$i] ne "REMOTE_ONLY") { 122 scp_put($trans_files[$i],"$check_files[$i]"); 123 } 124 else { 125 &my_die("There is a file that should be there, but the file isn't there, and I don't have a copy of that file here. The file is: $check_files[$i]", 126 $remote_id,$PS_EXIT_DATA_ERROR); # This seems a bit harsh. 127 } 128 } 129 } 130 } 131 93 my (undef,$remote_transfer)= uri_convert($uri_transfer); 94 # my $ssh_check_stdout = ssh_exec_command("${remote_root}/sc_validate_files.pl --check_list $remote_check --transfer_list $remote_transfer"); 95 my $ssh_check_stdout = ssh_exec_command("${remote_root}/sc_transfer_tool.pl --input $remote_check --fetch $remote_transfer"); 96 # We no longer need to parse this output, as it retrieves files itself. 97 foreach my $l (split /\n/, (join '', @$ssh_check_stdout)) { 98 print "$l\n"; 99 } 132 100 133 101 # Run real command … … 147 115 my $command = "$remotetool -updaterun -remote_id $remote_id "; 148 116 $command .= " -set_state run "; 149 $command .= " - set_job_id $job_id ";117 $command .= " -job_id $job_id "; 150 118 $command .= " -dbname $dbname " if defined $dbname; 151 119 152 120 system($command); 153 121 154 } 122 } # End of exec phase 155 123 156 124 # Check that we have a valid job_id, either from the command line, or from the msub command. … … 185 153 print "Stopped Polling code. $poll_count of $poll_max $poll_response\n"; 186 154 } 155 if ($poll_response != 1) { 156 &my_die("Job hasn't completed. Ending polling.", $remote_id, 0, "run", $job_id); 157 } 187 158 # Retrieve validation summary 188 159 my $fault = 0; 189 160 190 exit(1); 191 # Read this as a metadata object 192 my $ssh_exec_stdout = ssh_exec_command("sc_validate_processing.pl ${path_base}.out"); 193 my $retrieveData = $mdcParser->parse(join "", @$ssh_exec_stdout); 194 my $retrieveData2= parse_md_list($retrieveData); 195 196 foreach my $retrieveEntry (@$retrieveData2) { 197 my $process_fault = $retrieveEntry->{fault}; 198 my $dbcommand = $retrieveEntry->{dbcommand}; 199 my $filelist = $retrieveEntry->{filelist}; 200 201 scp_get("${filelist}",${filelist}); 202 open(FL,${filelist}); 203 while(<FL>) { 204 chomp; 205 my $f = $_; 206 scp_get("${f}",$f); 207 } 208 close(FL); 209 210 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 211 run(command => $dbcommand, verbose => $verbose); 212 unless ($success) { 213 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 214 &my_die("The database command returned did not execute correctly. $dbcommand $process_fault", 215 $remote_id,$error_code); 216 } 217 218 if ($process_fault != 0) { 219 $fault = 1; 220 } 221 } 222 223 if (($policy ne 'ignore')&&($fault != 0)) { 224 &my_die("This job exited without all components finishing successfully. Halting.", 225 $remote_id,$fault,"halt"); 226 } 227 else { 228 print "This job exited without all components finishing successfully. $fault\n" if $fault; 229 &my_die("This job finished. Setting remote job to full.", 230 $remote_id,0,"full"); 231 } 232 233 # Promote to finished. 234 &my_die(); # Not really, but I don't have the tool interface finished, so these are all just placeholders. 235 # Quick review: 236 # new -> pending -> run -> full 237 # auth 161 # Initialize the remote side to sync things 162 163 # Once sync completes, execute all the database commands 164 # Grab the return list 165 my $uri_return = $path_base . ".return"; 166 my ($ipp_return,$remote_return) = uri_convert($uri_return); 167 scp_get($remote_return,$ipp_return); 168 # Feed teh return list into the 169 my $return_push_output = ssh_exec_command("${remote_root}/sc_transfer_tool.pl --input $remote_return"); 170 print "$return_push_output\n"; 171 172 173 open(RETURN, "$ipp_return") || &my_die("Couldn't open file? $ipp_return", $remote_id,$PS_EXIT_SYS_ERROR); 174 while(<RETURN>) { 175 chomp; 176 if ($_ =~ /dbinfo/) { 177 my $file = $_; 178 # $file =~ s/${remote_root}.tmp//; THis shouldn't be needed, as the transfer tool munges the files on that side. 179 open(DBF,"$file") || warn "Missing file $file\n"; 180 my $cmd = <DBF>; 181 chomp($cmd); 182 $cmd =~ s/-/ -/g; # This is just a safety check for missing space. 183 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 184 run(command => $cmd, verbose => $verbose); 185 unless ($success) { 186 # This shouldn't fail, but we also can't suddenly abort if something does fail. Maybe retry if this looks to be a continuing issue? 187 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 188 warn("The command that shouldn't fail has failed: $cmd $remote_id $error_code");##,$remote_id,$error_code); 189 } 190 close(DBF); 191 } 192 } 193 close(RETURN); 194 195 # We're done, so set the state and exit. 196 &my_die("Finished",$remote_id,0,"full"); 197 198 238 199 239 200 # END PROGRAM … … 294 255 unless ($success) { 295 256 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 296 &my_die( );257 &my_die("Failed to execute command: >>$cmd<<"); 297 258 } 298 259 return ($stdout_buf); … … 368 329 my $exit_code = shift; 369 330 my $exit_state = shift; 370 331 my $jobid = shift; 371 332 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 372 333 … … 374 335 375 336 if (defined $id and not $no_update) { 376 my $command = "$remotetool -updaterun - stage_id $id";337 my $command = "$remotetool -updaterun -remote_id $id"; 377 338 $command .= " -fault $exit_code " if defined $exit_code; 339 $command .= " -job_id $job_id " if defined $jobid; 378 340 $command .= " -set_state $exit_state " if defined $exit_state; 379 341 $command .= " -dbname $dbname " if defined $dbname; … … 384 346 exit($exit_code); 385 347 } 348 349 # I don't think I need this anymore, but I don't want to burn it until I"m sure. 350 351 # exit(1); 352 # # Read this as a metadata object 353 # my $ssh_exec_stdout = ssh_exec_command("sc_validate_processing.pl ${path_base}.out"); 354 # my $retrieveData = $mdcParser->parse(join "", @$ssh_exec_stdout); 355 # my $retrieveData2= parse_md_list($retrieveData); 356 357 # foreach my $retrieveEntry (@$retrieveData2) { 358 # my $process_fault = $retrieveEntry->{fault}; 359 # my $dbcommand = $retrieveEntry->{dbcommand}; 360 # my $filelist = $retrieveEntry->{filelist}; 361 362 # scp_get("${filelist}",${filelist}); 363 # open(FL,${filelist}); 364 # while(<FL>) { 365 # chomp; 366 # my $f = $_; 367 # scp_get("${f}",$f); 368 # } 369 # close(FL); 370 371 # my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 372 # run(command => $dbcommand, verbose => $verbose); 373 # unless ($success) { 374 # $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 375 # &my_die("The database command returned did not execute correctly. $dbcommand $process_fault", 376 # $remote_id,$error_code); 377 # } 378 379 # if ($process_fault != 0) { 380 # $fault = 1; 381 # } 382 # } 383 384 # if (($policy ne 'ignore')&&($fault != 0)) { 385 # &my_die("This job exited without all components finishing successfully. Halting.", 386 # $remote_id,$fault,"halt"); 387 # } 388 # else { 389 # print "This job exited without all components finishing successfully. $fault\n" if $fault; 390 # &my_die("This job finished. Setting remote job to full.", 391 # $remote_id,0,"full"); 392 # } 393 394 # Promote to finished. 395 #&my_die(); # Not really, but I don't have the tool interface finished, so these are all just placeholders. 396 # Quick review: 397 # new -> pending -> run -> full 398 # auth
Note:
See TracChangeset
for help on using the changeset viewer.
