processview 0.1.0b0__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/__pycache__/version.cpython-37.pyc +0 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/core/__pycache__/dataset.cpython-37.pyc +0 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/core/__pycache__/superviseprocess.cpython-37.pyc +0 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/core/dataset.py +23 -6
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/core/manager/__pycache__/manager.cpython-37.pyc +0 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/core/manager/manager.py +46 -42
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/core/manager/test/__pycache__/test_manager.cpython-37.pyc +0 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/core/manager/test/test_manager.py +24 -4
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/core/superviseprocess.py +15 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/gui/__pycache__/processmanager.cpython-37.pyc +0 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/gui/processmanager.py +138 -87
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/gui/test/__init__.py +38 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/gui/test/__pycache__/__init__.cpython-37.pyc +0 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/gui/test/__pycache__/test_process_manager.cpython-37.pyc +0 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/gui/test/test_process_manager.py +108 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/resources/__init__.py +489 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/resources/__pycache__/__init__.cpython-37.pyc +0 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/test/__init__.py +2 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/test/__pycache__/__init__.cpython-37.pyc +0 -0
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/processview/version.py +3 -3
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/{processview-0.1.0b0-py3.7.egg-info → processview-0.1.2-py3.7.egg-info}/PKG-INFO +1 -1
- home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/{processview-0.1.0b0-py3.7.egg-info → processview-0.1.2-py3.7.egg-info}/SOURCES.txt +2 -0
- /home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/{processview-0.1.0b0-py3.7.egg-info → processview-0.1.2-py3.7.egg-info}/dependency_links.txt +0 -0
- /home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/{processview-0.1.0b0-py3.7.egg-info → processview-0.1.2-py3.7.egg-info}/not-zip-safe +0 -0
- /home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/{processview-0.1.0b0-py3.7.egg-info → processview-0.1.2-py3.7.egg-info}/requires.txt +0 -0
- /home/payno/.local/share/virtualenvs/tomwer_venv/lib/python3.7/site-packages/{processview-0.1.0b0-py3.7.egg-info → processview-0.1.2-py3.7.egg-info}/top_level.txt +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -28,13 +28,30 @@ __license__ = "MIT"
|
|
|
28
28
|
__date__ = "29/01/2021"
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
class DatasetIdentifier:
|
|
32
|
+
def __init__(self, dataset):
|
|
33
|
+
if not isinstance(dataset, Dataset):
|
|
34
|
+
raise TypeError("{} should be an instance of Dataset".format(dataset))
|
|
35
|
+
self._dataset_builder = dataset.from_dataset_identifier
|
|
36
|
+
|
|
37
|
+
def recreate_dataset(self):
|
|
38
|
+
"""Recreate the dataset from the identifier"""
|
|
39
|
+
return self._dataset_builder(self)
|
|
40
|
+
|
|
41
|
+
def long_description(self) -> str:
|
|
42
|
+
"""long description of the identifier"""
|
|
43
|
+
return ""
|
|
44
|
+
|
|
45
|
+
|
|
31
46
|
class Dataset:
|
|
32
47
|
"""Base class that class processes should inherit"""
|
|
33
48
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
@staticmethod
|
|
50
|
+
def from_dataset_identifier(identifier):
|
|
51
|
+
"""Return the Dataset from a identifier"""
|
|
52
|
+
raise NotImplementedError("Base class")
|
|
37
53
|
|
|
38
|
-
def
|
|
39
|
-
"""
|
|
40
|
-
|
|
54
|
+
def get_dataset_identifier(self) -> DatasetIdentifier:
|
|
55
|
+
"""dataset unique identifier. Can be for example a hdf5 and
|
|
56
|
+
en entry from which the dataset can be rebuild"""
|
|
57
|
+
raise NotImplementedError("Base class")
|
|
Binary file
|
|
@@ -30,6 +30,7 @@ __date__ = "03/11/2020"
|
|
|
30
30
|
|
|
31
31
|
from processview.utils.singleton import singleton
|
|
32
32
|
from processview.core.dataset import Dataset
|
|
33
|
+
from processview.core.dataset import DatasetIdentifier
|
|
33
34
|
from collections import OrderedDict
|
|
34
35
|
from silx.utils.enum import Enum as _Enum
|
|
35
36
|
import threading
|
|
@@ -60,7 +61,7 @@ class ProcessManager:
|
|
|
60
61
|
def __init__(self):
|
|
61
62
|
self._processes = {}
|
|
62
63
|
self._dataset_process_states = {}
|
|
63
|
-
"""key is
|
|
64
|
+
"""key is processID, Value is a tuple of
|
|
64
65
|
(dataset state, details)"""
|
|
65
66
|
self._processID = 0
|
|
66
67
|
self._updateCallback = set()
|
|
@@ -69,6 +70,15 @@ class ProcessManager:
|
|
|
69
70
|
"""list of callback to trigger when a process is added"""
|
|
70
71
|
self.lock = threading.Lock()
|
|
71
72
|
|
|
73
|
+
def met(self, process, dataset) -> bool:
|
|
74
|
+
"""check if a dataset has already met a dataset"""
|
|
75
|
+
if isinstance(dataset, DatasetIdentifier):
|
|
76
|
+
dataset_id = dataset
|
|
77
|
+
else:
|
|
78
|
+
dataset_id = dataset.get_dataset_identifier()
|
|
79
|
+
if process.process_id in self._dataset_process_states:
|
|
80
|
+
return dataset_id in self._dataset_process_states[process.process_id]
|
|
81
|
+
|
|
72
82
|
def register(self, process) -> int:
|
|
73
83
|
"""
|
|
74
84
|
Register a process to the manager
|
|
@@ -82,20 +92,17 @@ class ProcessManager:
|
|
|
82
92
|
|
|
83
93
|
for callback in self._newProcessCallback:
|
|
84
94
|
callback()
|
|
85
|
-
|
|
86
95
|
return process_id
|
|
87
96
|
|
|
88
|
-
def
|
|
97
|
+
def _find_dataset_id(self, data) -> Dataset:
|
|
89
98
|
if isinstance(data, Dataset):
|
|
99
|
+
return data.get_dataset_identifier()
|
|
100
|
+
elif isinstance(data, DatasetIdentifier):
|
|
90
101
|
return data
|
|
91
|
-
elif isinstance(data, str):
|
|
92
|
-
for s in self.get_datasets():
|
|
93
|
-
if s == data:
|
|
94
|
-
return data
|
|
95
102
|
else:
|
|
96
103
|
raise TypeError(
|
|
97
104
|
"dataset should be an instance of Dataset or "
|
|
98
|
-
"
|
|
105
|
+
"DatasetIdentifier. Get {} instead".format(type(data))
|
|
99
106
|
)
|
|
100
107
|
|
|
101
108
|
def _find_process(self, process):
|
|
@@ -106,7 +113,7 @@ class ProcessManager:
|
|
|
106
113
|
elif isinstance(process, str):
|
|
107
114
|
for p in self.get_processes():
|
|
108
115
|
if p.name == process:
|
|
109
|
-
return
|
|
116
|
+
return p
|
|
110
117
|
else:
|
|
111
118
|
raise TypeError(
|
|
112
119
|
"process should be an instance of SuperviseProcess or"
|
|
@@ -119,7 +126,7 @@ class ProcessManager:
|
|
|
119
126
|
|
|
120
127
|
:param BaseProcess process:
|
|
121
128
|
"""
|
|
122
|
-
if process.process_id in self._processes:
|
|
129
|
+
if process.process_id in self._processes and process.is_master_process:
|
|
123
130
|
del self._processes[process.process_id]
|
|
124
131
|
|
|
125
132
|
def get_processes(self) -> tuple:
|
|
@@ -160,77 +167,73 @@ class ProcessManager:
|
|
|
160
167
|
self._dataset_process_states[process.process_id] = OrderedDict()
|
|
161
168
|
if details is None:
|
|
162
169
|
details = ""
|
|
163
|
-
|
|
170
|
+
dataset_id = dataset.get_dataset_identifier()
|
|
171
|
+
self._dataset_process_states[process.process_id][dataset_id] = (
|
|
164
172
|
state,
|
|
165
173
|
datetime.now(),
|
|
166
174
|
details,
|
|
167
175
|
)
|
|
168
176
|
self.updated()
|
|
169
177
|
|
|
170
|
-
def get_dataset_state(self,
|
|
178
|
+
def get_dataset_state(self, dataset_id, process) -> Union[None, DatasetState]:
|
|
171
179
|
"""
|
|
172
180
|
|
|
173
|
-
:param Dataset
|
|
181
|
+
:param Dataset dataset_id:
|
|
174
182
|
:param BaseProcess process:
|
|
175
183
|
:return: DatasetState relative to provided process if know
|
|
176
184
|
:rtype: Union[None, DatasetState]
|
|
177
185
|
"""
|
|
178
|
-
|
|
186
|
+
dataset_id = self._find_dataset_id(dataset_id)
|
|
187
|
+
assert isinstance(dataset_id, DatasetIdentifier)
|
|
179
188
|
process = self._find_process(process)
|
|
180
189
|
if process is None:
|
|
181
190
|
_logger.warning("process {} is no more supervised".format(process))
|
|
182
191
|
return
|
|
183
|
-
if
|
|
184
|
-
_logger.warning("dataset {} is no more supervised".format(
|
|
185
|
-
|
|
186
|
-
if
|
|
187
|
-
return self._dataset_process_states[process.process_id][
|
|
188
|
-
dataset.short_str()
|
|
189
|
-
][0]
|
|
192
|
+
if dataset_id is None:
|
|
193
|
+
_logger.warning("dataset {} is no more supervised".format(dataset_id))
|
|
194
|
+
elif process.process_id in self._dataset_process_states:
|
|
195
|
+
if dataset_id in self._dataset_process_states[process.process_id]:
|
|
196
|
+
return self._dataset_process_states[process.process_id][dataset_id][0]
|
|
190
197
|
return None
|
|
191
198
|
|
|
192
|
-
def get_dataset_details(self,
|
|
199
|
+
def get_dataset_details(self, dataset_id, process) -> Union[None, str]:
|
|
193
200
|
"""
|
|
194
201
|
|
|
195
|
-
:param Dataset
|
|
202
|
+
:param Dataset dataset_id:
|
|
196
203
|
:param BaseProcess process:
|
|
197
204
|
:return: DatasetState relative to provided process if know
|
|
198
205
|
:rtype: Union[None, DatasetState]
|
|
199
206
|
"""
|
|
200
|
-
|
|
207
|
+
dataset_id = self._find_dataset_id(dataset_id)
|
|
201
208
|
process = self._find_process(process)
|
|
202
209
|
if process is None:
|
|
203
210
|
_logger.warning("process {} is no more supervised".format(process))
|
|
204
211
|
return
|
|
205
|
-
if
|
|
206
|
-
_logger.warning("dataset {} is no more supervised".format(
|
|
212
|
+
if dataset_id is None:
|
|
213
|
+
_logger.warning("dataset {} is no more supervised".format(dataset_id))
|
|
207
214
|
if process.process_id in self._dataset_process_states:
|
|
208
|
-
if
|
|
209
|
-
return self._dataset_process_states[process.process_id][
|
|
210
|
-
dataset.short_str()
|
|
211
|
-
][2]
|
|
215
|
+
if dataset_id in self._dataset_process_states[process.process_id]:
|
|
216
|
+
return self._dataset_process_states[process.process_id][dataset_id][2]
|
|
212
217
|
return None
|
|
213
218
|
|
|
214
|
-
def get_dataset_time_stamp(self,
|
|
219
|
+
def get_dataset_time_stamp(self, dataset_id, process) -> Union[None, str]:
|
|
215
220
|
"""
|
|
216
221
|
|
|
217
|
-
:param Dataset
|
|
222
|
+
:param Dataset dataset_id:
|
|
218
223
|
:param BaseProcess process:
|
|
219
224
|
:return: DatasetState relative to provided process if know
|
|
220
225
|
:rtype: Union[None, DatasetState]
|
|
221
226
|
"""
|
|
222
|
-
|
|
227
|
+
dataset_id = self._find_dataset_id(dataset_id)
|
|
223
228
|
process = self._find_process(process)
|
|
224
229
|
if process is None:
|
|
225
230
|
_logger.warning("process {} is no more supervised".format(process))
|
|
226
231
|
return
|
|
227
|
-
if
|
|
228
|
-
_logger.warning("dataset {} is no more supervised".format(
|
|
232
|
+
if dataset_id is None:
|
|
233
|
+
_logger.warning("dataset {} is no more supervised".format(dataset_id))
|
|
229
234
|
if process.process_id in self._dataset_process_states:
|
|
230
|
-
if
|
|
231
|
-
return self._dataset_process_states[process.process_id][
|
|
232
|
-
dataset.short_str()
|
|
233
|
-
][1]
|
|
235
|
+
if dataset_id in self._dataset_process_states[process.process_id]:
|
|
236
|
+
return self._dataset_process_states[process.process_id][dataset_id][1]
|
|
234
237
|
return None
|
|
235
238
|
|
|
236
239
|
def get_dataset_stream(self, dataset, time_stamp=False) -> tuple:
|
|
@@ -244,8 +247,9 @@ class ProcessManager:
|
|
|
244
247
|
"""
|
|
245
248
|
stream = []
|
|
246
249
|
for process_id, dataset_states in self._dataset_process_states.items():
|
|
247
|
-
|
|
248
|
-
|
|
250
|
+
dst_id = dataset.get_dataset_identifier()
|
|
251
|
+
if dst_id in dataset_states:
|
|
252
|
+
state, _timestamp, _ = dataset_states[dst_id]
|
|
249
253
|
stream.append((process_id, state, _timestamp))
|
|
250
254
|
# order the stream
|
|
251
255
|
stream = sorted(stream, key=lambda elmt: elmt[2])
|
|
@@ -260,7 +264,7 @@ class ProcessManager:
|
|
|
260
264
|
:param BaseProcess process:
|
|
261
265
|
:param bool time_stamp: if True then return timestamp in the list of
|
|
262
266
|
elements
|
|
263
|
-
:return: tuple of (
|
|
267
|
+
:return: tuple of (DatasetIdentifier, state, [timestamp])
|
|
264
268
|
:rtype: tuple
|
|
265
269
|
"""
|
|
266
270
|
history = []
|
|
Binary file
|
|
@@ -33,6 +33,7 @@ from processview.core.superviseprocess import SuperviseProcess
|
|
|
33
33
|
from processview.core.manager import ProcessManager
|
|
34
34
|
from processview.core.manager import DatasetState
|
|
35
35
|
from processview.core.dataset import Dataset
|
|
36
|
+
from processview.core.dataset import DatasetIdentifier
|
|
36
37
|
import gc
|
|
37
38
|
|
|
38
39
|
|
|
@@ -81,10 +82,11 @@ class TestProcessManager(unittest.TestCase):
|
|
|
81
82
|
)
|
|
82
83
|
# test 'getScanState'
|
|
83
84
|
self.assertEqual(
|
|
84
|
-
manager.get_dataset_state(
|
|
85
|
+
manager.get_dataset_state(dataset_id=scan_2, process=p2),
|
|
86
|
+
DatasetState.FAILED,
|
|
85
87
|
)
|
|
86
88
|
|
|
87
|
-
self.assertEqual(manager.get_dataset_state(
|
|
89
|
+
self.assertEqual(manager.get_dataset_state(dataset_id=scan_1, process=p2), None)
|
|
88
90
|
|
|
89
91
|
# test 'getScanStream'
|
|
90
92
|
self.assertEqual(
|
|
@@ -98,7 +100,10 @@ class TestProcessManager(unittest.TestCase):
|
|
|
98
100
|
# test 'getProcessHistory'
|
|
99
101
|
self.assertEqual(
|
|
100
102
|
manager.get_process_history(process=p1),
|
|
101
|
-
(
|
|
103
|
+
(
|
|
104
|
+
(scan_1.get_dataset_identifier(), DatasetState.PENDING),
|
|
105
|
+
(scan_2.get_dataset_identifier(), DatasetState.SUCCEED),
|
|
106
|
+
),
|
|
102
107
|
)
|
|
103
108
|
|
|
104
109
|
|
|
@@ -110,9 +115,24 @@ class _DummyScan(Dataset):
|
|
|
110
115
|
def __str__(self) -> str:
|
|
111
116
|
return self.name
|
|
112
117
|
|
|
113
|
-
def
|
|
118
|
+
def get_dataset_identifier(self) -> DatasetIdentifier:
|
|
119
|
+
return _DummyIdentifier(self)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class _DummyIdentifier(DatasetIdentifier):
|
|
123
|
+
def __init__(self, dataset):
|
|
124
|
+
super().__init__(dataset)
|
|
125
|
+
self.name = dataset.name
|
|
126
|
+
|
|
127
|
+
def __str__(self):
|
|
114
128
|
return self.name
|
|
115
129
|
|
|
130
|
+
def __eq__(self, other):
|
|
131
|
+
return self.name == other.name
|
|
132
|
+
|
|
133
|
+
def __hash__(self):
|
|
134
|
+
return hash(self.name)
|
|
135
|
+
|
|
116
136
|
|
|
117
137
|
def suite():
|
|
118
138
|
test_suite = unittest.TestSuite()
|
|
@@ -63,6 +63,9 @@ class SuperviseProcess:
|
|
|
63
63
|
|
|
64
64
|
def __init__(self, name=None, process_id=None):
|
|
65
65
|
self._name = name
|
|
66
|
+
self._is_master_process = process_id is None
|
|
67
|
+
"""is this process the master process of the SuperviseProcess. Or is
|
|
68
|
+
it just one of the underlying process of a master SuperviseProcess"""
|
|
66
69
|
if process_id is None:
|
|
67
70
|
ProcessManager().register(self)
|
|
68
71
|
else:
|
|
@@ -71,6 +74,10 @@ class SuperviseProcess:
|
|
|
71
74
|
def __del__(self):
|
|
72
75
|
ProcessManager().unregister(self)
|
|
73
76
|
|
|
77
|
+
@property
|
|
78
|
+
def is_master_process(self):
|
|
79
|
+
return self._is_master_process
|
|
80
|
+
|
|
74
81
|
@property
|
|
75
82
|
def process_id(self):
|
|
76
83
|
return self.__process_id
|
|
@@ -114,3 +121,11 @@ class SuperviseProcess:
|
|
|
114
121
|
ProcessManager().notify_dataset_state(
|
|
115
122
|
dataset=dataset, state=state, process=self, details=details
|
|
116
123
|
)
|
|
124
|
+
|
|
125
|
+
def reprocess(self, dataset):
|
|
126
|
+
"""
|
|
127
|
+
Reprocess a dataset.
|
|
128
|
+
|
|
129
|
+
:param Dataset: dataset to reprocess
|
|
130
|
+
"""
|
|
131
|
+
raise NotImplementedError("Base class")
|