Skip to content

Commit

Permalink
REFACTOR-modin-project#2059: Migrate MODIN_EXPERIMENTAL
Browse files Browse the repository at this point in the history
Signed-off-by: Vasilij Litvinov <[email protected]>
  • Loading branch information
vnlitvinov committed Oct 12, 2020
1 parent 195c0f3 commit d13ffcd
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
11 changes: 5 additions & 6 deletions modin/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# governing permissions and limitations under the License.

import pytest
import os

from modin.config import IsExperimental


def pytest_addoption(parser):
Expand Down Expand Up @@ -53,9 +54,9 @@ def __exit__(self, *a, **kw):


def set_experimental_env(mode):
import os
from modin.config import IsExperimental

os.environ["MODIN_EXPERIMENTAL"] = "True" if mode == "experimental" else "False"
IsExperimental.put(mode == "experimental")


@pytest.fixture(scope="session", autouse=True)
Expand All @@ -67,9 +68,7 @@ def simulate_cloud(request):

if mode not in ("normal", "experimental"):
raise ValueError(f"Unsupported --simulate-cloud mode: {mode}")
assert (
os.environ.get("MODIN_EXPERIMENTAL", "").title() == "True"
), "Simulated cloud must be started in experimental mode"
assert IsExperimental.get(), "Simulated cloud must be started in experimental mode"

from modin.experimental.cloud import create_cluster, get_connection
import pandas._testing
Expand Down
4 changes: 2 additions & 2 deletions modin/experimental/pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.

import os
from modin.config import IsExperimental

os.environ["MODIN_EXPERIMENTAL"] = "True"
IsExperimental.put(True)

# import numpy_wrap as early as possible to intercept all "import numpy" statements
# in the user code
Expand Down
6 changes: 2 additions & 4 deletions modin/experimental/pandas/io_exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# governing permissions and limitations under the License.

import inspect
import os

from . import DataFrame
from modin.data_management.factories.dispatcher import EngineDispatcher
from modin.config import IsExperimental


def read_sql(
Expand Down Expand Up @@ -63,8 +63,6 @@ def read_sql(
Returns:
Pandas Dataframe
"""
assert (
os.environ.get("MODIN_EXPERIMENTAL", "").title() == "True"
), "This only works in experimental mode"
assert IsExperimental.get(), "This only works in experimental mode"
_, _, _, kwargs = inspect.getargvalues(inspect.currentframe())
return DataFrame(query_compiler=EngineDispatcher.read_sql(**kwargs))
4 changes: 2 additions & 2 deletions modin/pandas/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.

import os
import numpy as np
from numpy import nan
import pandas
Expand Down Expand Up @@ -41,6 +40,7 @@
from modin.utils import try_cast_to_pandas
from modin.error_message import ErrorMessage
from modin.pandas.utils import is_scalar
from modin.config import IsExperimental

# Similar to pandas, sentinel value to use as kwarg in place of None when None has
# special meaning and needs to be distinguished from a user explicitly passing None.
Expand Down Expand Up @@ -3498,7 +3498,7 @@ def default_handler(*args, **kwargs):
return object.__getattribute__(self, item)


if os.environ.get("MODIN_EXPERIMENTAL", "").title() == "True":
if IsExperimental.get():
from modin.experimental.cloud.meta_magic import make_wrapped_class

make_wrapped_class(BasePandasDataset, "make_base_dataset_wrapper")
Expand Down
4 changes: 2 additions & 2 deletions modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
import functools
import numpy as np
import sys
import os
from typing import Optional, Sequence, Tuple, Union, Mapping
import warnings

from modin.error_message import ErrorMessage
from modin.utils import _inherit_docstrings, to_pandas, hashable
from modin.config import IsExperimental
from .utils import (
from_pandas,
from_non_pandas,
Expand Down Expand Up @@ -3410,7 +3410,7 @@ def _to_pandas(self):
return self._query_compiler.to_pandas()


if os.environ.get("MODIN_EXPERIMENTAL", "").title() == "True":
if IsExperimental.get():
from modin.experimental.cloud.meta_magic import make_wrapped_class

make_wrapped_class(DataFrame, "make_dataframe_wrapper")
4 changes: 2 additions & 2 deletions modin/pandas/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
# ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.

import os
import pandas
import pandas.core.groupby
from pandas.core.dtypes.common import is_list_like
import pandas.core.common as com

from modin.error_message import ErrorMessage
from modin.utils import _inherit_docstrings, wrap_udf_function, try_cast_to_pandas
from modin.config import IsExperimental
from .series import Series


Expand Down Expand Up @@ -771,7 +771,7 @@ def groupby_on_multiple_columns(df, *args, **kwargs):
return self._df._default_to_pandas(groupby_on_multiple_columns, *args, **kwargs)


if os.environ.get("MODIN_EXPERIMENTAL", "").title() == "True":
if IsExperimental.get():
from modin.experimental.cloud.meta_magic import make_wrapped_class

make_wrapped_class(DataFrameGroupBy, "make_dataframe_groupby_wrapper")
Expand Down
4 changes: 2 additions & 2 deletions modin/pandas/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.

import os
import numpy as np
import pandas
from pandas.core.common import apply_if_callable, is_bool_indexer
Expand All @@ -27,6 +26,7 @@
import warnings

from modin.utils import _inherit_docstrings, to_pandas
from modin.config import IsExperimental
from .base import BasePandasDataset, _ATTRS_NO_LOOKUP
from .iterator import PartitionIterator
from .utils import from_pandas, is_scalar
Expand Down Expand Up @@ -2308,7 +2308,7 @@ def _to_pandas(self):
return series


if os.environ.get("MODIN_EXPERIMENTAL", "").title() == "True":
if IsExperimental.get():
from modin.experimental.cloud.meta_magic import make_wrapped_class

make_wrapped_class(Series, "make_series_wrapper")
Expand Down

0 comments on commit d13ffcd

Please sign in to comment.