mccode-plumber 0.6.0__py3-none-any.whl → 0.7.0__py3-none-any.whl
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.
- mccode_plumber/file_writer_control/CommandChannel.py +236 -0
- mccode_plumber/file_writer_control/CommandHandler.py +58 -0
- mccode_plumber/file_writer_control/CommandStatus.py +151 -0
- mccode_plumber/file_writer_control/InThreadStatusTracker.py +228 -0
- mccode_plumber/file_writer_control/JobHandler.py +102 -0
- mccode_plumber/file_writer_control/JobStatus.py +147 -0
- mccode_plumber/file_writer_control/KafkaTopicUrl.py +22 -0
- mccode_plumber/file_writer_control/StateExtractor.py +58 -0
- mccode_plumber/file_writer_control/WorkerFinder.py +139 -0
- mccode_plumber/file_writer_control/WorkerJobPool.py +70 -0
- mccode_plumber/file_writer_control/WorkerStatus.py +88 -0
- mccode_plumber/file_writer_control/WriteJob.py +83 -0
- mccode_plumber/file_writer_control/__init__.py +13 -0
- mccode_plumber/writer.py +3 -3
- {mccode_plumber-0.6.0.dist-info → mccode_plumber-0.7.0.dist-info}/METADATA +3 -2
- mccode_plumber-0.7.0.dist-info/RECORD +27 -0
- mccode_plumber-0.6.0.dist-info/RECORD +0 -14
- {mccode_plumber-0.6.0.dist-info → mccode_plumber-0.7.0.dist-info}/WHEEL +0 -0
- {mccode_plumber-0.6.0.dist-info → mccode_plumber-0.7.0.dist-info}/entry_points.txt +0 -0
- {mccode_plumber-0.6.0.dist-info → mccode_plumber-0.7.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import uuid
|
|
2
|
+
from datetime import datetime, timedelta
|
|
3
|
+
|
|
4
|
+
from streaming_data_types import serialise_pl72
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class WriteJob:
|
|
8
|
+
"""
|
|
9
|
+
Represents a file-writer write job (before it has been started).
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
nexus_structure: str,
|
|
15
|
+
file_name: str,
|
|
16
|
+
broker: str,
|
|
17
|
+
start_time: datetime,
|
|
18
|
+
stop_time: datetime = None,
|
|
19
|
+
job_id="",
|
|
20
|
+
instrument_name: str = "",
|
|
21
|
+
run_name: str = "",
|
|
22
|
+
metadata: str = "",
|
|
23
|
+
control_topic: str = "",
|
|
24
|
+
):
|
|
25
|
+
self.structure = nexus_structure
|
|
26
|
+
self.file = file_name
|
|
27
|
+
if job_id:
|
|
28
|
+
try:
|
|
29
|
+
uuid.UUID(job_id)
|
|
30
|
+
self.job_id = job_id
|
|
31
|
+
except ValueError as e:
|
|
32
|
+
raise RuntimeError("Job ID should be a valid UUID (v1).") from e
|
|
33
|
+
else:
|
|
34
|
+
self.job_id = str(uuid.uuid1())
|
|
35
|
+
self.start = start_time
|
|
36
|
+
if stop_time is None:
|
|
37
|
+
self.stop = self.start + timedelta(days=365.25 * 10)
|
|
38
|
+
else:
|
|
39
|
+
self.stop = stop_time
|
|
40
|
+
self._service_id = ""
|
|
41
|
+
self.broker = broker
|
|
42
|
+
self.instrument_name = instrument_name
|
|
43
|
+
self.run_name = run_name
|
|
44
|
+
self.metadata = metadata
|
|
45
|
+
self.control_topic = control_topic
|
|
46
|
+
|
|
47
|
+
def generate_new_job_id(self):
|
|
48
|
+
"""
|
|
49
|
+
Generate a new job id. Should be called if an attempt at starting this write job fails and another attempt is made.
|
|
50
|
+
"""
|
|
51
|
+
self.job_id = str(uuid.uuid1())
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def service_id(self) -> str:
|
|
55
|
+
"""
|
|
56
|
+
The service identifier that should process this job. Defaults to an empty string.
|
|
57
|
+
.. note:: Must be set if job is to be processed by a specific file-writer instance.
|
|
58
|
+
"""
|
|
59
|
+
return self._service_id
|
|
60
|
+
|
|
61
|
+
@service_id.setter
|
|
62
|
+
def service_id(self, new_service_id: str):
|
|
63
|
+
self._service_id = new_service_id
|
|
64
|
+
|
|
65
|
+
def get_start_message(self) -> bytes:
|
|
66
|
+
"""
|
|
67
|
+
Generate the (flatbuffer) start message that will start this job. If you are sending the message to a specific
|
|
68
|
+
file-writer instance, you have to set the service_id property first or the message will fail to start the job.
|
|
69
|
+
:return: A flatbuffer message that holds the necessary information for starting a write job.
|
|
70
|
+
"""
|
|
71
|
+
return serialise_pl72(
|
|
72
|
+
self.job_id,
|
|
73
|
+
self.file,
|
|
74
|
+
self.start,
|
|
75
|
+
self.stop,
|
|
76
|
+
nexus_structure=self.structure,
|
|
77
|
+
service_id=self.service_id,
|
|
78
|
+
broker=self.broker,
|
|
79
|
+
instrument_name=self.instrument_name,
|
|
80
|
+
run_name=self.run_name,
|
|
81
|
+
metadata=self.metadata,
|
|
82
|
+
control_topic=self.control_topic,
|
|
83
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from .CommandStatus import CommandState
|
|
2
|
+
from .JobHandler import JobHandler
|
|
3
|
+
from .JobStatus import JobState
|
|
4
|
+
from .WorkerJobPool import WorkerJobPool
|
|
5
|
+
from .WriteJob import WriteJob
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"JobHandler",
|
|
9
|
+
"WorkerJobPool",
|
|
10
|
+
"WriteJob",
|
|
11
|
+
"CommandState",
|
|
12
|
+
"JobState",
|
|
13
|
+
]
|
mccode_plumber/writer.py
CHANGED
|
@@ -138,7 +138,7 @@ def insert_events_in_nexus_structure(ns: dict, config: dict):
|
|
|
138
138
|
|
|
139
139
|
|
|
140
140
|
def get_writer_pool(broker: str = None, job: str = None, command: str = None):
|
|
141
|
-
from file_writer_control import WorkerJobPool
|
|
141
|
+
from .file_writer_control import WorkerJobPool
|
|
142
142
|
pool = WorkerJobPool(f"{broker}/{job}", f"{broker}/{command}")
|
|
143
143
|
return pool
|
|
144
144
|
|
|
@@ -175,7 +175,7 @@ def start_pool_writer(start_time_string, structure, filename=None, stop_time_str
|
|
|
175
175
|
from time import sleep
|
|
176
176
|
from json import dumps
|
|
177
177
|
from datetime import datetime, timedelta
|
|
178
|
-
from file_writer_control import JobHandler, WriteJob, CommandState
|
|
178
|
+
from .file_writer_control import JobHandler, WriteJob, CommandState
|
|
179
179
|
|
|
180
180
|
start_time = datetime.fromisoformat(start_time_string)
|
|
181
181
|
if filename is None:
|
|
@@ -301,7 +301,7 @@ def wait_on_writer():
|
|
|
301
301
|
from os import EX_OK, EX_UNAVAILABLE
|
|
302
302
|
from time import sleep
|
|
303
303
|
from datetime import datetime, timedelta
|
|
304
|
-
from file_writer_control import JobHandler, CommandState
|
|
304
|
+
from .file_writer_control import JobHandler, CommandState
|
|
305
305
|
|
|
306
306
|
from argparse import ArgumentParser
|
|
307
307
|
parser = ArgumentParser()
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mccode-plumber
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Author-email: Gregory Tucker <gregory.tucker@ess.eu>
|
|
5
5
|
Classifier: License :: OSI Approved :: BSD License
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
7
7
|
Requires-Dist: p4p
|
|
8
|
-
Requires-Dist:
|
|
8
|
+
Requires-Dist: kafka-python>=2.0
|
|
9
|
+
Requires-Dist: ess-streaming-data-types>=0.14.0
|
|
9
10
|
Requires-Dist: restage>=0.4.0
|
|
10
11
|
Requires-Dist: mccode-to-kafka>=0.2.1
|
|
11
12
|
Requires-Dist: moreniius>=0.2.3
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
mccode_plumber/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
mccode_plumber/conductor.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
mccode_plumber/epics.py,sha256=THzech5V1UCLIN9u1r3GiEKxUVCDkYVXhfOQV71aQn4,3989
|
|
4
|
+
mccode_plumber/forwarder.py,sha256=1PdW91qLksDnA41-gOFMtgSae4wDdSLVvgAlrF23Uks,3764
|
|
5
|
+
mccode_plumber/kafka.py,sha256=8fHTy2Zzk638XXj29pfrk-7fUxafuse9OYWmaRgvV7M,1195
|
|
6
|
+
mccode_plumber/mccode.py,sha256=WXlu89Cs6a3s0aKtfRGuzqcOWoFZtdZWibLgBQnaXCI,2210
|
|
7
|
+
mccode_plumber/splitrun.py,sha256=MsR1cUvoayQGNCJNl5fIPG92Wfcy9V_8QNO_ITQTvtA,1295
|
|
8
|
+
mccode_plumber/utils.py,sha256=E8NoGo_3Z-pPEpzicVGSWfQOX8p3eR-GxElT33-kX5U,2167
|
|
9
|
+
mccode_plumber/writer.py,sha256=TSWw7Q1mlXcwOx4OuvNGN-yyB_X10Vmt1KywA79RmBs,16359
|
|
10
|
+
mccode_plumber/file_writer_control/CommandChannel.py,sha256=rrQxmQ6VJsl9OC5n45XkL3g7MXtICT_8tsv_xuGdIKI,9119
|
|
11
|
+
mccode_plumber/file_writer_control/CommandHandler.py,sha256=ETPGNiD3umt2XazCWztoaO6qgtilBzrB1N1EH5EAKUw,2245
|
|
12
|
+
mccode_plumber/file_writer_control/CommandStatus.py,sha256=biNK58vY1H-USYAl9uB_JNQyMohBj1cwJwmXktndd4E,4517
|
|
13
|
+
mccode_plumber/file_writer_control/InThreadStatusTracker.py,sha256=sLb8v1JBs3QSWXu-_kIznku3h_ZqVNwx0o9-RoxaKu4,10196
|
|
14
|
+
mccode_plumber/file_writer_control/JobHandler.py,sha256=H6fr0O6lcGw4EKRUuR9Ak4gk5Rknozru0PGaNxNITeg,4296
|
|
15
|
+
mccode_plumber/file_writer_control/JobStatus.py,sha256=ncLYEcTAOdrIASQvY0jJAX3fC4qF9tyzLavm5YUOhlQ,4416
|
|
16
|
+
mccode_plumber/file_writer_control/KafkaTopicUrl.py,sha256=dG6Aj2tYo1UGZferxyvURUAr77z9dhBN_SRzizzt1Vo,736
|
|
17
|
+
mccode_plumber/file_writer_control/StateExtractor.py,sha256=FaroeEuZCGTIi7kEIxeS7QHjnD7CxU1ONvKRQqRCmrc,2068
|
|
18
|
+
mccode_plumber/file_writer_control/WorkerFinder.py,sha256=vMv-_YQSdchGDo5TAHQfJODWsatjCyCbLiCwtJJGZi4,6093
|
|
19
|
+
mccode_plumber/file_writer_control/WorkerJobPool.py,sha256=2P6qYNgRtcolSO910a2BejoZyJf4H2ZiSfsVgYzwq8g,2966
|
|
20
|
+
mccode_plumber/file_writer_control/WorkerStatus.py,sha256=uw1q-Pvf1o2hxpMIPVwdtnAXLcO7VeEpcZ3wKjxxdsk,2826
|
|
21
|
+
mccode_plumber/file_writer_control/WriteJob.py,sha256=-2tQvfajctf6Bn19c9hT9N1lOP0uTo7SZRMnXV1A-aA,2721
|
|
22
|
+
mccode_plumber/file_writer_control/__init__.py,sha256=Wp8A7JOB0vgpwAbvI9ik5cBlZa6lY-cq8dxYGRTRs0M,285
|
|
23
|
+
mccode_plumber-0.7.0.dist-info/METADATA,sha256=4_DYv6ndynDY98_6zuO9aaC7e4fnaJ5JEHDz0Lsgjrs,552
|
|
24
|
+
mccode_plumber-0.7.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
25
|
+
mccode_plumber-0.7.0.dist-info/entry_points.txt,sha256=V-ULMAQo7W1O3CLd39iSJcRWNjx9p4OuzEC_8y3T-Zs,520
|
|
26
|
+
mccode_plumber-0.7.0.dist-info/top_level.txt,sha256=kCCIpYtKHCKWxiPEqX9J1UaGEm-ze0Qb-cemBCEPhDA,15
|
|
27
|
+
mccode_plumber-0.7.0.dist-info/RECORD,,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
mccode_plumber/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
mccode_plumber/conductor.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
mccode_plumber/epics.py,sha256=THzech5V1UCLIN9u1r3GiEKxUVCDkYVXhfOQV71aQn4,3989
|
|
4
|
-
mccode_plumber/forwarder.py,sha256=1PdW91qLksDnA41-gOFMtgSae4wDdSLVvgAlrF23Uks,3764
|
|
5
|
-
mccode_plumber/kafka.py,sha256=8fHTy2Zzk638XXj29pfrk-7fUxafuse9OYWmaRgvV7M,1195
|
|
6
|
-
mccode_plumber/mccode.py,sha256=WXlu89Cs6a3s0aKtfRGuzqcOWoFZtdZWibLgBQnaXCI,2210
|
|
7
|
-
mccode_plumber/splitrun.py,sha256=MsR1cUvoayQGNCJNl5fIPG92Wfcy9V_8QNO_ITQTvtA,1295
|
|
8
|
-
mccode_plumber/utils.py,sha256=E8NoGo_3Z-pPEpzicVGSWfQOX8p3eR-GxElT33-kX5U,2167
|
|
9
|
-
mccode_plumber/writer.py,sha256=-gdh6fyOtr6mBhm5AZOs4x2D-bo4_zRSgGkNk-X0ez8,16356
|
|
10
|
-
mccode_plumber-0.6.0.dist-info/METADATA,sha256=7NnOPT9uLE_ogTmdR3pSx0-L3T1oUNj9j4cep7pT4LU,513
|
|
11
|
-
mccode_plumber-0.6.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
12
|
-
mccode_plumber-0.6.0.dist-info/entry_points.txt,sha256=V-ULMAQo7W1O3CLd39iSJcRWNjx9p4OuzEC_8y3T-Zs,520
|
|
13
|
-
mccode_plumber-0.6.0.dist-info/top_level.txt,sha256=kCCIpYtKHCKWxiPEqX9J1UaGEm-ze0Qb-cemBCEPhDA,15
|
|
14
|
-
mccode_plumber-0.6.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|