summaryrefslogtreecommitdiffstats
path: root/scripts/visualize.py
blob: 2b828be31b1e8a863fd99ecbcee880f0a9efe0a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python

################################################################################
# Description
################################################################################
# This scriipt demonstrates the visualizer submodule.

# This script should be invoked with the names of the trace files you want to
# use. For example, `gedf_test.py ../sample_traces/*.bin`.
# You probably want to redirect the (normally lengthy) output to a file!
# Otherwise, speed is greatly decreased b/c terminal printing is slow.

################################################################################
# Setup
################################################################################

# Import the modules we need. You should not need to know about
# their internals.
import unit_trace
from unit_trace import trace_reader
from unit_trace import sanitizer
from unit_trace import gedf_test
from unit_trace import stats
from unit_trace import stdout_printer
from unit_trace import visualizer

# Get trace files from command line arguments
from optparse import OptionParser
parser = OptionParser()
(options, traces) = parser.parse_args()
traces = list(traces)

################################################################################
# Pipeline
################################################################################

# Read events from traces
stream = trace_reader.trace_reader(traces)

# Filter out garbage events
stream = sanitizer.sanitizer(stream)

# Produce G-EDF error records
stream = gedf_test.gedf_test(stream)

# Produce a statistics record
stream = stats.stats(stream)

# Filter some records out
def my_filter(record):
    if record.record_type == 'error' and record.type_name == 'inversion_end':
        if record.job.inversion_end - record.job.inversion_start < 4000000:
            return False
    return True
#stream = filter(my_filter, stream)

# It is possible to split the stream in two, 
# so we can use more than one output mechanism (for example)
# without re-doing earlier work.
# import itertools
# stream1, stream2 = itertools.tee(stream,2)

# Print the records to stdout
visualizer.visualizer(stream)