Changeset 6131
- Timestamp:
- Mar 16, 2016 6:39:27 PM (8 years ago)
- Location:
- branches/1.6
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.6/configure
r6058 r6131 1 1 #! /bin/sh 2 2 # Guess values for system-dependent variables and create Makefiles. 3 # Generated by GNU Autoconf 2.69 for Rappture 1. 5.3 # Generated by GNU Autoconf 2.69 for Rappture 1.6. 4 4 # 5 5 # Report bugs to <rappture@nanohub.org>. … … 581 581 PACKAGE_NAME='Rappture' 582 582 PACKAGE_TARNAME='rappture' 583 PACKAGE_VERSION='1. 5'584 PACKAGE_STRING='Rappture 1. 5'583 PACKAGE_VERSION='1.6' 584 PACKAGE_STRING='Rappture 1.6' 585 585 PACKAGE_BUGREPORT='rappture@nanohub.org' 586 586 PACKAGE_URL='' … … 1395 1395 # This message is too long to be a string in the A/UX 3.1 sh. 1396 1396 cat <<_ACEOF 1397 \`configure' configures Rappture 1. 5to adapt to many kinds of systems.1397 \`configure' configures Rappture 1.6 to adapt to many kinds of systems. 1398 1398 1399 1399 Usage: $0 [OPTION]... [VAR=VALUE]... … … 1460 1460 if test -n "$ac_init_help"; then 1461 1461 case $ac_init_help in 1462 short | recursive ) echo "Configuration of Rappture 1. 5:";;1462 short | recursive ) echo "Configuration of Rappture 1.6:";; 1463 1463 esac 1464 1464 cat <<\_ACEOF … … 1580 1580 if $ac_init_version; then 1581 1581 cat <<\_ACEOF 1582 Rappture configure 1. 51582 Rappture configure 1.6 1583 1583 generated by GNU Autoconf 2.69 1584 1584 … … 2400 2400 running configure, to aid debugging if configure makes a mistake. 2401 2401 2402 It was created by Rappture $as_me 1. 5, which was2402 It was created by Rappture $as_me 1.6, which was 2403 2403 generated by GNU Autoconf 2.69. Invocation command line was 2404 2404 … … 10725 10725 # values after options handling. 10726 10726 ac_log=" 10727 This file was extended by Rappture $as_me 1. 5, which was10727 This file was extended by Rappture $as_me 1.6, which was 10728 10728 generated by GNU Autoconf 2.69. Invocation command line was 10729 10729 … … 10787 10787 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" 10788 10788 ac_cs_version="\\ 10789 Rappture config.status 1. 510789 Rappture config.status 1.6 10790 10790 configured by $0, generated by GNU Autoconf 2.69, 10791 10791 with options \\"\$ac_cs_config\\" -
branches/1.6/configure.in
r6058 r6131 1 1 2 AC_INIT([Rappture],[1. 5],[rappture@nanohub.org])2 AC_INIT([Rappture],[1.6],[rappture@nanohub.org]) 3 3 AC_CONFIG_AUX_DIR(cf) 4 4 AC_CONFIG_HEADER(src/core/config.h) -
branches/1.6/examples/zoo/string/string.tcl
r3177 r6131 20 20 $driver put output.string(outi).about.label "Echo of input" 21 21 $driver put output.string(outi).current $indeck 22 puts stderr "This is an error message." 23 exit 10 22 24 23 25 # save the updated XML describing the run... 24 26 Rappture::result $driver 25 exit 0 -
branches/1.6/examples/zoo/string/tool.xml
r5788 r6131 11 11 </about> 12 12 <command> 13 python @tool/string_test.py@driver13 tclsh @tool/string.tcl @driver 14 14 </command> 15 15 </tool> -
branches/1.6/gui/configure
r6127 r6131 1 1 #! /bin/sh 2 2 # Guess values for system-dependent variables and create Makefiles. 3 # Generated by GNU Autoconf 2.69 for RapptureGUI 1. 5.3 # Generated by GNU Autoconf 2.69 for RapptureGUI 1.6. 4 4 # 5 5 # Report bugs to <rappture@nanohub.org>. … … 580 580 PACKAGE_NAME='RapptureGUI' 581 581 PACKAGE_TARNAME='rappturegui' 582 PACKAGE_VERSION='1. 5'583 PACKAGE_STRING='RapptureGUI 1. 5'582 PACKAGE_VERSION='1.6' 583 PACKAGE_STRING='RapptureGUI 1.6' 584 584 PACKAGE_BUGREPORT='rappture@nanohub.org' 585 585 PACKAGE_URL='' … … 1226 1226 # This message is too long to be a string in the A/UX 3.1 sh. 1227 1227 cat <<_ACEOF 1228 \`configure' configures RapptureGUI 1. 5to adapt to many kinds of systems.1228 \`configure' configures RapptureGUI 1.6 to adapt to many kinds of systems. 1229 1229 1230 1230 Usage: $0 [OPTION]... [VAR=VALUE]... … … 1292 1292 if test -n "$ac_init_help"; then 1293 1293 case $ac_init_help in 1294 short | recursive ) echo "Configuration of RapptureGUI 1. 5:";;1294 short | recursive ) echo "Configuration of RapptureGUI 1.6:";; 1295 1295 esac 1296 1296 cat <<\_ACEOF … … 1383 1383 if $ac_init_version; then 1384 1384 cat <<\_ACEOF 1385 RapptureGUI configure 1. 51385 RapptureGUI configure 1.6 1386 1386 generated by GNU Autoconf 2.69 1387 1387 … … 1438 1438 running configure, to aid debugging if configure makes a mistake. 1439 1439 1440 It was created by RapptureGUI $as_me 1. 5, which was1440 It was created by RapptureGUI $as_me 1.6, which was 1441 1441 generated by GNU Autoconf 2.69. Invocation command line was 1442 1442 … … 3697 3697 # values after options handling. 3698 3698 ac_log=" 3699 This file was extended by RapptureGUI $as_me 1. 5, which was3699 This file was extended by RapptureGUI $as_me 1.6, which was 3700 3700 generated by GNU Autoconf 2.69. Invocation command line was 3701 3701 … … 3750 3750 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" 3751 3751 ac_cs_version="\\ 3752 RapptureGUI config.status 1. 53752 RapptureGUI config.status 1.6 3753 3753 configured by $0, generated by GNU Autoconf 2.69, 3754 3754 with options \\"\$ac_cs_config\\" -
branches/1.6/gui/configure.in
r6127 r6131 1 1 2 AC_INIT([RapptureGUI],[1. 5],[rappture@nanohub.org])2 AC_INIT([RapptureGUI],[1.6],[rappture@nanohub.org]) 3 3 AC_CONFIG_AUX_DIR(cf) 4 4 #------------------------------------------------------------------------ -
branches/1.6/gui/scripts/bugreport.tcl
r5679 r6131 607 607 return 0 608 608 } 609 609 set url [Rappture::Tool::resources -huburl] 610 if { $url == "" } { 611 return 0 612 } 610 613 # if this is a problem launching a job and the tool 611 614 # expects this, then don't bother with automatic reports. -
branches/1.6/lang/tcl/scripts/task.tcl
r6113 r6131 19 19 20 20 itcl::class Rappture::Task { 21 private method CheckCacheForRunFile { driverFile } 22 private method CollectUQResults {} 23 private method ExecuteSimulationCommand { cmd } 24 private method GetCommand {} 25 private method GetDriverFile {} 26 private method GetSignal { signal } 27 private method GetSimulationCommand { driverFile } 28 private method GetUQSimulationCommand { driverFile } 29 private method GetUQTemplateFile {} 30 private method IsCacheable {} 31 private method LogCachedSimulationUsage {} 32 private method LogSimulationUsage {} 33 private method SetCpuResourceLimit {} 34 21 35 public variable logger "" 22 36 public variable jobstats Rappture::Task::MiddlewareTime … … 35 49 public method save {xmlobj {name ""}} 36 50 37 protected method _mkdir {dir}38 51 protected method _output {data} 39 protected method _log {args} 40 protected method _build_submit_cmd {cmd tfile params_file} 41 protected method _get_params {varlist uq_type uq_args} 42 private method GetSignal { signal } 52 protected method Log {args} 53 protected method BuildSubmitCommand {cmd tfile params_file} 54 protected method GetParamsForUQ {} 43 55 44 56 private variable _xmlobj "" ;# XML object with inputs/outputs 45 57 private variable _origxml "" ;# copy of original XML (for reset) 46 private variable _lastrun "" ;# name of last run file47 58 private variable _installdir "" ;# installation directory for this tool 48 59 private variable _outputcb "" ;# callback for tool output 49 private common job ;# array var used for blt::bgexec jobs50 60 private common jobnum 0 ;# counter for unique job number 51 61 private variable _uq 62 63 private variable _job 64 52 65 # get global resources for this tool session 53 66 public proc resources {{option ""}} … … 60 73 public proc setJobPrt {name} { set _resources(-jobprotocol) $name } 61 74 public proc setResultDir {name} { set _resources(-resultdir) $name } 75 public proc setCacheHost {name} { set _resources(-cachehost) $name } 62 76 63 77 # default method for -jobstats control … … 74 88 session_token Rappture::Task::setSession \ 75 89 job_protocol Rappture::Task::setJobPrt \ 76 results_directory Rappture::Task::setResultDir 90 results_directory Rappture::Task::setResultDir \ 91 cache_host Rappture::Task::setCacheHost 77 92 } 78 93 … … 122 137 itcl::body Rappture::Task::GetSignal {code} { 123 138 set signals { 124 HUP INT QUIT ILL TRAP ABRT BUS FPE KILL USR1 SEGV 125 USR2 PIPE ALRM TERM STKFLT CHLD CONT STOP TSTP TTIN 126 TTOU URG XCPU XFSZ VTALRM PROF WINCH POLL PWR SYS 127 139 HUP INT QUIT ILL TRAP ABRT BUS FPE KILL USR1 SEGV 140 USR2 PIPE ALRM TERM STKFLT CHLD CONT STOP TSTP TTIN 141 TTOU URG XCPU XFSZ VTALRM PROF WINCH POLL PWR SYS 142 RTMIN RTMIN+1 RTMIN+2 RTMIN+3 RTMAX-3 RTMAX-2 RTMAX-1 RTMAX 128 143 } 129 144 set sigNum [expr $code - 128] 130 145 if { $sigNum > 0 && $sigNum < [llength $signals] } { 131 146 return [lindex $signals $sigNum] 132 147 } 133 148 return "unknown exit code \"$code\"" … … 137 152 foreach {path val} $args { 138 153 if {$path == "-uq_type"} { 139 set uq_type$val154 set _uq(type) $val 140 155 } elseif {$path == "-uq_args"} { 141 set uq_args$val156 set _uq(args) $val 142 157 } 143 158 } 144 159 #set varlist [$_xmlobj uq_get_vars] 145 160 foreach {varlist num} [$_xmlobj uq_get_vars] break 146 return [Rappture::UQ ::#auto $varlist $num $ uq_type $uq_args]161 return [Rappture::UQ ::#auto $varlist $num $_uq(type) $_uq(args)] 147 162 } 148 163 … … 173 188 174 189 # 175 # Make sure that we save the proper application name. 176 # Actually, the best place to get this information is 177 # straight from the "installtool" script, but just in 178 # case we have an older tool, we should insert the 190 # Make sure that we save the proper application name. Actually, the 191 # best place to get this information is straight from the "installtool" 192 # script, but just in case we have an older tool, we should insert the 179 193 # tool name from the resources config file. 180 194 # 181 if {[info exists _resources(-appname)] 182 && $_resources(-appname) ne "" 183 && [$_xmlobj get tool.name] eq ""} { 195 if {[info exists _resources(-appname)] && $_resources(-appname) ne "" && 196 [$_xmlobj get tool.name] eq ""} { 184 197 $_xmlobj put tool.name $_resources(-appname) 185 198 } … … 187 200 # if there are any args, use them to override parameters 188 201 set _outputcb "" 189 set uq_type""202 set _uq(type) "" 190 203 foreach {path val} $args { 191 204 if {$path == "-output"} { 192 205 set _outputcb $val 193 206 } elseif {$path == "-uq_type"} { 194 set uq_type$val207 set _uq(type) $val 195 208 } elseif {$path == "-uq_args"} { 196 set uq_args$val209 set _uq(args) $val 197 210 } else { 198 211 $_xmlobj put $path.current $val … … 200 213 } 201 214 202 foreach item {control output error} { set job($item) "" } 203 215 # Initialize job array variables 216 array set _job { 217 control "" 218 mesg "" 219 runfile "" 220 stderr "" 221 stdout "" 222 success 0 223 xmlobj "" 224 } 225 226 SetCpuResourceLimit 227 set driverFile [GetDriverFile] 228 set cached 0 229 if { [IsCacheable] } { 230 set cached [CheckForCachedRunFile $driverFile] 231 } 232 if { !$cached } { 233 if { $_uq(type) != "" } { 234 set _uq(tfile) [GetUQTemplateFile] 235 } 236 if { $_uq(type) == "" } { 237 set cmd [GetSimulationCommand $driverFile] 238 } else { 239 set cmd [GetUQSimulationCommand $driverFile] 240 } 241 if { $cmd == "" } { 242 puts stderr "cmd is empty" 243 append mesg "There is no command specified by\n\n" 244 append mesg " <command>\n" 245 append mesg " </command>\n\n" 246 append mesg "in the tool.xml file." 247 return [list 1 $mesg] 248 } 249 Rappture::rusage mark 250 if { ![ExecuteSimulationCommand $cmd] } { 251 return [list 1 $_job(mesg)] 252 } 253 if { $_uq(type) != "" } { 254 CollectUQResults 255 } 256 if { [resources -jobprotocol] != "submit" } { 257 LogSimulationUsage 258 } 259 } else { 260 LogCachedSimulationUsage 261 } 262 if { $_job(success) } { 263 file delete -force -- $driverFile 264 Log run finished 265 return [list 0 $_job(xmlobj)] 266 } else { 267 # See if the job was aborted. 268 if {[regexp {^KILLED} $_job(control)]} { 269 Log run aborted 270 return [list 1 "ABORT"] 271 } 272 Log run failed [list 0 $_job(mesg)] 273 return [list 1 $_job(mesg)] 274 } 275 } 276 277 # ---------------------------------------------------------------------- 278 # Turn the command string from tool.xml into the proper syntax to use 279 # with a submit parameter sweep with a temlate file. Proper quoting 280 # of the template file is necessary to prevent submit from being too smart 281 # and converting it to a full pathname. 282 # ---------------------------------------------------------------------- 283 itcl::body Rappture::Task::BuildSubmitCommand {cmd tfile params_file} { 284 set quote_next 0 285 set newcmd "submit --progress submit --runName=puq -l -i @:$tfile -d $params_file" 286 set cmds [split $cmd " "] 287 for {set i 0} {$i < [llength $cmds]} {incr i} { 288 set arg [lindex $cmds $i] 289 if {$quote_next == 1} { 290 set nc [string range $arg 0 0] 291 if {$nc != "\""} { 292 set arg "\"\\\"$arg\\\"\"" 293 } 294 } 295 if {$arg == "--eval"} { 296 set quote_next 1 297 } else { 298 set quote_next 0 299 } 300 if {$arg == "@driver"} { 301 set arg "\"\\\"$tfile\\\"\"" 302 } 303 append newcmd " " $arg 304 } 305 regsub -all @driver $newcmd $tfile newcmd 306 return $newcmd 307 } 308 309 # ---------------------------------------------------------------------- 310 # USAGE: abort 311 # 312 # Clients use this during a "run" to abort the current job. 313 # Kills the job and forces the "run" method to return. 314 # ---------------------------------------------------------------------- 315 itcl::body Rappture::Task::abort {} { 316 Log run abort 317 set _job(control) "abort" 318 } 319 320 # ---------------------------------------------------------------------- 321 # USAGE: reset 322 # 323 # Resets all input values to their defaults. Sometimes used just 324 # before a run to reset to a clean state. 325 # ---------------------------------------------------------------------- 326 itcl::body Rappture::Task::reset {} { 327 $_xmlobj copy "" from $_origxml "" 328 foreach path [Rappture::entities -as path $_xmlobj input] { 329 if {[$_xmlobj element -as type $path.default] ne ""} { 330 set defval [$_xmlobj get $path.default] 331 $_xmlobj put $path.current $defval 332 } 333 } 334 } 335 336 # ---------------------------------------------------------------------- 337 # USAGE: xml <subcommand> ?<arg> <arg> ...? 338 # USAGE: xml object 339 # 340 # Used by clients to manipulate the underlying XML data for this 341 # tool. The <subcommand> can be any operation supported by a 342 # Rappture::library object. Clients can also request the XML object 343 # directly by using the "object" subcommand. 344 # ---------------------------------------------------------------------- 345 itcl::body Rappture::Task::xml {args} { 346 if {"object" == $args} { 347 return $_xmlobj 348 } 349 return [eval $_xmlobj $args] 350 } 351 352 # ---------------------------------------------------------------------- 353 # USAGE: save <xmlobj> ?<filename>? 354 # 355 # Used by clients to save the contents of an <xmlobj> representing 356 # a run out to the given file. If <filename> is not specified, then 357 # it uses the -resultsdir and other settings to do what Rappture 358 # would normally do with the output. 359 # ---------------------------------------------------------------------- 360 itcl::body Rappture::Task::save {xmlobj {filename ""}} { 361 if {$filename eq ""} { 362 363 # If there's a results_directory defined in the resources file, 364 # then move the run.xml file there for storage. 365 366 set rdir "" 367 if {$resultdir eq "@default"} { 368 if {[info exists _resources(-resultdir)]} { 369 set rdir $_resources(-resultdir) 370 } else { 371 global rapptureInfo 372 set rdir $rapptureInfo(cwd) 373 } 374 } elseif {$resultdir ne ""} { 375 set rdir $resultdir 376 } 377 378 # use the runfile name generated by the last run 379 if {$_job(runfile) ne ""} { 380 set filename [file join $rdir $_job(runfile)] 381 } else { 382 set filename [file join $rdir run.xml] 383 } 384 } 385 386 # add any last-minute metadata 387 $xmlobj put output.time [clock format [clock seconds]] 388 389 $xmlobj put tool.version.rappture.version $::Rappture::version 390 $xmlobj put tool.version.rappture.revision $::Rappture::build 391 $xmlobj put output.filename $filename 392 $xmlobj put output.version $Rappture::version 393 394 if {[info exists ::tcl_platform(user)]} { 395 $xmlobj put output.user $::tcl_platform(user) 396 } 397 398 # save the output 399 set rdir [file dirname $filename] 400 file mkdir $rdir 401 402 set fid [open $filename w] 403 puts $fid "<?xml version=\"1.0\"?>" 404 puts $fid [$xmlobj xml] 405 close $fid 406 407 Log output saved in $filename 408 } 409 410 # ---------------------------------------------------------------------- 411 # USAGE: _output <data> 412 # 413 # Used internally to send each bit of output <data> coming from the 414 # tool onto the caller, so the user can see progress. 415 # ---------------------------------------------------------------------- 416 itcl::body Rappture::Task::_output {data} { 417 if {[string length $_outputcb] > 0} { 418 uplevel #0 $_outputcb [list $data] 419 } 420 } 421 422 # ---------------------------------------------------------------------- 423 # USAGE: Log <cmd> <arg> <arg> ... 424 # 425 # Used internally to log interesting events during the run. If the 426 # -logger option is set (to Rappture::Logger::log, or something like 427 # that), then the arguments to this method are passed along to the 428 # logger and written out to a log file. Logging is off by default, 429 # so this method does nothing unless -logger is set. 430 # ---------------------------------------------------------------------- 431 itcl::body Rappture::Task::Log {args} { 432 if {[string length $logger] > 0} { 433 uplevel #0 $logger [list $args] 434 } 435 } 436 437 # ---------------------------------------------------------------------- 438 # USAGE: MiddlewareTime <key> <value> ... 439 # 440 # Used as the default method for reporting job status information. 441 # Implements the old HUBzero method of reporting job status info to 442 # stderr, which can then be picked up by the tool session container. 443 # Most tools use the "submit" command, which talks directly to a 444 # database to log job information, so this isn't really needed. But 445 # it doesn't hurt to have this and it can be useful in some cases. 446 # ---------------------------------------------------------------------- 447 itcl::body Rappture::Task::MiddlewareTime {args} { 448 set line "MiddlewareTime:" 449 foreach {key val} $args { 450 append line " $key=$val" 451 } 452 puts stderr $line 453 } 454 455 itcl::body Rappture::Task::IsCacheable {} { 456 if { ![info exists _resources(-cachehost)] || 457 $_resources(-cachehost) == "" } { 458 return 0 459 } 460 set state [$_xmlobj get "tool.cached"] 461 if { $state == "" } { 462 return 0 463 } 464 if { ![string is boolean $state] } { 465 return 0 466 } 467 return $state 468 } 469 470 # 471 # Send the list of parameters to a python program so it can call PUQ 472 # and get a CSV file containing the parameter values to use for the runs. 473 itcl::body Rappture::Task::GetParamsForUQ {} { 474 set pid [pid] 475 # puts "get_params.py $pid $_uq(varlist) $_uq(type) $_uq(args)" 476 if {[catch { 477 exec puq get_params $pid $_uq(varlist) $_uq(type) $_uq(args) 478 } errs] != 0 } { 479 set fp [open "uq_debug.err" r] 480 set contents [read $fp] 481 close $fp 482 puts stderr "get_params.py failed: $contents" 483 error "get_params.py: $errs\n$contents" 484 } 485 return "params[pid].csv" 486 } 487 488 itcl::body Rappture::Task::SetCpuResourceLimit {} { 204 489 # Set limits for cpu time 205 490 set limit [$_xmlobj get tool.limits.cputime] … … 216 501 } 217 502 Rappture::rlimit set cputime $limit 218 219 # write out the driver.xml file for the tool 503 } 504 505 # Write out the driver.xml file for the tool 506 itcl::body Rappture::Task::GetDriverFile {} { 220 507 global rapptureInfo 221 set file [file join $rapptureInfo(cwd) "driver[pid].xml"] 222 set status [catch { 223 set fid [open $file w] 224 puts $fid "<?xml version=\"1.0\"?>" 225 puts $fid [$_xmlobj xml] 226 close $fid 227 } result] 228 229 if {$uq_type != ""} { 230 # Copy xml into a new file 231 set tfile "template[pid].xml" 232 set fid [open $tfile w] 233 puts $fid "<?xml version=\"1.0\"?>" 234 puts $fid [$_xmlobj xml] 235 close $fid 236 237 # Return a list of the UQ variables and their PDFs. 238 # Also turns $tfile into a template file. 239 set uq_varlist [lindex [$_xmlobj uq_get_vars $tfile] 0] 240 } 241 242 243 # execute the tool using the path from the tool description 244 if {$status == 0} { 245 set cmd [$_xmlobj get tool.command] 246 regsub -all @tool $cmd $_installdir cmd 247 set cmd [string trimleft $cmd " "] 248 249 if { $cmd == "" } { 250 puts stderr "cmd is empty" 251 return [list 1 "Command is empty.\n\nThere is no command specified by\n\n <command>\n </command>\n\nin the tool.xml file."] 252 } 253 254 if {$uq_type == ""} { 255 regsub -all @driver $cmd $file cmd 256 257 switch -glob -- [resources -jobprotocol] { 258 "submit*" { 259 # if job_protocol is "submit", then use use submit command 260 set cmd "submit --local $cmd" 261 } 262 "mx" { 263 # metachory submission 264 set cmd "mx $cmd" 265 } 266 "exec" { 267 # default -- nothing special 268 } 508 set fileName [file join $rapptureInfo(cwd) "driver[pid].xml"] 509 if { [catch { 510 set f [open $fileName w] 511 puts $f "<?xml version=\"1.0\"?>" 512 puts $f [$_xmlobj xml] 513 close $f 514 } errs] != 0 } { 515 error "can't create driver file \"$fileName\": $errs" 516 } 517 return $fileName 518 } 519 520 itcl::body Rappture::Task::GetCommand { } { 521 set cmd [$_xmlobj get tool.command] 522 regsub -all @tool $cmd $_installdir cmd 523 set cmd [string trimleft $cmd " "] 524 return $cmd 525 } 526 527 itcl::body Rappture::Task::GetSimulationCommand { driverFile } { 528 set cmd [GetCommand] 529 if { $cmd == "" } { 530 return "" 531 } 532 regsub -all @driver $cmd $driverFile cmd 533 534 switch -glob -- [resources -jobprotocol] { 535 "submit*" { 536 # if job_protocol is "submit", then use use submit command 537 set cmd "submit --local $cmd" 538 } 539 "mx" { 540 # metachory submission 541 set cmd "mx $cmd" 542 } 543 "exec" { 544 # default -- nothing special 545 } 546 } 547 return $cmd 548 } 549 550 itcl::body Rappture::Task::GetUQSimulationCommand { driverFile } { 551 set cmd [GetCommand] 552 if { $cmd == "" } { 553 return "" 554 } 555 set paramsFile [GetParamsForUQ] 556 set cmd [BuildSubmitCommand $cmd $_uq(tfile) $paramsFile] 557 file delete -force puq 558 return $cmd 559 } 560 561 itcl::body Rappture::Task::GetUQTemplateFile {} { 562 global rapptureInfo 563 # Copy xml into a new file 564 set templateFile [file join $rapptureInfo(cwd) "template[pid].xml"] 565 set fid [open $templateFile w] 566 puts $fid "<?xml version=\"1.0\"?>" 567 puts $fid [$_xmlobj xml] 568 close $fid 569 570 # Return a list of the UQ variables and their PDFs. 571 # Also turns $uq(tfile) into a template file. 572 set _uq(varlist) [lindex [$_xmlobj uq_get_vars $templateFile] 0] 573 set _uq(tfile) $templateFile 574 return $templateFile 575 } 576 577 itcl::body Rappture::Task::ExecuteSimulationCommand { cmd } { 578 579 set _job(runfile) "" 580 set _job(success) 0 581 582 # Step 1. Write the command into the run file. 583 $_xmlobj put tool.execute $cmd 584 585 Log run started 586 Rappture::rusage mark 587 588 # Step 2. Check if it is a special case "ECHO" command which always 589 # succeeds. 590 if { [string compare -nocase -length 5 $cmd "ECHO "] == 0 } { 591 set _job(stdout) [string range $cmd 5 end] 592 set _job(success) 1 593 set _job(mesg) "" 594 return 1; # Success 595 } 596 597 # Step 3. Execute the command, collecting its stdout and stderr. 598 catch { 599 eval blt::bgexec [list [itcl::scope _job(control)]] \ 600 -keepnewline yes \ 601 -killsignal SIGTERM \ 602 -onoutput [list [itcl::code $this _output]] \ 603 -output [list [itcl::scope _job(stdout)]] \ 604 -error [list [itcl::scope _job(stderr)]] \ 605 $cmd 606 } result 607 608 # Step 4. Check the token and the exit code. 609 set logmesg $result 610 foreach { token pid code mesg } $_job(control) break 611 if { $token == "EXITED" } { 612 if { $code != 0 } { 613 # This means that the program exited normally but returned a 614 # non-zero exitcode. Consider this an invalid result from the 615 # program. Append the stderr from the program to the message. 616 617 if {$code > 128} { 618 set logmesg "Program signaled: signal was [GetSignal]" 619 } else { 620 set logmesg "Program finished: non-zero exit code is $code" 269 621 } 270 } else { 271 set params_file [_get_params $uq_varlist $uq_type $uq_args] 272 set cmd [_build_submit_cmd $cmd $tfile $params_file] 273 file delete -force puq 274 } 275 276 $_xmlobj put tool.execute $cmd 277 278 # starting job... 279 set _lastrun "" 280 _log run started 281 Rappture::rusage mark 282 283 if {0 == [string compare -nocase -length 5 $cmd "ECHO "] } { 284 set status 0; 285 set job(output) [string range $cmd 5 end] 286 } else { 287 set status [catch { 288 set ::Rappture::Task::job(control) "" 289 eval blt::bgexec \ 290 ::Rappture::Task::job(control) \ 291 -keepnewline yes \ 292 -killsignal SIGTERM \ 293 -onoutput [list [itcl::code $this _output]] \ 294 -output ::Rappture::Task::job(output) \ 295 -error ::Rappture::Task::job(error) \ 296 $cmd 297 } result] 298 299 if { $status != 0 } { 300 # We're here because the exec-ed program failed 301 set logmesg $result 302 if { $::Rappture::Task::job(control) ne "" } { 303 foreach { token pid code mesg } \ 304 $::Rappture::Task::job(control) break 305 if { $token == "EXITED" } { 306 # This means that the program exited normally but 307 # returned a non-zero exitcode. Consider this an 308 # invalid result from the program. Append the stderr 309 # from the program to the message. 310 if {$code > 128} { 311 set logmesg "Program signaled: signal was [GetSignal $code]" 312 } else { 313 set logmesg "Program finished: exit code is $code" 314 } 315 set result "$logmesg\n\n$::Rappture::Task::job(error)" 316 } elseif { $token == "abort" } { 317 # The user pressed the abort button. 318 set logmesg "Program terminated by user." 319 set result "$logmesg\n\n$::Rappture::Task::job(output)" 320 } else { 321 # Abnormal termination 322 set logmesg "Abnormal program termination: $mesg" 323 set result "$logmesg\n\n$::Rappture::Task::job(output)" 324 } 325 } 326 _log run failed [list $logmesg] 327 return [list $status $result] 328 } 329 } 330 # ...job is finished 331 array set times [Rappture::rusage measure] 332 333 if {[resources -jobprotocol] ne "submit"} { 334 set id [$_xmlobj get tool.id] 335 set vers [$_xmlobj get tool.version.application.revision] 336 set simulation simulation 337 if { $id ne "" && $vers ne "" } { 338 set pid [pid] 339 set simulation ${pid}_${id}_r${vers} 340 } 341 342 # need to save job info? then invoke the callback 343 if {[string length $jobstats] > 0} { 344 uplevel #0 $jobstats [list job [incr jobnum] \ 345 event $simulation start $times(start) \ 346 walltime $times(walltime) cputime $times(cputime) \ 347 status $status] 348 } 349 350 # 351 # Scan through stderr channel and look for statements that 352 # represent grid jobs that were executed. The statements 353 # look like this: 354 # 355 # MiddlewareTime: job=1 event=simulation start=3.001094 ... 356 # 357 set subjobs 0 358 while {[regexp -indices {(^|\n)MiddlewareTime:( +[a-z]+=[^ \n]+)+(\n|$)} $job(error) match]} { 359 foreach {p0 p1} $match break 360 if {[string index $job(error) $p0] == "\n"} { incr p0 } 361 362 catch {unset data} 363 array set data { 364 job 1 365 event simulation 366 start 0 367 walltime 0 368 cputime 0 369 status 0 370 } 371 foreach arg [lrange [string range $job(error) $p0 $p1] 1 end] { 372 foreach {key val} [split $arg =] break 373 set data($key) $val 374 } 375 set data(job) [expr {$jobnum+$data(job)}] 376 set data(event) "subsimulation" 377 set data(start) [expr {$times(start)+$data(start)}] 378 379 set details "" 380 foreach key {job event start walltime cputime status} { 381 # add required keys in a particular order 382 lappend details $key $data($key) 383 unset data($key) 384 } 385 foreach key [array names data] { 386 # add anything else that the client gave -- venue, etc. 387 lappend details $key $data($key) 388 } 389 390 if {[string length $jobstats] > 0} { 391 uplevel #0 $jobstats $details 392 } 393 394 incr subjobs 395 396 # done -- remove this statement 397 set job(error) [string replace $job(error) $p0 $p1] 398 } 399 incr jobnum $subjobs 400 } 401 622 set _job(mesg) "$logmesg\n\n$_job(stderr)" 623 Log run failed [list $logmesg] 624 return 0; # Fail. 625 } 626 # Successful program termination with exit code of 0. 627 } elseif { $token == "abort" } { 628 # The user pressed the abort button. 629 630 set logmesg "Program terminated by user." 631 Log run failed [list $logmesg] 632 set _job(mesg) "$logmesg\n\n$_job(stdout)" 633 return 0; # Fail 402 634 } else { 403 set job(error) "$result\n$errorInfo" 404 } 405 if {$status == 0} { 406 # file delete -force -- $file 407 } 408 409 # see if the job was aborted 410 if {[regexp {^KILLED} $job(control)]} { 411 _log run aborted 412 return [list 0 "ABORT"] 413 } 414 635 # Abnormal termination 636 637 set logmesg "Abnormal program termination:" 638 Log run failed [list $logmesg] 639 set _job(mesg) "$logmesg\n\n$_job(stdout)" 640 return 0; # Fail 641 } 642 643 # Step 5. Look in stdout for the name of the run file. 644 set pattern {=RAPPTURE-RUN=>([^\n]+)} 645 if {![regexp $pattern $_job(stdout) match fileName]} { 646 set _job(mesg) "Can't find result file in output.\n" 647 append _job(mesg) "Did you call Rappture::result in your simulator?" 648 return 0; # Fail 649 } 650 set _job(runfile) $fileName 651 set _job(success) 1 652 set _job(mesg) $_job(stdout) 653 return 1; # Success 654 } 655 656 itcl::body Rappture::Task::LogSimulationUsage {} { 657 array set times [Rappture::rusage measure] 658 659 set toolId [$_xmlobj get tool.id] 660 set toolVers [$_xmlobj get tool.version.application.revision] 661 set simulation "simulation" 662 if { $toolId ne "" && $toolVers ne "" } { 663 set simulation "[pid]_${toolId}_r${toolVers}" 664 } 665 666 # Need to save job info? then invoke the callback 667 if { [string length $jobstats] > 0} { 668 lappend args \ 669 "job" [incr jobnum] \ 670 "event" $simulation \ 671 "start" $times(start) \ 672 "walltime" $times(walltime) \ 673 "cputime" $times(cputime) \ 674 "status" $_job(success) 675 uplevel #0 $jobstats $args 676 } 677 415 678 # 416 # If successful, return the output, which should include 417 # a reference to the run.xml file containing results. 679 # Scan through stderr channel and look for statements that 680 # represent grid jobs that were executed. The statements look 681 # like this: 418 682 # 419 420 if {$status == 0} { 421 set result [string trim $job(output)] 422 423 if {$uq_type != ""} { 424 # UQ. Collect data from all jobs and put it in one xml run file. 425 file delete -force -- run_uq.xml 426 if {[catch {exec puq analyze puq_[pid].hdf5} res]} { 427 set fp [open "uq_debug.err" r] 428 set rdata [read $fp] 429 close $fp 430 puts "PUQ analysis failed: $res\n$rdata" 431 error "UQ analysis failed: $res\n$rdata" 432 } else { 433 append result "\n" $res 434 } 435 } 436 if {[regexp {=RAPPTURE-RUN=>([^\n]+)} $result match file]} { 437 set _lastrun $file 438 439 set status [catch {Rappture::library $file} result] 440 if {$status == 0} { 441 # add cputime info to run.xml file 442 $result put output.walltime $times(walltime) 443 $result put output.cputime $times(cputime) 444 if {[info exists env(SESSION)]} { 445 $result put output.session $env(SESSION) 446 } 447 } else { 448 global errorInfo 449 set result "$result\n$errorInfo" 450 } 451 452 file delete -force -- $file 453 } else { 454 set status 1 455 set result "Can't find result file in output.\nDid you call Rappture 456 ::result in your simulator?" 457 } 458 } elseif {$job(output) ne "" || $job(error) ne ""} { 459 set result [string trim "$job(output)\n$job(error)"] 460 } 461 462 # log final status for the run 463 if {$status == 0} { 464 _log run finished 683 # MiddlewareTime: job=1 event=simulation start=3.001094 ... 684 # 685 686 set subjobs 0 687 set pattern {(^|\n)MiddlewareTime:( +[a-z]+=[^ \n]+)+(\n|$)} 688 while { [regexp -indices $pattern $_job(stderr) match] } { 689 foreach {p0 p1} $match break 690 if { [string index $_job(stderr) $p0] == "\n" } { 691 incr p0 692 } 693 array unset data 694 array set data { 695 job 1 696 event simulation 697 start 0 698 walltime 0 699 cputime 0 700 status 0 701 } 702 foreach arg [lrange [string range $_job(stderr) $p0 $p1] 1 end] { 703 foreach {key val} [split $arg =] break 704 set data($key) $val 705 } 706 set data(job) [expr { $jobnum + $data(job) }] 707 set data(event) "subsimulation" 708 set data(start) [expr { $times(start) + $data(start) }] 709 710 set details "" 711 foreach key {job event start walltime cputime status} { 712 # Add required keys in a particular order 713 lappend details $key $data($key) 714 unset data($key) 715 } 716 foreach key [array names data] { 717 # Add anything else that the client gave -- venue, etc. 718 lappend details $key $data($key) 719 } 720 721 if {[string length $jobstats] > 0} { 722 uplevel #0 $jobstats $details 723 } 724 725 incr subjobs 726 727 # Done -- remove this statement 728 set _job(stderr) [string replace $_job(stderr) $p0 $p1] 729 } 730 incr jobnum $subjobs 731 732 # Add cputime info to run.xml file 733 if { [catch { 734 Rappture::library $_job(runfile) 735 } xmlobj] != 0 } { 736 error "Can't create rappture library: $xmlobj" 737 } 738 $xmlobj put output.walltime $times(walltime) 739 $xmlobj put output.cputime $times(cputime) 740 global env 741 if {[info exists env(SESSION)]} { 742 $xmlobj put output.session $env(SESSION) 743 } 744 set _job(xmlobj) $xmlobj 745 } 746 747 itcl::body Rappture::Task::LogCachedSimulationUsage {} { 748 if { [catch { 749 Rappture::library $_job(runfile) 750 } xmlobj] != 0 } { 751 error "Can't create rappture library: $xmlobj" 752 } 753 # Get the session from runfile 754 set session [$xmlobj get "tool.session"] 755 catch exec {submit --cache $session} result 756 set _job(xmlobj) $xmlobj 757 } 758 759 760 itcl::body Rappture::Task::CheckCacheForRunFile { driverFile } { 761 762 # Read the driver file and collect its contents as the query. 763 set url http://$_resources(-cachehost)/cache/request 764 set f [open $driverFile "r"] 765 set query [read $f] 766 close $f 767 768 # Make the query 769 if { [catch { 770 http::geturl $url -query $query -timeout 60000 -binary yes 771 } token] != 0 } { 772 puts stderr "can't get query: token=$token" 773 return 0 774 } 775 # If the code isn't 200, we'll assume it's a cache miss. 776 if { [http::ncode $token] != 200} { 777 return 0 778 } 779 # Get contents of the run file. 780 set contents [http::data $token] 781 if { $contents == "" } { 782 return 0 783 } 784 # Create a new run.xml file and write the results into it. 785 set secs [clock seconds] 786 set millisecs [expr [clock clicks -milliseconds] % 1000] 787 set timestamp [format %d%03d%03d $secs $millisecs 0] 788 789 global rapptureInfo 790 set fileName [file join $rapptureInfo(cwd) "run${timestamp}.xml"] 791 set f [open $fileName "w"] 792 puts $f $contents 793 close $f 794 set _job(runfile) $fileName 795 return 1 796 } 797 798 # UQ. Collect data from all jobs and put it in one xml run file. 799 itcl::body Rappture::Task::CollectUQResults {} { 800 file delete -force -- "run_uq.xml" 801 global rapptureInfo 802 set puqFileName [file join $rapptureInfo(cwd) puq_[pid].hdf5] 803 if {[catch { 804 exec puq analyze $puqFileName 805 } fileName] != 0 } { 806 set f [open "uq_debug.err" r] 807 set rdata [read $f] 808 close $f 809 puts "PUQ analysis failed: $fileName\n$rdata" 810 error "UQ analysis failed: $fileName\n$rdata" 465 811 } else { 466 _log run failed [list $result] 467 } 468 469 return [list $status $result] 470 } 471 472 # ---------------------------------------------------------------------- 473 # Turn the command string from tool.xml into the proper syntax to use 474 # with a submit parameter sweep with a temlate file. Proper quoting 475 # of the template file is necessary to prevent submit from being too smart 476 # and converting it to a full pathname. 477 # ---------------------------------------------------------------------- 478 itcl::body Rappture::Task::_build_submit_cmd {cmd tfile params_file} { 479 set quote_next 0 480 set newcmd "submit --progress submit --runName=puq -l -i @:$tfile -d $params_file" 481 set cmds [split $cmd " "] 482 for {set i 0} {$i < [llength $cmds]} {incr i} { 483 set arg [lindex $cmds $i] 484 if {$quote_next == 1} { 485 set nc [string range $arg 0 0] 486 if {$nc != "\""} { 487 set arg "\"\\\"$arg\\\"\"" 488 } 489 } 490 if {$arg == "--eval"} { 491 set quote_next 1 492 } else { 493 set quote_next 0 494 } 495 if {$arg == "@driver"} { 496 set arg "\"\\\"$tfile\\\"\"" 497 } 498 append newcmd " " $arg 499 } 500 regsub -all @driver $newcmd $tfile newcmd 501 return $newcmd 502 } 503 504 # ---------------------------------------------------------------------- 505 # USAGE: _mkdir <directory> 506 # 507 # Used internally to create the <directory> in the file system. 508 # The parent directory is also created, as needed. 509 # ---------------------------------------------------------------------- 510 itcl::body Rappture::Task::_mkdir {dir} { 511 set parent [file dirname $dir] 512 if {$parent ne "." && $parent ne "/"} { 513 if {![file exists $parent]} { 514 _mkdir $parent 515 } 516 } 517 file mkdir $dir 518 } 519 520 521 # ---------------------------------------------------------------------- 522 # USAGE: abort 523 # 524 # Clients use this during a "run" to abort the current job. 525 # Kills the job and forces the "run" method to return. 526 # ---------------------------------------------------------------------- 527 itcl::body Rappture::Task::abort {} { 528 _log run abort 529 set job(control) "abort" 530 } 531 532 # ---------------------------------------------------------------------- 533 # USAGE: reset 534 # 535 # Resets all input values to their defaults. Sometimes used just 536 # before a run to reset to a clean state. 537 # ---------------------------------------------------------------------- 538 itcl::body Rappture::Task::reset {} { 539 $_xmlobj copy "" from $_origxml "" 540 foreach path [Rappture::entities -as path $_xmlobj input] { 541 if {[$_xmlobj element -as type $path.default] ne ""} { 542 set defval [$_xmlobj get $path.default] 543 $_xmlobj put $path.current $defval 544 } 545 } 546 } 547 548 # ---------------------------------------------------------------------- 549 # USAGE: xml <subcommand> ?<arg> <arg> ...? 550 # USAGE: xml object 551 # 552 # Used by clients to manipulate the underlying XML data for this 553 # tool. The <subcommand> can be any operation supported by a 554 # Rappture::library object. Clients can also request the XML object 555 # directly by using the "object" subcommand. 556 # ---------------------------------------------------------------------- 557 itcl::body Rappture::Task::xml {args} { 558 if {"object" == $args} { 559 return $_xmlobj 560 } 561 return [eval $_xmlobj $args] 562 } 563 564 # ---------------------------------------------------------------------- 565 # USAGE: save <xmlobj> ?<filename>? 566 # 567 # Used by clients to save the contents of an <xmlobj> representing 568 # a run out to the given file. If <filename> is not specified, then 569 # it uses the -resultsdir and other settings to do what Rappture 570 # would normally do with the output. 571 # ---------------------------------------------------------------------- 572 itcl::body Rappture::Task::save {xmlobj {filename ""}} { 573 if {$filename eq ""} { 574 # if there's a results_directory defined in the resources 575 # file, then move the run.xml file there for storage 576 set rdir "" 577 if {$resultdir eq "@default"} { 578 if {[info exists _resources(-resultdir)]} { 579 set rdir $_resources(-resultdir) 580 } else { 581 global rapptureInfo 582 set rdir $rapptureInfo(cwd) 583 } 584 } elseif {$resultdir ne ""} { 585 set rdir $resultdir 586 } 587 588 # use the runfile name generated by the last run 589 if {$_lastrun ne ""} { 590 set filename [file join $rdir $_lastrun] 591 } else { 592 set filename [file join $rdir run.xml] 593 } 594 } 595 596 # add any last-minute metadata 597 $xmlobj put output.time [clock format [clock seconds]] 598 599 $xmlobj put tool.version.rappture.version $::Rappture::version 600 $xmlobj put tool.version.rappture.revision $::Rappture::build 601 $xmlobj put output.filename $filename 602 $xmlobj put output.version $Rappture::version 603 604 if {[info exists ::tcl_platform(user)]} { 605 $xmlobj put output.user $::tcl_platform(user) 606 } 607 608 # save the output 609 set rdir [file dirname $filename] 610 if {![file exists $rdir]} { 611 _mkdir $rdir 612 } 613 614 set fid [open $filename w] 615 puts $fid "<?xml version=\"1.0\"?>" 616 puts $fid [$xmlobj xml] 617 close $fid 618 619 _log output saved in $filename 620 } 621 622 # ---------------------------------------------------------------------- 623 # USAGE: _output <data> 624 # 625 # Used internally to send each bit of output <data> coming from the 626 # tool onto the caller, so the user can see progress. 627 # ---------------------------------------------------------------------- 628 itcl::body Rappture::Task::_output {data} { 629 if {[string length $_outputcb] > 0} { 630 uplevel #0 $_outputcb [list $data] 631 } 632 } 633 634 # ---------------------------------------------------------------------- 635 # USAGE: _log <cmd> <arg> <arg> ... 636 # 637 # Used internally to log interesting events during the run. If the 638 # -logger option is set (to Rappture::Logger::log, or something like 639 # that), then the arguments to this method are passed along to the 640 # logger and written out to a log file. Logging is off by default, 641 # so this method does nothing unless -logger is set. 642 # ---------------------------------------------------------------------- 643 itcl::body Rappture::Task::_log {args} { 644 if {[string length $logger] > 0} { 645 uplevel #0 $logger [list $args] 646 } 647 } 648 649 # ---------------------------------------------------------------------- 650 # USAGE: MiddlewareTime <key> <value> ... 651 # 652 # Used as the default method for reporting job status information. 653 # Implements the old HUBzero method of reporting job status info to 654 # stderr, which can then be picked up by the tool session container. 655 # Most tools use the "submit" command, which talks directly to a 656 # database to log job information, so this isn't really needed. But 657 # it doesn't hurt to have this and it can be useful in some cases. 658 # ---------------------------------------------------------------------- 659 itcl::body Rappture::Task::MiddlewareTime {args} { 660 set line "MiddlewareTime:" 661 foreach {key val} $args { 662 append line " $key=$val" 663 } 664 puts stderr $line 665 } 666 667 668 # 669 # Send the list of parameters to a python program so it can call PUQ 670 # and get a CSV file containing the parameter values to use for the runs. 671 itcl::body Rappture::Task::_get_params {varlist uq_type uq_args} { 672 set pid [pid] 673 # puts "puq get_params $pid $varlist $uq_type $uq_args" 674 if {[catch {exec puq get_params $pid $varlist $uq_type $uq_args}]} { 675 set fp [open "uq_debug.err" r] 676 set rdata [read $fp] 677 close $fp 678 puts "get_params.py failed: $rdata" 679 error "get_params.py: $rdata" 680 } 681 return params[pid].csv 682 } 812 set _job(runfile) $fileName 813 } 814 } -
branches/1.6/src/core/config.h.in
r4225 r6131 240 240 /* Define to the one symbol short name of this package. */ 241 241 #undef PACKAGE_TARNAME 242 243 /* Define to the home page for this package. */ 244 #undef PACKAGE_URL 242 245 243 246 /* Define to the version of this package. */
Note: See TracChangeset
for help on using the changeset viewer.