-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathcrashmodule.py
More file actions
91 lines (66 loc) · 2.21 KB
/
crashmodule.py
File metadata and controls
91 lines (66 loc) · 2.21 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import logging
from cellprofiler_core.module import ImageProcessing
from cellprofiler_core.object import Objects
from cellprofiler_core.setting.choice import Choice
LOGGER = logging.getLogger(__name__)
__doc__ = f"""\
CrashModule
===========
**CrashModule** crashes
============ ============ ===============
Supports 2D? Supports 3D? Respects masks?
============ ============ ===============
YES YES NO
============ ============ ===============
"""
DOCKER_IMAGE_NAME = "cellprofiler/crashdocker:0.0.1"
class CrashModule(ImageProcessing):
category = "Image Processing"
module_name = "CrashModule"
variable_revision_number = 1
def create_settings(self):
super(CrashModule, self).create_settings()
self.y_name.set_value("OutputImage")
self.do_crash = Choice(
text="Crash the run",
choices=["Yes", "No"],
value="Yes",
doc="""\
Cause this module to crash or succeed
""",
)
def settings(self):
return super().settings() + [
self.do_crash,
]
def visible_settings(self):
vis_settings = super().visible_settings() + [
self.do_crash,
]
return vis_settings
def run(self, workspace):
print("CrashModule - I am running")
self.function = self.do_run
measurements = workspace.measurements
for i in range(100):
feature = "Blah%d" % i
measurements.add_measurement(
"Image", feature, i
)
if self.do_crash == "Yes":
super().run(workspace)
raise Exception("I am crashing - run")
else:
super().run(workspace)
def do_run(self, x_data, *args):
return x_data
def post_run(self, workspace):
print("CrashModule - I am running post run")
if self.do_crash == "Yes":
raise Exception("I am crashing - post run")
else:
super().post_run(workspace)
def display(self, workspace, figure):
super().display(workspace, figure)
def upgrade_settings(self, setting_values, variable_revision_number, module_name):
return setting_values, variable_revision_number