Skip to content

Commit 9ffbc92

Browse files
Fix errors
Signed-off-by: sfc-gh-mvashishtha <mahesh.vashishtha@snowflake.com>
1 parent c605ffd commit 9ffbc92

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

modin/config/envvars.py

+24-23
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,6 @@
3535
)
3636

3737

38-
class DisallowExecutionAndBackendInEnvironmentMixin:
39-
"""Mixin to disallow setting both execution and backend in environment."""
40-
41-
@classmethod
42-
@doc(Parameter._get_value_from_config.__doc__)
43-
def _get_value_from_config(cls) -> str:
44-
if Backend.varname in os.environ and (
45-
Engine.varname in os.environ or StorageFormat.varname in os.environ
46-
):
47-
# Handling this case is tricky, in part because the combination of
48-
# Backend and Engine/StorageFormat may be invalid. For now just
49-
# disallow it.
50-
raise Exception("Can't specify both execution and backend in environment")
51-
return Parameter._get_value_from_config()
52-
53-
5438
class EnvironmentVariable(Parameter, type=str, abstract=True):
5539
"""Base class for environment variables-based configuration."""
5640

@@ -182,14 +166,35 @@ def put(cls, value: Any) -> None:
182166
cls._update_sibling = True
183167

184168

169+
class EnvironmentVariableDisallowingExecutionAndBackendBothSet(
170+
EnvironmentVariable,
171+
type=EnvironmentVariable.type,
172+
abstract=True,
173+
):
174+
"""Subclass to disallow getting this variable from the environment when both execution and backend are set in the environment."""
175+
176+
@classmethod
177+
@doc(EnvironmentVariable._get_value_from_config.__doc__)
178+
def _get_value_from_config(cls) -> str:
179+
if Backend.varname in os.environ and (
180+
Engine.varname in os.environ or StorageFormat.varname in os.environ
181+
):
182+
# Handling this case is tricky, in part because the combination of
183+
# Backend and Engine/StorageFormat may be invalid. For now just
184+
# disallow it.
185+
raise Exception("Can't specify both execution and backend in environment")
186+
return super()._get_value_from_config()
187+
188+
185189
class IsDebug(EnvironmentVariable, type=bool):
186190
"""Force Modin engine to be "Python" unless specified by $MODIN_ENGINE."""
187191

188192
varname = "MODIN_DEBUG"
189193

190194

191195
class Engine(
192-
DisallowExecutionAndBackendInEnvironmentMixin, EnvironmentVariable, type=str
196+
EnvironmentVariableDisallowingExecutionAndBackendBothSet,
197+
type=str,
193198
):
194199
"""Distribution engine to run queries by."""
195200

@@ -327,9 +332,7 @@ def get(cls) -> str:
327332
return cls._value
328333

329334

330-
class StorageFormat(
331-
DisallowExecutionAndBackendInEnvironmentMixin, EnvironmentVariable, type=str
332-
):
335+
class StorageFormat(EnvironmentVariableDisallowingExecutionAndBackendBothSet, type=str):
333336
"""Engine to run on a single node of distribution."""
334337

335338
@classmethod
@@ -395,9 +398,7 @@ def get(cls) -> str:
395398
Execution = namedtuple("Execution", ["storage_format", "engine"])
396399

397400

398-
class Backend(
399-
DisallowExecutionAndBackendInEnvironmentMixin, EnvironmentVariable, type=str
400-
):
401+
class Backend(EnvironmentVariableDisallowingExecutionAndBackendBothSet, type=str):
401402
"""
402403
An alias for execution, i.e. the combination of StorageFormat and Engine.
403404

0 commit comments

Comments
 (0)