summaryrefslogtreecommitdiffstats
path: root/sample_script.py
diff options
context:
space:
mode:
Diffstat (limited to 'sample_script.py')
-rwxr-xr-xsample_script.py49
1 files changed, 36 insertions, 13 deletions
diff --git a/sample_script.py b/sample_script.py
index c3b7843..435cde0 100755
--- a/sample_script.py
+++ b/sample_script.py
@@ -1,9 +1,16 @@
1#!/usr/bin/python 1#!/usr/bin/python
2 2
3################################################################################
4# Description
5################################################################################
3# This is a sample script for using the tool. I would recommend copying 6# This is a sample script for using the tool. I would recommend copying
4# this and modifying it to suit your needs for a particular test. Make 7# this and modifying it to suit your needs for a particular test. Make
5# sure you redirect the output to a file (e.g. ./sample_script.py > output). 8# sure you redirect the output to a file (e.g. ./sample_script.py > output).
6 9
10################################################################################
11# Setup
12################################################################################
13
7# Import the modules we need. You should not need to know about 14# Import the modules we need. You should not need to know about
8# their internals. 15# their internals.
9import trace_reader 16import trace_reader
@@ -11,6 +18,7 @@ import sanitizer
11import gedf_test 18import gedf_test
12import stats 19import stats
13import stdout_printer 20import stdout_printer
21import visualizer
14 22
15# Specify your trace files 23# Specify your trace files
16g6 = [ 24g6 = [
@@ -20,22 +28,37 @@ g6 = [
20'./sample_traces/st-g6-3.bin', 28'./sample_traces/st-g6-3.bin',
21] 29]
22 30
23# Here is an example of a custom filter function. 31################################################################################
24# It will remove from the error stream all inversion_end records indicating 32# Pipeline
25# an inversion of less than 4000000 time units. Thus, you can grep through 33################################################################################
26# the output looking 'Inversion end' and find only errors for particularly 34
27# long inversions. This is commented out in the pipeline (below) since you 35# Read events from traces
28# probably don't want it in general. 36stream = trace_reader.trace_reader(g6)
37
38# Filter out garbage events
39stream = sanitizer.sanitizer(stream)
40
41# Produce G-EDF error records
42stream = gedf_test.gedf_test(stream)
43
44# Produce a statistics record
45stream = stats.stats(stream)
46
47# Filter some records out
48# NOTE: Currently, this will break the Visualizer if enabled
29def my_filter(record): 49def my_filter(record):
30 if record.record_type == 'error' and record.type_name == 'inversion_end': 50 if record.record_type == 'error' and record.type_name == 'inversion_end':
31 if record.job.inversion_end - record.job.inversion_start < 4000000: 51 if record.job.inversion_end - record.job.inversion_start < 4000000:
32 return False 52 return False
33 return True 53 return True
54#stream = filter(my_filter, stream)
34 55
35# Pipeline 56# Split the stream in two, so we can use both output mechanisms
36stream = trace_reader.trace_reader(g6) # Read events from traces 57import itertools
37stream = sanitizer.sanitizer(stream) # Remove garbage events 58stream1, stream2 = itertools.tee(stream,2)
38stream = gedf_test.gedf_test(stream) # Produce G-EDF error records 59
39stream = stats.stats(stream) # Produce a statistics record 60# Print the records to stdout
40#stream = filter(my_filter, stream) # Filter some records before printing 61stdout_printer.stdout_printer(stream1)
41stdout_printer.stdout_printer(stream) # Print records to stdout 62
63# Visualize the records
64visualizer.visualizer(stream2)