Repository: modin-project/modin

Issue:
Synchronize the python version in the local context with the python version in the remote context.



Discussion:
Just started.

Resolving patch:
diff --git a/modin/experimental/cloud/rayscale.py b/modin/experimental/cloud/rayscale.py
--- a/modin/experimental/cloud/rayscale.py
+++ b/modin/experimental/cloud/rayscale.py
@@ -133,8 +133,34 @@ def __make_config(self):
         config["worker_nodes"][instance_key] = self.worker_node_type
         config["worker_nodes"][image_key] = self.provider.image
 
+        # NOTE: setup_commands may be list with several sets of shell commands
+        # this change only first set defining the remote environment
+        res = self._update_conda_requirements(config["setup_commands"][0])
+        config["setup_commands"][0] = res
+
         return _bootstrap_config(config)
 
+    @classmethod
+    def _conda_requirements(cls):
+        reqs = []
+
+        reqs.append(f"python=={cls._get_python_version()}")
+
+        return reqs
+
+    @classmethod
+    def _update_conda_requirements(cls, setup_commands: str):
+        return setup_commands.replace(
+            "{{CONDA_PACKAGES}}", " ".join(cls._conda_requirements())
+        )
+
+    @staticmethod
+    def _get_python_version():
+        major = sys.version_info.major
+        minor = sys.version_info.minor
+        micro = sys.version_info.micro
+        return f"{major}.{minor}.{micro}"
+
     @staticmethod
     def __save_config(config):
         cfgdir = os.path.abspath(os.path.expanduser("~/.modin/cloud"))


Test patch:
diff --git a/modin/experimental/cloud/test/__init__.py b/modin/experimental/cloud/test/__init__.py
new file mode 100644
--- /dev/null
+++ b/modin/experimental/cloud/test/__init__.py
@@ -0,0 +1,12 @@
+# Licensed to Modin Development Team under one or more contributor license agreements.
+# See the NOTICE file distributed with this work for additional information regarding
+# copyright ownership.  The Modin Development Team licenses this file to you under the
+# Apache License, Version 2.0 (the "License"); you may not use this file except in
+# compliance with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software distributed under
+# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+# ANY KIND, either express or implied. See the License for the specific language
+# governing permissions and limitations under the License.
diff --git a/modin/experimental/cloud/test/test_cloud.py b/modin/experimental/cloud/test/test_cloud.py
new file mode 100644
--- /dev/null
+++ b/modin/experimental/cloud/test/test_cloud.py
@@ -0,0 +1,39 @@
+# Licensed to Modin Development Team under one or more contributor license agreements.
+# See the NOTICE file distributed with this work for additional information regarding
+# copyright ownership.  The Modin Development Team licenses this file to you under the
+# Apache License, Version 2.0 (the "License"); you may not use this file except in
+# compliance with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software distributed under
+# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+# ANY KIND, either express or implied. See the License for the specific language
+# governing permissions and limitations under the License.
+
+import sys
+import pytest
+from modin.experimental.cloud.rayscale import RayCluster
+
+
+@pytest.mark.parametrize(
+    "setup_commands_source",
+    [
+        r"""conda create --clone base --name modin --yes
+        conda activate modin
+        conda install --yes {{CONDA_PACKAGES}}
+
+        pip install modin "ray==0.8.7" cloudpickle
+        """
+    ],
+)
+def test_update_conda_requirements(setup_commands_source):
+    major = sys.version_info.major
+    minor = sys.version_info.minor
+    micro = sys.version_info.micro
+    python_version = f"python=={major}.{minor}.{micro}"
+
+    setup_commands_result = RayCluster._update_conda_requirements(setup_commands_source)
+
+    assert python_version in setup_commands_result
+    assert "{{CONDA_PACKAGES}}" not in setup_commands_result