1
1
Sopic
2
2
======
3
3
4
- Helper library for a test station in a production line.
4
+ Test stations GUI library for your hardware on a production line.
5
5
6
6
Define a station that will run a number of steps, in sequential order.
7
+ Visualize the steps with the GUI
7
8
8
9
9
10
# Screenshots
@@ -15,112 +16,87 @@ Define a station that will run a number of steps, in sequential order.
15
16
16
17
# Installation
17
18
18
- After a clone of the repository
19
-
20
- ` poetry install `
19
+ ` pip install sopic `
21
20
22
21
23
22
# How to use
24
23
25
- Initialise a ` MainWindow ` with a station object, child of the ` Station ` class.
26
-
27
- In your station class you can set some parameters and define your list of steps.
24
+ Initialise ` MainWindow ` with a station object, child of the ` Station ` class.
28
25
29
- You can also define a settings dialog when initializing the ` MainWindow ` .
30
-
31
- Check the examples directory (eg: ` poetry run python examples/00_basic.py ` )
26
+ In your station class you can define the steps in a DAG and settings for the
27
+ runs.
32
28
33
29
34
30
# Keybinds
35
31
36
- ### Exit the station
37
- Ctrl-Q
38
-
39
- ### Settings
40
- ** Ctrl-P**
41
-
42
- DIsplay the settings dialog. The configuration is saved. The settings can be
43
- reset to the default configuration set in the station class.
44
-
45
- ### Step selection
46
- ** Ctrl-T**
47
-
48
- Allow to enable/disable steps. The configuration is not saved.
49
-
50
- ### Log and settings layout
51
- ** Ctrl-B**
52
-
53
- Display settings and log window
54
-
32
+ - ` Ctrl-Q ` : exit the station
33
+ - ` Ctrl-P ` : display the settings dialog, when available
34
+ - ` Ctrl-B ` : display the logs
55
35
56
36
# Definitions
57
37
58
38
A step is the smallest component, a class invoked at the start of the station.
59
- A method from this object will be called to start the step. The step has then
60
- access to data from previous steps, if they provided it, and global settings of
61
- the station.
62
- After being called, the step has to notify the station of the tests passed or
63
- not.
39
+ The ` start ` method from this object will be called to start the step. The step
40
+ has then access to data from previous steps, if they provided it, settings and
41
+ current run info.
42
+ After being called the step can either returns ` self.OK() ` or ` self.KO() ` to
43
+ notify the station if the step has passed or not. These two methods take a
44
+ parameters to select the next step.
64
45
65
- A station is a group of steps. It's also defined as a class and will store the
66
- default settings, station configuration and the steps.
46
+ A station is a group of steps. The steps are defined in a Direct Acyclic Graph.
67
47
68
- A run is the term used to define the "list" of steps from the first to the last,
69
- as defined in the station class.
70
- So a station will perform multiple runs. Each one composed of multiple steps.
48
+ A run is the succession of the steps. A run can either Pass or Fail. A station
49
+ will perform multiple runs.
71
50
72
51
73
52
# Features
74
53
75
54
- GUI
76
55
- Share data between steps
77
56
- Settings for step configuration
78
- - Step selection
79
57
- Logs
58
+ - Easy to customize with wrappers
80
59
81
60
# Define a station
82
61
83
62
``` python
84
63
from sopic import Station
85
64
86
65
class MyStation (Station ):
87
- # Used as window title
88
- DISPLAY_NAME = ' my station'
89
- # Used for logs, filenames
66
+ # Used as window title, log file, settings file
90
67
STATION_NAME = ' my-station'
91
- # Same use as STATION_NAME, useful to when saving the previous station
68
+ # Same use as STATION_NAME
92
69
STATION_ID = 0
93
-
94
- # Allow to disable logging to files
95
- disable_file_logging = False
96
-
97
- # List of steps in the station
98
- steps = [
99
- Step1,
100
- # Can deactivate step by default
101
- # steps can be enabled with the step selection dialog
102
- (Step2, False ),
103
- ]
104
-
105
- # By default a fail in a step will force the run to go directly to the
106
- # last step, skipping other steps.
107
- # By defining the non blocking steps we allow the run to continue even
108
- # if these steps failed. Useful when testing the station without caring
109
- # about the step output
110
- # Note that the run is still a fail if one of these steps fail.
111
- nonBlockingSteps = [
112
- Step1.STEP_NAME ,
113
- ]
114
-
115
- # Steps that will always be skipped if one previous step has failed.
116
- # Useful when also using nonBlockingSteps
117
- stepsSkippedOnPreviousFail = [
118
- Step2.STEP_NAME ,
119
- ]
70
+ # Optional, displayed in the bottom right corner of the main window
71
+ STATION_VERSION = " 1.0.0"
72
+
73
+ # Will generate a png output of the dag
74
+ DEBUG = True
75
+
76
+ # Select the first step, via its key
77
+ start_step_key = " start"
78
+
79
+ # DAG of the steps
80
+ dag = {
81
+ # first step
82
+ # `StartButton` is the step class
83
+ # `["select"] is the child, no matter if the StartButton fails, the
84
+ # child will be the one with the `"select"` key
85
+ " start" : (StartButton, [" select" ]),
86
+ # This step define another step class, `Select`
87
+ # This step can select one of two childs
88
+ # - "foo", if the step returns the key "ok"
89
+ # - "bar", if the step returns the key "ko"
90
+ " select" : (Select, {" ok" : " foo" , " ko" : " bar" }),
91
+ # The next two steps don't have any child, returning for those step
92
+ # will end the run
93
+ " foo" : (AlwaysOK, []),
94
+ " bar" : (AlwaysKO, []),
95
+ }
120
96
121
97
# Default settings of the station. Can be updated with the SettingsDialog.
122
- defaultSettings = {
123
- ' random-setting ' : ' 42 ' ,
98
+ default_settings = {
99
+ " random-settings " : { " value " : 42 , " label " : " A random settings " } ,
124
100
}
125
101
```
126
102
@@ -130,53 +106,41 @@ class MyStation(Station):
130
106
from sopic import Step
131
107
132
108
class MyStep (Step ):
133
- # name of the step, used for display and logs
109
+ # Name of the step, used for display and logs
134
110
STEP_NAME = ' my-step'
135
- # number of retries allowed on fail
111
+ # Number of retries allowed on fail
136
112
MAX_RETRIES = 1
137
113
138
- # called when the step is started
139
- # stepsData contains data of the previous steps, if available.
140
- # Data of steps is available via `stepsData[Step1.STEP_NAME]`.
141
- # Settings is available at `stepsData['__settings']`.
142
- # Check the End step in the example folder for more use of the stepsData.
143
- def start (self , stepsData ):
114
+ # Called when the step is started
115
+ # `context` contains value stored by previous steps
116
+ # `settings` contains the station settings
117
+ # `run_info` contains current run information
118
+ def start (self , context , settings , run_info ):
144
119
super ().start()
145
120
146
121
# Add your tests here
147
- # You have access to `self.logger` to log some info.
148
- # You have access to the object `self.stepData` to store data, it will
149
- # be available for future the next steps. This object is reset on each run.
150
- # The step will have to return either `OK` or `KO`
151
-
152
- # A string can be passed to describe the success of the step.
153
- return self .OK(' all good' )
154
-
155
- # On error, the step should return `self.KO`
156
- # terminate, flag will force the run to end.
157
- # errorStr and errorCode is used to describe the error
158
- # return self.KO(
159
- terminate = False ,
160
- errorStr = " something happened" ,
161
- errorCode = 42
162
- )
163
-
164
- # Used if the step define use a StepUI
165
- # Check the steps in the examples directory
166
- def getWidget (self ):
167
- if (self .widet == = None ):
168
- self .widget = MyStepUI()
169
- return self .widget
122
+
123
+ return self .OK()
170
124
```
171
125
172
126
173
127
# Examples
174
128
175
129
[ Check the examples directory] ( ./examples )
176
130
131
+ To run the examples:
132
+ ``` bash
133
+ git clone https://github.com/Taldrain/sopic
134
+ cd sopic
135
+ poetry install
136
+ poetry run examples/00_basic.py
137
+ ```
138
+
177
139
178
140
# See also
179
141
180
142
[ exclave] ( https://github.com/exclave/exclave )
181
143
182
144
[ Exclave: Hardware Testing in Mass Production, Made Easier] ( https://www.bunniestudios.com/blog/?p=5450 )
145
+
146
+ [ awesome-hardware-test] ( https://github.com/sschaetz/awesome-hardware-test )
0 commit comments