Skip to content

Commit

Permalink
choose_devices: don't short-circuit dev choice when answers available (
Browse files Browse the repository at this point in the history
…#780)

* choose_devices: don't short-circuit dev choice when answers available

* print automatically chosen device

* dont print in non-interactive case
  • Loading branch information
matthiasdiener authored Aug 28, 2024
1 parent 40230ea commit fec3ef6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pyopencl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down

0 comments on commit fec3ef6

Please sign in to comment.