Skip to content

Commit 9d92d19

Browse files
authored
Merge pull request #865 from genematx/move-tiled-writer
MNT: move TiledWriter from bluesky
2 parents ccc9332 + 9a8a03e commit 9d92d19

File tree

11 files changed

+3355
-1
lines changed

11 files changed

+3355
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
from .bluesky_event_stream import BlueskyEventStream # noqa: F401
22
from .bluesky_run import BlueskyRun # noqa: F401
33
from .catalog_of_bluesky_runs import CatalogOfBlueskyRuns # noqa: F401
4+
from .tiled_writer import TiledWriter # noqa: F401
5+
6+
__all__ = [
7+
"BlueskyEventStream",
8+
"BlueskyRun",
9+
"CatalogOfBlueskyRuns",
10+
"TiledWriter",
11+
]

bluesky-tiled-plugins/bluesky_tiled_plugins/consolidators.py

Lines changed: 528 additions & 0 deletions
Large diffs are not rendered by default.

bluesky-tiled-plugins/bluesky_tiled_plugins/tiled_writer.py

Lines changed: 848 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import asyncio
2+
3+
import pytest
4+
from bluesky.run_engine import RunEngine, TransitionError
5+
6+
7+
@pytest.fixture(scope="function", params=[False, True])
8+
def RE(request):
9+
loop = asyncio.new_event_loop()
10+
loop.set_debug(True)
11+
RE = RunEngine({}, call_returns_result=request.param, loop=loop)
12+
13+
def clean_event_loop():
14+
if RE.state not in ("idle", "panicked"):
15+
try:
16+
RE.halt()
17+
except TransitionError:
18+
pass
19+
loop.call_soon_threadsafe(loop.stop)
20+
RE._th.join()
21+
loop.close()
22+
23+
request.addfinalizer(clean_event_loop)
24+
return RE
Lines changed: 346 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
[
2+
{
3+
"name": "start",
4+
"doc": {
5+
"uid": "{{ uuid }}-9724b2201fe7",
6+
"time": 1745500521.706236,
7+
"scan_id": 3,
8+
"plan_type": "generator",
9+
"plan_name": "count",
10+
"detectors": [
11+
"det-obj1",
12+
"det-obj2"
13+
]
14+
}
15+
},
16+
{
17+
"name": "descriptor",
18+
"doc": {
19+
"configuration": {
20+
"det-obj1": {
21+
"data": {},
22+
"timestamps": {},
23+
"data_keys": {}
24+
}
25+
},
26+
"data_keys": {
27+
"det-key1": {
28+
"source": "file",
29+
"dtype": "number",
30+
"dtype_numpy": "<f8",
31+
"shape": [
32+
1
33+
],
34+
"external": "STREAM:",
35+
"object_name": "det-obj1"
36+
},
37+
"det-key2": {
38+
"source": "file",
39+
"dtype": "array",
40+
"dtype_numpy": "<i8",
41+
"shape": [
42+
1,
43+
13,
44+
17
45+
],
46+
"external": "STREAM:",
47+
"object_name": "det-obj1"
48+
}
49+
},
50+
"name": "primary",
51+
"object_keys": {
52+
"det-obj1": [
53+
"det-key1",
54+
"det-key2"
55+
]
56+
},
57+
"run_start": "{{ uuid }}-9724b2201fe7",
58+
"time": 1745500521.79327,
59+
"uid": "{{ uuid }}-descriptor01",
60+
"hints": {}
61+
}
62+
},
63+
{
64+
"name": "stream_resource",
65+
"doc": {
66+
"parameters": {
67+
"dataset": "/entry/data/data_1",
68+
"chunk_shape": [
69+
100
70+
]
71+
},
72+
"data_key": "det-key1",
73+
"uri": "file://localhost/{{ root_path }}/dataset.h5",
74+
"mimetype": "application/x-hdf5",
75+
"uid": "det-key1-uid",
76+
"run_start": "{{ uuid }}-9724b2201fe7"
77+
}
78+
},
79+
{
80+
"name": "stream_datum",
81+
"doc": {
82+
"stream_resource": "det-key1-uid",
83+
"descriptor": "{{ uuid }}-descriptor01",
84+
"uid": "det-key1-uid/0",
85+
"indices": {
86+
"start": 0,
87+
"stop": 1
88+
},
89+
"seq_nums": {
90+
"start": 1,
91+
"stop": 2
92+
}
93+
}
94+
},
95+
{
96+
"name": "stream_resource",
97+
"doc": {
98+
"parameters": {
99+
"dataset": "/entry/data/data_2",
100+
"chunk_shape": [
101+
100,
102+
13,
103+
17
104+
]
105+
},
106+
"data_key": "det-key2",
107+
"uri": "file://localhost/{{ root_path }}/dataset.h5",
108+
"mimetype": "application/x-hdf5",
109+
"uid": "det-key2-uid",
110+
"run_start": "{{ uuid }}-9724b2201fe7"
111+
}
112+
},
113+
{
114+
"name": "stream_datum",
115+
"doc": {
116+
"stream_resource": "det-key2-uid",
117+
"descriptor": "{{ uuid }}-descriptor01",
118+
"uid": "det-key2-uid/0",
119+
"indices": {
120+
"start": 0,
121+
"stop": 1
122+
},
123+
"seq_nums": {
124+
"start": 1,
125+
"stop": 2
126+
}
127+
}
128+
},
129+
{
130+
"name": "descriptor",
131+
"doc": {
132+
"configuration": {
133+
"det-obj2": {
134+
"data": {},
135+
"timestamps": {},
136+
"data_keys": {}
137+
}
138+
},
139+
"data_keys": {
140+
"det-key3": {
141+
"source": "file",
142+
"dtype": "array",
143+
"dtype_numpy": "|u1",
144+
"shape": [
145+
1,
146+
10,
147+
15
148+
],
149+
"external": "STREAM:",
150+
"object_name": "det-obj2"
151+
}
152+
},
153+
"name": "secondary",
154+
"object_keys": {
155+
"det-obj2": [
156+
"det-key3"
157+
]
158+
},
159+
"run_start": "{{ uuid }}-9724b2201fe7",
160+
"time": 1745500521.79337,
161+
"uid": "{{ uuid }}-descriptor02",
162+
"hints": {}
163+
}
164+
},
165+
{
166+
"name": "stream_resource",
167+
"doc": {
168+
"parameters": {
169+
"chunk_shape": [
170+
1,
171+
10,
172+
15
173+
],
174+
"template": "img_{:05d}.tif",
175+
"join_method": "stack"
176+
},
177+
"data_key": "det-key3",
178+
"uri": "file://localhost/{{ root_path }}/tiff_files/",
179+
"mimetype": "multipart/related;type=image/tiff",
180+
"uid": "det-key3-uid",
181+
"run_start": "{{ uuid }}-9724b2201fe7"
182+
}
183+
},
184+
{
185+
"name": "stream_datum",
186+
"doc": {
187+
"stream_resource": "det-key3-uid",
188+
"descriptor": "{{ uuid }}-descriptor02",
189+
"uid": "det-key3-uid/0",
190+
"indices": {
191+
"start": 0,
192+
"stop": 1
193+
},
194+
"seq_nums": {
195+
"start": 1,
196+
"stop": 2
197+
}
198+
}
199+
},
200+
{
201+
"name": "event",
202+
"doc": {
203+
"uid": "{{ uuid }}-fccee75c4049",
204+
"time": 1745500522.3483489,
205+
"data": {},
206+
"timestamps": {},
207+
"seq_num": 1,
208+
"filled": {},
209+
"descriptor": "{{ uuid }}-descriptor01"
210+
}
211+
},
212+
{
213+
"name": "stream_datum",
214+
"doc": {
215+
"stream_resource": "det-key1-uid",
216+
"descriptor": "{{ uuid }}-descriptor01",
217+
"uid": "det-key1-uid/1",
218+
"indices": {
219+
"start": 1,
220+
"stop": 2
221+
},
222+
"seq_nums": {
223+
"start": 2,
224+
"stop": 3
225+
}
226+
}
227+
},
228+
{
229+
"name": "stream_datum",
230+
"doc": {
231+
"stream_resource": "det-key2-uid",
232+
"descriptor": "{{ uuid }}-descriptor01",
233+
"uid": "det-key2-uid/1",
234+
"indices": {
235+
"start": 1,
236+
"stop": 2
237+
},
238+
"seq_nums": {
239+
"start": 2,
240+
"stop": 3
241+
}
242+
}
243+
},
244+
{
245+
"name": "stream_datum",
246+
"doc": {
247+
"stream_resource": "det-key3-uid",
248+
"descriptor": "{{ uuid }}-descriptor02",
249+
"uid": "det-key3-uid/1",
250+
"indices": {
251+
"start": 1,
252+
"stop": 2
253+
},
254+
"seq_nums": {
255+
"start": 2,
256+
"stop": 3
257+
}
258+
}
259+
},
260+
{
261+
"name": "event",
262+
"doc": {
263+
"uid": "{{ uuid }}-a889843f30fc",
264+
"time": 1745500522.548436,
265+
"data": {},
266+
"timestamps": {},
267+
"seq_num": 2,
268+
"filled": {},
269+
"descriptor": "{{ uuid }}-descriptor01"
270+
}
271+
},
272+
{
273+
"name": "stream_datum",
274+
"doc": {
275+
"stream_resource": "det-key1-uid",
276+
"descriptor": "{{ uuid }}-descriptor01",
277+
"uid": "det-key1-uid/2",
278+
"indices": {
279+
"start": 2,
280+
"stop": 3
281+
},
282+
"seq_nums": {
283+
"start": 3,
284+
"stop": 4
285+
}
286+
}
287+
},
288+
{
289+
"name": "stream_datum",
290+
"doc": {
291+
"stream_resource": "det-key2-uid",
292+
"descriptor": "{{ uuid }}-descriptor01",
293+
"uid": "det-key2-uid/2",
294+
"indices": {
295+
"start": 2,
296+
"stop": 3
297+
},
298+
"seq_nums": {
299+
"start": 3,
300+
"stop": 4
301+
}
302+
}
303+
},
304+
{
305+
"name": "stream_datum",
306+
"doc": {
307+
"stream_resource": "det-key3-uid",
308+
"descriptor": "{{ uuid }}-descriptor02",
309+
"uid": "det-key3-uid/2",
310+
"indices": {
311+
"start": 2,
312+
"stop": 3
313+
},
314+
"seq_nums": {
315+
"start": 3,
316+
"stop": 4
317+
}
318+
}
319+
},
320+
{
321+
"name": "event",
322+
"doc": {
323+
"uid": "{{ uuid }}-6707fc155dd0",
324+
"time": 1745500522.77075,
325+
"data": {},
326+
"timestamps": {},
327+
"seq_num": 3,
328+
"filled": {},
329+
"descriptor": "{{ uuid }}-descriptor01"
330+
}
331+
},
332+
{
333+
"name": "stop",
334+
"doc": {
335+
"uid": "{{ uuid }}-fe2748f474de",
336+
"time": 1745500522.771699,
337+
"run_start": "{{ uuid }}-9724b2201fe7",
338+
"exit_status": "success",
339+
"reason": "",
340+
"num_events": {
341+
"primary": 3,
342+
"secondary": 0
343+
}
344+
}
345+
}
346+
]

0 commit comments

Comments
 (0)