process_measurement
Base class for measurement of external processes asynchronously.
ProcessMeasurement
Bases: Measurement
Base class to be extended to measure external processes.
Source code in mlte/measurement/process_measurement.py
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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
PROCESS_GROUP_KEY = 'group'
class-attribute
instance-attribute
Key to store optional process groups used by this measurement.
error = ''
instance-attribute
Any error messages from running measurement.
group = group
instance-attribute
An optional group id, if we want to group this measurement with others.
stored_value = None
instance-attribute
The result of the measurement.
thread = None
instance-attribute
Thread that will be used to run the measurement process.
__call__(pid, *args, **kwargs)
abstractmethod
Calls for process based measurement will always have pid as the first argument..
Source code in mlte/measurement/process_measurement.py
95 96 97 98 99 100 | |
__init__(test_case_id=None, group=None)
Initialize a new ProcessMeasurement measurement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
test_case_id
|
Optional[str]
|
A unique identifier for the measurement |
None
|
group
|
Optional[str]
|
An optional group id, if we want to group this measurement with others. |
None
|
Source code in mlte/measurement/process_measurement.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
additional_setup(model)
Customized method to set up Optional group id from metadata.
Source code in mlte/measurement/process_measurement.py
83 84 85 86 87 88 89 90 91 92 | |
evaluate(command, *args, **kwargs)
Evaluate by starting the given process and waiting for it to complete.
Source code in mlte/measurement/process_measurement.py
102 103 104 105 106 107 108 109 110 111 112 | |
evaluate_async(pid, *args, **kwargs)
Monitor an external process at pid in a separate thread until it stops.
Equivalent to evaluate(), but does not return the value immediately as it works in the background.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pid
|
int
|
The process identifier |
required |
Source code in mlte/measurement/process_measurement.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
generate_metadata()
Returns Measurement metadata with additional info.
Source code in mlte/measurement/process_measurement.py
72 73 74 75 76 77 78 79 80 | |
start_process(command)
staticmethod
Initialize an external process running training or similar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
list[str]
|
A list the full path to a process to run and string arguments for the process. |
required |
Returns:
| Type | Description |
|---|---|
int
|
the id of the process that was created. |
Source code in mlte/measurement/process_measurement.py
38 39 40 41 42 43 44 45 46 | |
start_script(command)
staticmethod
Initialize an external Python process running training or similar script.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
list[str]
|
A list with the full path to a Python script with the training or equivalent process to run, and a list of string arguments for the process. |
required |
Returns:
| Type | Description |
|---|---|
int
|
the id of the process that was created. |
Source code in mlte/measurement/process_measurement.py
27 28 29 30 31 32 33 34 35 36 | |
wait_for_output(poll_interval=1)
Needed to get the output of a measurement executed in parallel using evaluate_async. Waits for the thread to finish.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poll_interval
|
int
|
The poll interval in seconds |
1
|
Returns:
| Type | Description |
|---|---|
Evidence
|
The resulting value of measurement execution, with semantics |
Source code in mlte/measurement/process_measurement.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |