Skip to content

Commit 50e0746

Browse files
Merge pull request #211 from simonsobs/koopman/smurf-stream-kwargs
Pass additional kwargs through to SMuRF stream process
2 parents fdd78f1 + 8a49766 commit 50e0746

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

src/sorunlib/smurf.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,23 +346,20 @@ def shutdown(concurrent=True, settling_time=0):
346346
settling_time=settling_time)
347347

348348

349-
def stream(state, tag=None, subtype=None, downsample_factor=None, filter_disable=False):
349+
def stream(state, tag=None, subtype=None, **kwargs):
350350
"""Stream data on all SMuRF Controllers.
351351
352352
Args:
353353
state (str): Streaming state, either 'on' or 'off'.
354354
tag (str, optional): Tag or comma-separated listed of tags to attach to
355355
the operation.
356356
subtype (str, optional): Operation subtype used to tag the stream.
357-
downsample_factor (int, optional): Downsample factor. If None, this will be
358-
pulled from the device cfg.
359-
filter_disable (bool, optional): If true, will disable the downsample filter
360-
before streaming.
357+
**kwargs: Additional keyword arguments. Passed through to the SMuRF
358+
controller unmodified. See the `controller documentation
359+
<https://socs.readthedocs.io/en/main/agents/pysmurf-controller.html#socs.agents.pysmurf_controller.agent.PysmurfController.stream>`_.
361360
362361
"""
363362
clients_to_remove = []
364-
kwargs = {'downsample_factor': downsample_factor,
365-
'filter_disable': filter_disable}
366363

367364
if state.lower() == 'on':
368365
for smurf in run.CLIENTS['smurf']:

tests/test_smurf.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,20 @@ def test_stream(state):
170170
client.stream.stop.assert_called_once()
171171

172172

173+
@pytest.mark.parametrize("state", [("on"), ("off")])
174+
def test_stream_w_kwargs(state):
175+
smurf.stream(state=state, tag='test', subtype='test',
176+
downsample_factor=20, filter_disable=False)
177+
for client in smurf.run.CLIENTS['smurf']:
178+
if state == "on":
179+
client.stream.start.assert_called_once_with(tag='test',
180+
subtype='test',
181+
kwargs={'downsample_factor': 20,
182+
'filter_disable': False})
183+
else:
184+
client.stream.stop.assert_called_once()
185+
186+
173187
@pytest.mark.parametrize("state", [("on"), ("off")])
174188
def test_stream_single_failure(state):
175189
# Create failure on smurf1

tests/test_wiregrid.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,7 @@ def test_calibrate_stepwise(patch_clients, continuous, el, tag):
262262
client.stream.start.assert_called_with(
263263
tag=tag,
264264
subtype='cal',
265-
kwargs={
266-
"downsample_factor": None,
267-
"filter_disable": False},
265+
kwargs={},
268266
)
269267
client.stream.stop.assert_called()
270268

@@ -317,10 +315,6 @@ def test_time_constant_cw():
317315
call(tag='wiregrid, wg_time_constant, wg_ejected, hwp_ccw')
318316
]
319317

320-
common_kwargs_of_streams = {
321-
"downsample_factor": None,
322-
"filter_disable": False
323-
}
324318
expected_tags_of_streams = [
325319
'wiregrid, wg_time_constant, wg_inserting, hwp_cw',
326320
'wiregrid, wg_time_constant, wg_stepwise, hwp_cw',
@@ -330,7 +324,7 @@ def test_time_constant_cw():
330324
'wiregrid, wg_time_constant, wg_ejecting, hwp_ccw'
331325
]
332326
expected_calls_of_streams = [
333-
call(tag=stream_tag, subtype='cal', kwargs=common_kwargs_of_streams)
327+
call(tag=stream_tag, subtype='cal', kwargs={})
334328
for stream_tag in expected_tags_of_streams
335329
]
336330

@@ -366,10 +360,6 @@ def test_time_constant_ccw_el90():
366360
call(tag='wiregrid, wg_time_constant, wg_ejected, hwp_cw, wg_el90')
367361
]
368362

369-
common_kwargs_of_streams = {
370-
"downsample_factor": None,
371-
"filter_disable": False
372-
}
373363
expected_tags_of_streams = [
374364
'wiregrid, wg_time_constant, wg_inserting, hwp_ccw, wg_el90',
375365
'wiregrid, wg_time_constant, wg_stepwise, hwp_ccw, wg_el90',
@@ -379,7 +369,7 @@ def test_time_constant_ccw_el90():
379369
'wiregrid, wg_time_constant, wg_ejecting, hwp_cw, wg_el90'
380370
]
381371
expected_calls_of_streams = [
382-
call(tag=stream_tag, subtype='cal', kwargs=common_kwargs_of_streams)
372+
call(tag=stream_tag, subtype='cal', kwargs={})
383373
for stream_tag in expected_tags_of_streams
384374
]
385375

@@ -416,10 +406,6 @@ def test_time_constant_repeats():
416406
call(tag='wiregrid, wg_time_constant, wg_ejected, hwp_cw')
417407
]
418408

419-
common_kwargs_of_streams = {
420-
"downsample_factor": None,
421-
"filter_disable": False
422-
}
423409
expected_tags_of_streams = [
424410
'wiregrid, wg_time_constant, wg_inserting, hwp_cw',
425411
'wiregrid, wg_time_constant, wg_stepwise, hwp_cw',
@@ -432,7 +418,7 @@ def test_time_constant_repeats():
432418
'wiregrid, wg_time_constant, wg_ejecting, hwp_cw'
433419
]
434420
expected_calls_of_streams = [
435-
call(tag=stream_tag, subtype='cal', kwargs=common_kwargs_of_streams)
421+
call(tag=stream_tag, subtype='cal', kwargs={})
436422
for stream_tag in expected_tags_of_streams
437423
]
438424

0 commit comments

Comments
 (0)