Changeset 6169


Ignore:
Timestamp:
Mar 21, 2016 10:20:17 AM (7 years ago)
Author:
gah
Message:

reapply fix for logging submitted jobs

File:
1 edited

Legend:

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

    r6133 r6169  
    3131    private method LogCachedSimulationUsage {}
    3232    private method LogSimulationUsage {}
     33    private method LogSubmittedSimulationUsage {}
    3334    private method SetCpuResourceLimit {}
    3435
     
    254255            CollectUQResults
    255256        }
    256         if { [resources -jobprotocol] != "submit" } {
     257        if { [resources -jobprotocol] == "submit" } {
     258            LogSubmittedSimulationUsage
     259        } else {
    257260            LogSimulationUsage
    258261        }
     
    744747}
    745748
     749itcl::body Rappture::Task::LogSubmittedSimulationUsage {} {
     750    array set times [Rappture::rusage measure]
     751
     752    set toolId     [$_xmlobj get tool.id]
     753    set toolVers   [$_xmlobj get tool.version.application.revision]
     754    set simulation "simulation"
     755    if { $toolId ne "" && $toolVers ne "" } {
     756        set simulation "[pid]_${toolId}_r${toolVers}"
     757    }
     758   
     759    # Need to save job info? then invoke the callback
     760    if { [string length $jobstats] > 0} {
     761        lappend args \
     762            "job"      [incr jobnum] \
     763            "event"    $simulation \
     764            "start"    $times(start) \
     765            "walltime" $times(walltime) \
     766            "cputime"  $times(cputime) \
     767            "status"   $_job(success)
     768        uplevel #0 $jobstats $args
     769    }
     770       
     771    #
     772    # Scan through stderr channel and look for statements that
     773    # represent grid jobs that were executed.  The statements look
     774    # like this:
     775    #
     776    # MiddlewareTime: job=1 event=simulation start=3.001094 ...
     777    #
     778   
     779    set subjobs 0
     780    set pattern {(^|\n)MiddlewareTime:( +[a-z]+=[^ \n]+)+(\n|$)}
     781    while { [regexp -indices $pattern $_job(stderr) match] } {
     782        foreach {p0 p1} $match break
     783        if { [string index $_job(stderr) $p0] == "\n" } {
     784            incr p0
     785        }
     786        array unset data
     787        array set data {
     788            job 1
     789            event simulation
     790            start 0
     791            walltime 0
     792            cputime 0
     793            status 0
     794        }
     795        foreach arg [lrange [string range $_job(stderr) $p0 $p1] 1 end] {
     796            foreach {key val} [split $arg =] break
     797            set data($key) $val
     798        }
     799        set data(job)   [expr { $jobnum + $data(job) }]
     800        set data(event) "subsimulation"
     801        set data(start) [expr { $times(start) + $data(start) }]
     802       
     803        set details ""
     804        foreach key {job event start walltime cputime status} {
     805            # Add required keys in a particular order
     806            lappend details $key $data($key)
     807            unset data($key)
     808        }
     809        foreach key [array names data] {
     810            # Add anything else that the client gave -- venue, etc.
     811            lappend details $key $data($key)
     812        }
     813       
     814        if {[string length $jobstats] > 0} {
     815            uplevel #0 $jobstats $details
     816        }
     817       
     818        incr subjobs
     819       
     820        # Done -- remove this statement
     821        set _job(stderr) [string replace $_job(stderr) $p0 $p1]
     822    }
     823    incr jobnum $subjobs
     824
     825    # Add cputime info to run.xml file
     826    if { [catch {
     827        Rappture::library $_job(runfile)
     828    } xmlobj] != 0 } {
     829        error "Can't create rappture library: $xmlobj"
     830    }
     831    set _job(xmlobj) $xmlobj
     832}
     833
    746834itcl::body Rappture::Task::LogCachedSimulationUsage {} {
    747835    if { [catch {
Note: See TracChangeset for help on using the changeset viewer.