Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue creating SMuRF controller client list for single controllers #155

Merged
merged 2 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/sorunlib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,12 @@ def create_clients(config=None, sorunlib_config=None, test_mode=False):
hwp_client = _try_client(hwp_id)
clients['hwp'] = hwp_client

# Always create smurf client list, even if empty
smurf_clients = [_try_client(x) for x in smurf_ids]
if isinstance(smurf_ids, str):
# when only a single SMuRF controller online
smurf_clients = [smurf_ids]
else:
# create smurf client list, even if empty
smurf_clients = [_try_client(x) for x in smurf_ids]
clients['smurf'] = smurf_clients

clients['wiregrid'] = _create_wiregrid_clients(
Expand Down
33 changes: 32 additions & 1 deletion tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,33 @@ def mock_client(*args, **kwargs):
'stop_and_clear': 1},
'agent_class': 'ACUAgent',
'agent_address': 'observatory.acu-sat1'}}}

mock_registry_client = create_mock_ocsclient(reg_session)

reg_session_single_smurf = {'session_id': 0,
'op_name': 'main',
'op_code': 3,
'status': 'running',
'success': None,
'start_time': 1669919099.7585046,
'end_time': None,
'data': {
'observatory.smurf-file-emulator-5': {
'expired': False,
'time_expired': None,
'last_updated': 1669935108.8366735,
'op_codes': {
'uxm_setup': 1,
'uxm_relock': 1,
'take_iv': 1,
'take_bias_steps': 1,
'take_bgmap': 1,
'bias_dets': 1,
'take_noise': 1,
'stream': 1},
'agent_class': 'SmurfFileEmulator',
'agent_address': 'observatory.smurf-file-emulator-5'}}}
mock_registry_client_single_smurf = create_mock_ocsclient(reg_session_single_smurf)


class NoAgentClient:
def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -187,6 +211,13 @@ def test_create_clients_test_mode():
assert 'wiregrid' in clients


@patch('sorunlib.util.OCSClient', mock_registry_client_single_smurf)
def test_create_clients_test_mode_single_smurf():
clients = util.create_clients(test_mode=True)
assert 'smurf' in clients
assert len(clients['smurf']) == 1


@patch('sorunlib.util.OCSClient', mock_registry_client)
def test__create_clients_minimal_config():
clients = util.create_clients(sorunlib_config='./data/minimal_config.yaml')
Expand Down