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

Return no results if CPU and GPU agree on no results #819

Merged
merged 4 commits into from
Oct 21, 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
23 changes: 13 additions & 10 deletions src/dodal/devices/zocalo/zocalo_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,19 @@ async def trigger(self):
source_of_second_results = source_from_results(
raw_results_two_sources[1]
)

# Compare results from both sources and warn if they aren't the same
differences_str = get_dict_differences(
raw_results_two_sources[0]["results"][0],
source_of_first_results,
raw_results_two_sources[1]["results"][0],
source_of_second_results,
)
if differences_str:
LOGGER.warning(differences_str)
first_results = raw_results_two_sources[0]["results"]
second_results = raw_results_two_sources[1]["results"]

if first_results and second_results:
# Compare results from both sources and warn if they aren't the same
differences_str = get_dict_differences(
first_results[0],
source_of_first_results,
second_results[0],
source_of_second_results,
)
if differences_str:
LOGGER.warning(differences_str)

# Always use CPU results
raw_results = (
Expand Down
15 changes: 15 additions & 0 deletions tests/devices/unit_tests/test_zocalo_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,18 @@ def zocalo_plan():
)

RE(zocalo_plan())


async def test_given_gpu_enabled_when_no_results_found_then_returns_no_results(
zocalo_results: ZocaloResults,
):
zocalo_results.use_cpu_and_gpu = True
await zocalo_results.stage()
zocalo_results._raw_results_received.get = MagicMock(
side_effect=[
{"recipe_parameters": {"dcgid": 0, "dcid": 0, "gpu": True}, "results": []},
{"recipe_parameters": {"dcgid": 0, "dcid": 0}, "results": []},
]
)
await zocalo_results.trigger()
assert len(await zocalo_results.centres_of_mass.get_value()) == 0
Loading