Repository: gammapy/gammapy

Issue:
Just importing gammapy raises a warning about ray support being experimental
**Gammapy version**

```
Gammapy support for parallelisation with ray is still a prototype and is not fully functional.

System:

	python_executable      : /home/maxnoe/.local/conda/envs/gammapy-dev/bin/python3.9 
	python_version         : 3.9.16     
	machine                : x86_64     
	system                 : Linux      


Gammapy package:

	version                : 1.2.dev201+g514451881.d20230627 
	path                   : /home/maxnoe/Projects/gammapy/gammapy 


Other packages:

	numpy                  : 1.25.0     
	scipy                  : 1.11.0     
	astropy                : 5.3        
	regions                : 0.7        
	click                  : 8.1.3      
	yaml                   : 6.0        
	IPython                : 8.14.0     
	jupyterlab             : 3.5.3      
	matplotlib             : 3.7.1      
	pandas                 : 2.0.2      
	healpy                 : 1.16.2     
	iminuit                : 2.22.0     
	sherpa                 : 4.15.1     
	naima                  : 0.10.0     
	emcee                  : 3.1.4      
	corner                 : 2.2.2      
	ray                    : 2.5.1      


Gammapy environment variables:

	GAMMAPY_DATA           : /home/maxnoe/Projects/gammapy/gammapy-datasets/dev 
```

**Bug description**

Just importing a subpackage of gammapy, without doing anything else, raises a warning about ray support being experimental.

I am not doing anything with ray, I just setup the dev environment and imported things:

```
❯ python -c 'import gammapy.datasets'
Gammapy support for parallelisation with ray is still a prototype and is not fully functional.
❯ python -c 'import gammapy.makers'
Gammapy support for parallelisation with ray is still a prototype and is not fully functional.
```

**Expected behavior**

No warnings about things I don't actually use.


**To Reproduce**
See above, dev environment and the imports.

**Other information**




Discussion:
maybe the warning should be triggered from `utils.parallel.run_multiprocessing` instead of raising it from the multiprocessing setup?

Resolving patch:
diff --git a/gammapy/utils/parallel.py b/gammapy/utils/parallel.py
--- a/gammapy/utils/parallel.py
+++ b/gammapy/utils/parallel.py
@@ -2,7 +2,6 @@
 """Multiprocessing and multithreading setup"""
 import importlib
 import logging
-import multiprocessing
 from enum import Enum
 from gammapy.utils.pbar import progress_bar
 
@@ -39,6 +38,13 @@ class PoolMethodEnum(Enum):
 N_JOBS_DEFAULT = 1
 
 
+def get_multiprocessing():
+    """Get multiprocessing module"""
+    import multiprocessing
+
+    return multiprocessing
+
+
 def get_multiprocessing_ray():
     """Get multiprocessing module for ray backend"""
     import ray.util.multiprocessing as multiprocessing
@@ -147,7 +153,7 @@ def run_multiprocessing(
 
     processes = pool_kwargs.get("processes", N_JOBS_DEFAULT)
 
-    multiprocessing = PARALLEL_BACKEND_MODULES[backend]
+    multiprocessing = PARALLEL_BACKEND_MODULES[backend]()
 
     if backend == ParallelBackendEnum.multiprocessing:
         cpu_count = multiprocessing.cpu_count()
@@ -225,8 +231,6 @@ def run_pool_async(pool, func, inputs, method_kwargs=None, task_name=""):
 }
 
 PARALLEL_BACKEND_MODULES = {
-    ParallelBackendEnum.multiprocessing: multiprocessing,
+    ParallelBackendEnum.multiprocessing: get_multiprocessing,
+    ParallelBackendEnum.ray: get_multiprocessing_ray,
 }
-
-if is_ray_available():
-    PARALLEL_BACKEND_MODULES[ParallelBackendEnum.ray] = get_multiprocessing_ray()


Test patch: