Repository: modin-project/modin

Issue:
Align experimental and regular IO modules initializations
Currently import of modin in the experimental mode triggers factories initialization:
```
>python -c "import modin.pandas as pd; from modin.core.execution.dispatching.factories.factories import PandasOnRayFactory; print(PandasOnRayFactory.io_cls)"
None

>python -c "import modin.experimental.pandas as pd; from modin.core.execution.dispatching.factories.factories import ExperimentalPandasOnRayFactory; print(ExperimentalPandasOnRayFactory.io_cls)"
UserWarning: Thank you for using the Modin Experimental pandas API.
Please note that some of these APIs deviate from pandas in order to provide improved performance.
<class 'modin.experimental.core.execution.ray.implementations.pandas_on_ray.io.io.ExperimentalPandasOnRayIO'>
```

Related to https://github.com/modin-project/modin/pull/4286#discussion_r877929699.
Align experimental and regular IO modules initializations
Currently import of modin in the experimental mode triggers factories initialization:
```
>python -c "import modin.pandas as pd; from modin.core.execution.dispatching.factories.factories import PandasOnRayFactory; print(PandasOnRayFactory.io_cls)"
None

>python -c "import modin.experimental.pandas as pd; from modin.core.execution.dispatching.factories.factories import ExperimentalPandasOnRayFactory; print(ExperimentalPandasOnRayFactory.io_cls)"
UserWarning: Thank you for using the Modin Experimental pandas API.
Please note that some of these APIs deviate from pandas in order to provide improved performance.
<class 'modin.experimental.core.execution.ray.implementations.pandas_on_ray.io.io.ExperimentalPandasOnRayIO'>
```

Related to https://github.com/modin-project/modin/pull/4286#discussion_r877929699.


Discussion:

Resolving patch:
diff --git a/modin/experimental/pandas/io.py b/modin/experimental/pandas/io.py
--- a/modin/experimental/pandas/io.py
+++ b/modin/experimental/pandas/io.py
@@ -24,7 +24,6 @@
 
 from . import DataFrame
 from modin.config import IsExperimental, Engine
-from modin.core.execution.dispatching.factories.dispatcher import FactoryDispatcher
 from ...pandas import _update_engine
 
 
@@ -96,9 +95,13 @@ def read_sql(
     -------
     modin.DataFrame
     """
+    _, _, _, kwargs = inspect.getargvalues(inspect.currentframe())
+
     Engine.subscribe(_update_engine)
+    from modin.core.execution.dispatching.factories.dispatcher import FactoryDispatcher
+
     assert IsExperimental.get(), "This only works in experimental mode"
-    _, _, _, kwargs = inspect.getargvalues(inspect.currentframe())
+
     return DataFrame(query_compiler=FactoryDispatcher.read_sql(**kwargs))
 
 
@@ -137,9 +140,13 @@ def read_custom_text(
     -------
     modin.DataFrame
     """
+    _, _, _, kwargs = inspect.getargvalues(inspect.currentframe())
+
     Engine.subscribe(_update_engine)
+    from modin.core.execution.dispatching.factories.dispatcher import FactoryDispatcher
+
     assert IsExperimental.get(), "This only works in experimental mode"
-    _, _, _, kwargs = inspect.getargvalues(inspect.currentframe())
+
     return DataFrame(query_compiler=FactoryDispatcher.read_custom_text(**kwargs))
 
 
@@ -265,6 +272,7 @@ def _read(**kwargs) -> DataFrame:
     [4652013 rows x 18 columns]
     """
     Engine.subscribe(_update_engine)
+    from modin.core.execution.dispatching.factories.dispatcher import FactoryDispatcher
 
     try:
         pd_obj = FactoryDispatcher.read_csv_glob(**kwargs)
@@ -322,9 +330,13 @@ def read_pickle_distributed(
     -----
     The number of partitions is equal to the number of input files.
     """
+    _, _, _, kwargs = inspect.getargvalues(inspect.currentframe())
+
     Engine.subscribe(_update_engine)
+    from modin.core.execution.dispatching.factories.dispatcher import FactoryDispatcher
+
     assert IsExperimental.get(), "This only works in experimental mode"
-    _, _, _, kwargs = inspect.getargvalues(inspect.currentframe())
+
     return DataFrame(query_compiler=FactoryDispatcher.read_pickle_distributed(**kwargs))
 
 
@@ -369,6 +381,8 @@ def to_pickle_distributed(
     """
     obj = self
     Engine.subscribe(_update_engine)
+    from modin.core.execution.dispatching.factories.dispatcher import FactoryDispatcher
+
     if isinstance(self, DataFrame):
         obj = self._query_compiler
     FactoryDispatcher.to_pickle_distributed(


Test patch: