From fec3ef636a182cbb0885f7c809a08ea19068d29a Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Wed, 28 Aug 2024 10:34:26 -0500 Subject: [PATCH] choose_devices: don't short-circuit dev choice when answers available (#780) * choose_devices: don't short-circuit dev choice when answers available * print automatically chosen device * dont print in non-interactive case --- pyopencl/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index ab71643ba..15d1e2bb9 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -1648,7 +1648,8 @@ def parse_device(choice): if not devices: raise Error("no devices found") - elif len(devices) == 1: + elif len(devices) == 1 and not answers: + cc_print(f"Choosing only available device: {devices[0]}") pass else: if not answers: @@ -1672,7 +1673,7 @@ def parse_device(choice): if answers: raise RuntimeError("not all provided choices were used by " - "choose_device. (left over: '%s')" % ":".join(answers)) + "choose_devices. (left over: '%s')" % ":".join(answers)) return devices