From e11d6f6abad7f86411bf052b85cf67a0d1e72fdb Mon Sep 17 00:00:00 2001 From: Alex Zwanenburg Date: Wed, 27 Mar 2024 11:55:24 +0100 Subject: [PATCH] Try-except for capturing failure to start ray instances. --- mirp/utilities/parallel.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mirp/utilities/parallel.py b/mirp/utilities/parallel.py index b3d1ced5..a3069a09 100644 --- a/mirp/utilities/parallel.py +++ b/mirp/utilities/parallel.py @@ -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.",