Changeset 6221 for branches/1.6/lang/tcl/scripts
- Timestamp:
- Mar 30, 2016, 6:08:17 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.6/lang/tcl/scripts/task.tcl
r6205 r6221 26 26 private method GetSignal { signal } 27 27 private method GetSimulationCommand { driverFile } 28 private method GetUQErrors {} 28 29 private method GetUQSimulationCommand { driverFile } 29 30 private method GetUQTemplateFile {} … … 68 69 69 70 public common _resources 70 public proc setAppName {name} { set _resources(-appname) $name }71 public proc setHubName {name} { set _resources(-hubname) $name }72 public proc setHubURL {name} { set _resources(-huburl) $name }73 public proc setSession {name} { set _resources(-session) $name }74 public proc setJobPrt {name} { set _resources(-jobprotocol) $name }75 public proc setResultDir {name} { set _resources(-resultdir) $name }76 public proc setCacheHost {name} { set _resources(-cachehost) $name }71 public proc setAppName {name} { set _resources(-appname) $name } 72 public proc setHubName {name} { set _resources(-hubname) $name } 73 public proc setHubURL {name} { set _resources(-huburl) $name } 74 public proc setSession {name} { set _resources(-session) $name } 75 public proc setJobPrt {name} { set _resources(-jobprotocol) $name } 76 public proc setResultDir {name} { set _resources(-resultdir) $name } 77 public proc setCacheHosts {name} { set _resources(-cachehosts) $name } 77 78 78 79 # default method for -jobstats control … … 90 91 job_protocol Rappture::Task::setJobPrt \ 91 92 results_directory Rappture::Task::setResultDir \ 92 cache_host Rappture::Task::setCacheHost93 cache_hosts Rappture::Task::setCacheHosts 93 94 } 94 95 … … 110 111 } 111 112 set _installdir $installdir 113 package require http 114 package require tls 115 http::register https 443 [list ::tls::socket -tls1 1] 112 116 113 117 eval configure $args … … 216 220 # Initialize job array variables 217 221 array set _job { 218 control "" 219 mesg "" 220 runfile "" 221 stderr "" 222 stdout "" 223 success 0 224 xmlobj "" 222 control "" 223 exitcode 0 224 mesg "" 225 runfile "" 226 stderr "" 227 stdout "" 228 success 0 229 xmlobj "" 225 230 } 226 231 … … 457 462 458 463 itcl::body Rappture::Task::IsCacheable {} { 459 if { ![info exists _resources(-cachehost)] || 460 $_resources(-cachehost) == "" } { 464 if { ![info exists _resources(-cachehosts)] || 465 $_resources(-cachehosts) == "" } { 466 puts stderr cachehosts=[info exists _resources(-cachehosts)] 461 467 return 0 462 468 } 463 469 if 0 { 464 470 set state [$_xmlobj get "tool.cache"] 471 puts stderr "cache tag is \"$state\"" 465 472 if { $state == "" } { 466 473 return 0 … … 484 491 exec puq.sh get_params $pid $_uq(varlist) $_uq(type) $_uq(args) 485 492 } errs] != 0 } { 486 set contents {} 487 if { [file exists "uq_debug.err"] } { 488 set f [open "uq_debug.err" r] 489 set contents [read $f] 490 close $f 491 } 492 puts stderr "get_params.py failed: $contents" 493 error "get_params.py failed: $errs\n$contents" 494 } 495 return "params[pid].csv" 493 error "get_params.py failed: $errs\n[GetUQErrors]" 494 } 495 return "params${pid}.csv" 496 496 } 497 497 … … 589 589 set _job(runfile) "" 590 590 set _job(success) 0 591 set _job(exitcode) 0 591 592 592 593 # Step 1. Write the command into the run file. … … 601 602 set _job(stdout) [string range $cmd 5 end] 602 603 set _job(success) 1 604 set _job(exitcode) 0 603 605 set _job(mesg) "" 604 606 return 1; # Success … … 618 620 # Step 4. Check the token and the exit code. 619 621 set logmesg $result 620 foreach { token pid codemesg } $_job(control) break622 foreach { token _job(pid) _job(exitcode) mesg } $_job(control) break 621 623 if { $token == "EXITED" } { 622 if { $ code!= 0 } {624 if { $_job(exitcode) != 0 } { 623 625 # This means that the program exited normally but returned a 624 626 # non-zero exitcode. Consider this an invalid result from the 625 627 # program. Append the stderr from the program to the message. 626 628 if {$code > 128} { 627 set logmesg "Program signaled: signal was [GetSignal $ code]"629 set logmesg "Program signaled: signal was [GetSignal $_job(exitcode)]" 628 630 } else { 629 set logmesg "Program finished: non-zero exit code is $ code"631 set logmesg "Program finished: non-zero exit code is $_job(exitcode)" 630 632 } 631 633 set _job(mesg) "$logmesg\n\n$_job(stderr)" … … 684 686 "walltime" $times(walltime) \ 685 687 "cputime" $times(cputime) \ 686 "status" $_job( success)688 "status" $_job(exitcode) 687 689 uplevel #0 $jobstats $args 688 690 } … … 775 777 "walltime" $times(walltime) \ 776 778 "cputime" $times(cputime) \ 777 "status" $_job( success)779 "status" $_job(exitcode) 778 780 uplevel #0 $jobstats $args 779 781 } … … 860 862 861 863 # Read the driver file and collect its contents as the query. 862 set url http://$_resources(-cachehost )/cache/request864 set url http://$_resources(-cachehosts)/cache/request 863 865 set f [open $driverFile "r"] 864 866 set query [read $f] … … 867 869 # Make the query 868 870 if { [catch { 869 http::geturl $url -query $query -timeout 6000 0-binary yes871 http::geturl $url -query $query -timeout 6000 -binary yes 870 872 } token] != 0 } { 871 873 puts stderr "error performing cache query: token=$token" … … 896 898 set _job(stderr) "Loading cached results\n" 897 899 OnOutput "Loading cached results\n" 900 update 898 901 return 1 902 } 903 904 itcl::body Rappture::Task::GetUQErrors {} { 905 set contents {} 906 if { [file exists "uq_debug.err"] } { 907 set f [open "uq_debug.err" r] 908 set contents [read $f] 909 close $f 910 } 911 return $contents 899 912 } 900 913 … … 906 919 exec puq.sh analyze $hdfFile 907 920 } results] != 0 } { 908 set rdata {} 909 if { [file exists "uq_debug.err" ] } { 910 set f [open "uq_debug.err" r] 911 set rdata [read $f] 912 close $f 913 } 914 puts stderr "UQ analysis failed: $results\n$rdata" 915 error "UQ analysis failed: $results\n$rdata" 921 error "UQ analysis failed: $results\n[GetUQErrors]" 916 922 } else { 917 923 set _job(stdout) $results
Note: See TracChangeset
for help on using the changeset viewer.