Skip to content

Commit 308fd52

Browse files
Restructure import attempt to only try Ray if on a non-windows machine (#945)
* Restructure import attempt to only try Ray if on a non-windows machine * Resolves #944 * Fix typos in error messages
1 parent 60109b9 commit 308fd52

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

modin/__init__.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
import warnings
34

45

@@ -19,39 +20,42 @@ def get_execution_engine():
1920
# execution engine + backing (Pandas + Ray).
2021
if "MODIN_ENGINE" in os.environ:
2122
# .title allows variants like ray, RAY, Ray
22-
engine = os.environ["MODIN_ENGINE"].title()
23+
return os.environ["MODIN_ENGINE"].title()
2324
else:
2425
if "MODIN_DEBUG" in os.environ:
25-
engine = "Python"
26+
return "Python"
2627
else:
27-
try:
28-
import ray
29-
30-
engine = "Ray"
31-
except ImportError:
28+
if sys.platform != "win32":
3229
try:
33-
import dask
34-
import distributed
30+
import ray
3531

36-
engine = "Dask"
3732
except ImportError:
38-
raise ImportError(
39-
"Please `pip install modin[ray] or modin[dask] to install an engine"
40-
)
33+
pass
4134
else:
42-
if (
43-
str(dask.__version__) < "2.1.0"
44-
or str(distributed.__version__) < "2.3.2"
45-
):
35+
if ray.__version__ != "0.8.0":
4636
raise ImportError(
47-
"Please `pip install modin[dask] to install compatible Dask version."
37+
"Please `pip install modin[ray]` to install compatible Ray version."
4838
)
39+
return "Ray"
40+
try:
41+
import dask
42+
import distributed
43+
44+
except ImportError:
45+
raise ImportError(
46+
"Please `pip install {}modin[dask]` to install an engine".format(
47+
"modin[ray]` or `" if sys.platform != "win32" else ""
48+
)
49+
)
4950
else:
50-
if ray.__version__ != "0.8.0":
51+
if (
52+
str(dask.__version__) < "2.1.0"
53+
or str(distributed.__version__) < "2.3.2"
54+
):
5155
raise ImportError(
52-
"Please `pip install modin[ray] to install compatible Ray version."
56+
"Please `pip install modin[dask]` to install compatible Dask version."
5357
)
54-
return engine
58+
return "Dask"
5559

5660

5761
def get_partition_format():

0 commit comments

Comments
 (0)