Changeset 5147


Ignore:
Timestamp:
Mar 17, 2015, 6:16:46 PM (5 years ago)
Author:
mmh
Message:

fix submit command parsing for uq

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/uq/lang/tcl/scripts/task.tcl

    r5121 r5147  
    3838    protected method _output {data}
    3939    protected method _log {args}
     40    protected method _build_submit_cmd {cmd tfile params_file}
    4041
    4142    private variable _xmlobj ""      ;# XML object with inputs/outputs
     
    230231    if {$status == 0} {
    231232        set cmd [$_xmlobj get tool.command]
     233        regsub -all @tool $cmd $_installdir cmd
     234        set cmd [string trimleft $cmd " "]
    232235        puts "1. cmd=$cmd"
    233         regsub -all @tool $cmd $_installdir cmd
    234 
    235         if {$uq_varlist == ""} {
    236             regsub -all @driver $cmd $file cmd
    237         } else {
    238             regsub -all @driver $cmd $tfile cmd
    239         }
    240         set cmd [string trimleft $cmd " "]
    241         puts "2. cmd=$cmd"
     236
    242237        if { $cmd == "" } {
    243238            puts stderr "cmd is empty"
     
    246241
    247242        if {$uq_varlist == ""} {
     243            regsub -all @driver $cmd $file cmd
     244
    248245            switch -glob -- [resources -jobprotocol] {
    249246                "submit*" {
     
    260257            }
    261258        } else {
    262             puts "uq_varlist=$uq_varlist"
     259            set params_file [get_params $file $uq_varlist $uq_type $uq_args]
     260            set cmd [_build_submit_cmd $cmd $tfile $params_file]
    263261            file delete -force puq
    264             set params_file [get_params $file $uq_varlist $uq_type $uq_args]
    265             set cmd "submit --runName=puq -l -d $params_file uq.py $cmd @:$tfile"
    266262        }
    267263
     
    454450
    455451# ----------------------------------------------------------------------
     452#  Turn the command string from tool.xml into the proper syntax to use
     453#  with a submit parameter sweep with a temlate file.  Proper quoting
     454# of the template file is necessary to prevent submit from being too smart
     455# and converting it to a full pathname.
     456# ----------------------------------------------------------------------
     457itcl::body Rappture::Task::_build_submit_cmd {cmd tfile params_file} {
     458    puts "BSC $cmd $tfile $params_file"
     459
     460    set quote_next 0
     461    set newcmd "submit --runName=puq -l -i @:$tfile -d $params_file"
     462    set cmds [split $cmd " "]
     463    for {set i 0} {$i < [llength $cmds]} {incr i} {
     464        set arg [lindex $cmds $i]
     465        if {$quote_next == 1} {
     466            set nc [string range $arg 0 0]
     467            if {$nc != "\""} {
     468                set arg "\"\\\"$arg\\\"\""
     469            }
     470        }
     471        if {$arg == "--eval"} {
     472            set quote_next 1
     473        } else {
     474            set quote_next 0
     475        }
     476        if {$arg == "@driver"} {
     477            set arg "\"\\\"$tfile\\\"\""
     478        }
     479        append newcmd " " $arg
     480    }
     481    puts "BSC2: $newcmd"
     482    regsub -all @driver $newcmd $tfile newcmd
     483    puts "BSC returning: $newcmd"
     484    return $newcmd
     485}
     486
     487# ----------------------------------------------------------------------
    456488# USAGE: _mkdir <directory>
    457489#
     
    650682    set varlist [varlist2py $varlist]
    651683    set pid [pid]
     684    puts "get_params.py $dfile $pid $varlist $uq_type $args"
    652685    exec get_params.py $dfile $pid $varlist $uq_type $args
    653686    return params[pid].csv
Note: See TracChangeset for help on using the changeset viewer.