Changeset 3625 for trunk/gui/apps


Ignore:
Timestamp:
Apr 4, 2013 5:18:19 AM (11 years ago)
Author:
mmc
Message:

Added "-v" option to rptimes, which lets you take a quick peek at an
SQLite database generated by processing run.xml files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/apps/rptimes

    r3624 r3625  
    99#    USAGE:
    1010#    % rptimes <run.xml> ?<run.xml>...?
     11#    % rptimes -v <sqliteDB>
    1112#
    1213#  Exits with status 0 if successful, and non-zero if any run.xml
    1314#  files cannot be processed.
    1415#
    15 #  The SQLite DB created by this command contains the following data:
    16 #
    17 #     CREATE TABLE times:
    18 #       tool ...... tool.id - app name of tool on nanoHUB (text)
    19 #       version ... tool.version.identifier - tool version (text)
    20 #       walltime .. execution wall time in seconds (double)
    21 #       cputime ... execution cpu time in seconds (double)
    22 #       user ...... output.user - user name (text)
     16#  Creates an SQLite DB for each unique tool referenced by a run.xml
     17#  file.  Each DB file contains a table of parameters and a table of
     18#  "jobs" info.  The jobs table includes CPU time and Wall time
     19#  measurements.
    2320#
    2421# ======================================================================
     
    4037if {[llength $argv] < 1} {
    4138    puts stderr "USAGE: rptimes run.xml ?run.xml...?"
     39    puts stderr "USAGE: rptimes -v tool.sql3"
    4240    exit 1
     41}
     42
     43set op "ingest"
     44while {[llength $argv] > 0} {
     45    set flag [lindex $argv 0]
     46    if {![string match -* $flag]} {
     47        break
     48    }
     49    switch -- $flag {
     50        -v {
     51            set op "view"
     52            if {[llength $argv] < 2} {
     53                puts stderr "USAGE: rptimes -v tool.sql3"
     54                exit 1
     55            }
     56            set dbfile [lindex $argv 1]
     57            set argv [lrange $argv 2 end]
     58        }
     59        default {
     60            puts stderr "bad flag \"$flag\": should be -v"
     61            exit 1
     62        }
     63    }
    4364}
    4465
     
    159180    regsub -all {([^\'])\'} $str {\1''} str
    160181    return $str
     182}
     183
     184#
     185# Handle "view" operation
     186#
     187if {$op eq "view"} {
     188    sqlite3 db $dbfile
     189
     190    puts "PARAMETERS:"
     191    db eval {SELECT nickName,rappturePath,type FROM parameters;} data {
     192        puts " - $data(nickName) ($data(type)) = $data(rappturePath)"
     193    }
     194
     195    puts "\nJOBS:"
     196    set n 0
     197    db eval {SELECT runToken,date,cpuTime,wallTime FROM jobs;} data {
     198        puts [format " [incr n]) [clock format $data(date)]:  %6.2f CPU, %6.2f Wall" $data(cpuTime) $data(wallTime)]
     199    }
     200
     201    catch {db close}
     202    exit 0
    161203}
    162204
Note: See TracChangeset for help on using the changeset viewer.