Skip to content

Commit ead8651

Browse files
committed
gracefully handle missing extrae ON/OFF events
should resolve #24
1 parent 585fc3d commit ead8651

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

pypop/notebook_interface/wizard.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def _calculate_callback_hook(self, callback_reference=None):
149149
force_recalculation=advanced_config["Delete Cache"].value,
150150
chop_to_roi=advanced_config["Chop to ROI"].value,
151151
no_progress=True,
152+
chop_fail_is_error=True
152153
)
153154
except ExtraePRVNoOnOffEventsError as err:
154155
fileprogress = tqdm_notebook_noauto(self._fileselector.filenames, leave=False)

pypop/trace/prvtrace.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
from .trace import Trace
1414

1515
from ..utils.io import zipopen
16-
from ..utils.exceptions import WrongLoaderError
16+
from ..utils.exceptions import WrongLoaderError, ExtraePRVNoOnOffEventsError
1717

1818
from ..dimemas import dimemas_idealise
1919
from ..extrae import paramedir_analyze_any_of, chop_prv_to_roi, remove_trace
2020

2121
base_configs = {
22-
k: tuple(resource_filename('pypop', w) for w in v)
22+
k: tuple(resource_filename("pypop", w) for w in v)
2323
for k, v in {
2424
"Serial Useful Computation": (
2525
"cfgs/serial_useful_computation.cfg",
@@ -37,7 +37,7 @@
3737
}
3838

3939
omp_configs = {
40-
k: tuple(resource_filename('pypop', w) for w in v)
40+
k: tuple(resource_filename("pypop", w) for w in v)
4141
for k, v in {
4242
"OpenMP Total Runtime": (
4343
"cfgs/omp_total_runtime.cfg",
@@ -53,7 +53,7 @@
5353
}
5454

5555
ideal_configs = {
56-
k: tuple(resource_filename('pypop', w) for w in v)
56+
k: tuple(resource_filename("pypop", w) for w in v)
5757
for k, v in {
5858
"Ideal Useful Computation": ("cfgs/total_useful_computation.cfg",),
5959
"Ideal Runtime": ("cfgs/total_runtime.cfg",),
@@ -120,6 +120,7 @@ def _gather_statistics(self):
120120
self._tracefile,
121121
self._kwargs.get("chop_to_roi", False),
122122
self._kwargs.get("outpath", None),
123+
self._kwargs.get("chop_fail_is_error", False)
123124
)
124125

125126
@staticmethod
@@ -142,19 +143,26 @@ def _split_layoutstring(prv_td):
142143
return (commsize, threads)
143144

144145
@staticmethod
145-
def _analyze_tracefile(trace, chop_to_roi, outpath):
146+
def _analyze_tracefile(trace, chop_to_roi, outpath, chop_fail_is_error):
146147
if outpath:
147148
makedirs(outpath, exist_ok=True)
148149

149-
if chop_to_roi:
150-
if outpath:
151-
tgtname = ".chop".join(splitext(basename(trace)))
152-
outfile = path_join(outpath, tgtname)
150+
try:
151+
if chop_to_roi:
152+
if outpath:
153+
tgtname = ".chop".join(splitext(basename(trace)))
154+
outfile = path_join(outpath, tgtname)
155+
else:
156+
outfile = None
157+
cut_trace = chop_prv_to_roi(trace, outfile)
153158
else:
154-
outfile = None
155-
cut_trace = chop_prv_to_roi(trace, outfile)
156-
else:
159+
cut_trace = trace
160+
except ExtraePRVNoOnOffEventsError as err:
161+
if chop_fail_is_error:
162+
raise err
163+
warn("Unable to chop to ROI: ({}) - Continuing without chopping".format(err))
157164
cut_trace = trace
165+
chop_to_roi = False
158166

159167
stats = [
160168
paramedir_analyze_any_of(

pypop/traceset.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def __init__(
6767
outpath=None,
6868
ignore_cache=None,
6969
tag=None,
70+
chop_fail_is_error=False,
7071
):
7172
# Setup data structures
7273
self.traces = set()
@@ -80,7 +81,13 @@ def __init__(
8081

8182
# Add traces
8283
self.add_traces(
83-
path_list, force_recalculation, chop_to_roi, no_progress, outpath, tag
84+
path_list,
85+
force_recalculation,
86+
chop_to_roi,
87+
no_progress,
88+
outpath,
89+
tag,
90+
chop_fail_is_error,
8491
)
8592

8693
def add_traces(
@@ -91,6 +98,7 @@ def add_traces(
9198
no_progress=False,
9299
outpath=None,
93100
tag=None,
101+
chop_fail_is_error=False,
94102
):
95103
"""Collect statistics from provided trace files, currently only Extrae .prv files
96104
are supported.
@@ -140,6 +148,7 @@ def add_traces(
140148
chop_to_roi=chop_to_roi,
141149
outpath=outpath,
142150
tag=tag,
151+
chop_fail_is_error=chop_fail_is_error,
143152
)
144153
)
145154

0 commit comments

Comments
 (0)