Skip to content

Commit

Permalink
Try-except for capturing failure to start ray instances.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzwanenburg committed Mar 27, 2024
1 parent 18a1c68 commit e11d6f6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mirp/utilities/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ def ray_is_initialized():

def ray_init(num_cpus):
if RAY_AVAILABLE:
ray.init(num_cpus=num_cpus)
try:
ray.init(num_cpus=num_cpus)
except OSError as err:
warnings.warn(
f"Ray instances could not be started for parallel processing. Switching to sequential processing. "
f"{str(err)}",
UserWarning
)
pass
else:
warnings.warn(
"The ray package was not found. Switching to sequential processing.",
Expand Down

0 comments on commit e11d6f6

Please sign in to comment.