We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[Ray] Secure Redis ports
Currently Ray's Redis ports are not secured by default which is a problem on systems exposed to the internet.

 Once ray-project/ray#2952 is merged, I recommend securing Redis ports with `ray.init(redis_password=password)` where `password` is securely generated e.g. by using the [secrets module](https://docs.python.org/3.6/library/secrets.html).

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `modin/pandas/__init__.py`
Content:
```
1 import pandas
2 
3 __pandas_version__ = "0.25.3"
4 
5 if pandas.__version__ != __pandas_version__:
6     import warnings
7 
8     warnings.warn(
9         "The pandas version installed does not match the required pandas version in "
10         "Modin. This may cause undesired side effects!".format(__pandas_version__)
11     )
12 
13 from pandas import (
14     eval,
15     unique,
16     value_counts,
17     cut,
18     to_numeric,
19     factorize,
20     test,
21     qcut,
22     date_range,
23     period_range,
24     Index,
25     MultiIndex,
26     CategoricalIndex,
27     bdate_range,
28     DatetimeIndex,
29     Timedelta,
30     Timestamp,
31     to_timedelta,
32     set_eng_float_format,
33     options,
34     set_option,
35     NaT,
36     PeriodIndex,
37     Categorical,
38     Interval,
39     UInt8Dtype,
40     UInt16Dtype,
41     UInt32Dtype,
42     UInt64Dtype,
43     SparseDtype,
44     Int8Dtype,
45     Int16Dtype,
46     Int32Dtype,
47     Int64Dtype,
48     CategoricalDtype,
49     DatetimeTZDtype,
50     IntervalDtype,
51     PeriodDtype,
52     RangeIndex,
53     Int64Index,
54     UInt64Index,
55     Float64Index,
56     TimedeltaIndex,
57     IntervalIndex,
58     IndexSlice,
59     Grouper,
60     array,
61     Period,
62     show_versions,
63     DateOffset,
64     timedelta_range,
65     infer_freq,
66     interval_range,
67     ExcelWriter,
68     SparseArray,
69     SparseSeries,
70     SparseDataFrame,
71     datetime,
72     NamedAgg,
73 )
74 import threading
75 import os
76 import types
77 import sys
78 
79 from .. import __version__
80 from .concat import concat
81 from .dataframe import DataFrame
82 from .datetimes import to_datetime
83 from .io import (
84     read_csv,
85     read_parquet,
86     read_json,
87     read_html,
88     read_clipboard,
89     read_excel,
90     read_hdf,
91     read_feather,
92     read_msgpack,
93     read_stata,
94     read_sas,
95     read_pickle,
96     read_sql,
97     read_gbq,
98     read_table,
99     read_fwf,
100     read_sql_table,
101     read_sql_query,
102     read_spss,
103     ExcelFile,
104     to_pickle,
105     HDFStore,
106 )
107 from .reshape import get_dummies, melt, crosstab, lreshape, wide_to_long
108 from .series import Series
109 from .general import (
110     isna,
111     isnull,
112     merge,
113     merge_asof,
114     merge_ordered,
115     pivot_table,
116     notnull,
117     notna,
118     pivot,
119 )
120 from .plotting import Plotting as plotting
121 from .. import __execution_engine__ as execution_engine
122 
123 # Set this so that Pandas doesn't try to multithread by itself
124 os.environ["OMP_NUM_THREADS"] = "1"
125 num_cpus = 1
126 
127 
128 def initialize_ray():
129     import ray
130 
131     """Initializes ray based on environment variables and internal defaults."""
132     if threading.current_thread().name == "MainThread":
133         plasma_directory = None
134         cluster = os.environ.get("MODIN_RAY_CLUSTER", None)
135         redis_address = os.environ.get("MODIN_REDIS_ADDRESS", None)
136         if cluster == "True" and redis_address is not None:
137             # We only start ray in a cluster setting for the head node.
138             ray.init(
139                 include_webui=False,
140                 ignore_reinit_error=True,
141                 redis_address=redis_address,
142                 logging_level=100,
143             )
144         elif cluster is None:
145             object_store_memory = os.environ.get("MODIN_MEMORY", None)
146             if os.environ.get("MODIN_OUT_OF_CORE", "False").title() == "True":
147                 from tempfile import gettempdir
148 
149                 plasma_directory = gettempdir()
150                 # We may have already set the memory from the environment variable, we don't
151                 # want to overwrite that value if we have.
152                 if object_store_memory is None:
153                     # Round down to the nearest Gigabyte.
154                     mem_bytes = ray.utils.get_system_memory() // 10 ** 9 * 10 ** 9
155                     # Default to 8x memory for out of core
156                     object_store_memory = 8 * mem_bytes
157             # In case anything failed above, we can still improve the memory for Modin.
158             if object_store_memory is None:
159                 # Round down to the nearest Gigabyte.
160                 object_store_memory = int(
161                     0.6 * ray.utils.get_system_memory() // 10 ** 9 * 10 ** 9
162                 )
163                 # If the memory pool is smaller than 2GB, just use the default in ray.
164                 if object_store_memory == 0:
165                     object_store_memory = None
166             else:
167                 object_store_memory = int(object_store_memory)
168             ray.init(
169                 include_webui=False,
170                 ignore_reinit_error=True,
171                 plasma_directory=plasma_directory,
172                 object_store_memory=object_store_memory,
173                 redis_address=redis_address,
174                 logging_level=100,
175                 memory=object_store_memory,
176             )
177         # Register custom serializer for method objects to avoid warning message.
178         # We serialize `MethodType` objects when we use AxisPartition operations.
179         ray.register_custom_serializer(types.MethodType, use_pickle=True)
180 
181         # Register a fix import function to run on all_workers including the driver.
182         # This is a hack solution to fix #647, #746
183         def move_stdlib_ahead_of_site_packages(*args):
184             site_packages_path = None
185             site_packages_path_index = -1
186             for i, path in enumerate(sys.path):
187                 if sys.exec_prefix in path and path.endswith("site-packages"):
188                     site_packages_path = path
189                     site_packages_path_index = i
190                     # break on first found
191                     break
192 
193             if site_packages_path is not None:
194                 # stdlib packages layout as follows:
195                 # - python3.x
196                 #   - typing.py
197                 #   - site-packages/
198                 #     - pandas
199                 # So extracting the dirname of the site_packages can point us
200                 # to the directory containing standard libraries.
201                 sys.path.insert(
202                     site_packages_path_index, os.path.dirname(site_packages_path)
203                 )
204 
205         move_stdlib_ahead_of_site_packages()
206         ray.worker.global_worker.run_function_on_all_workers(
207             move_stdlib_ahead_of_site_packages
208         )
209 
210 
211 if execution_engine == "Ray":
212     import ray
213 
214     initialize_ray()
215     num_cpus = ray.cluster_resources()["CPU"]
216 elif execution_engine == "Dask":  # pragma: no cover
217     from distributed.client import get_client
218     import warnings
219 
220     if threading.current_thread().name == "MainThread":
221         warnings.warn("The Dask Engine for Modin is experimental.")
222         try:
223             client = get_client()
224         except ValueError:
225             from distributed import Client
226             import multiprocessing
227 
228             num_cpus = multiprocessing.cpu_count()
229             client = Client(n_workers=num_cpus)
230 elif execution_engine != "Python":
231     raise ImportError("Unrecognized execution engine: {}.".format(execution_engine))
232 
233 DEFAULT_NPARTITIONS = max(4, int(num_cpus))
234 
235 __all__ = [
236     "DataFrame",
237     "Series",
238     "read_csv",
239     "read_parquet",
240     "read_json",
241     "read_html",
242     "read_clipboard",
243     "read_excel",
244     "read_hdf",
245     "read_feather",
246     "read_msgpack",
247     "read_stata",
248     "read_sas",
249     "read_pickle",
250     "read_sql",
251     "read_gbq",
252     "read_table",
253     "read_spss",
254     "concat",
255     "eval",
256     "unique",
257     "value_counts",
258     "cut",
259     "to_numeric",
260     "factorize",
261     "test",
262     "qcut",
263     "to_datetime",
264     "get_dummies",
265     "isna",
266     "isnull",
267     "merge",
268     "pivot_table",
269     "date_range",
270     "Index",
271     "MultiIndex",
272     "Series",
273     "bdate_range",
274     "period_range",
275     "DatetimeIndex",
276     "to_timedelta",
277     "set_eng_float_format",
278     "options",
279     "set_option",
280     "CategoricalIndex",
281     "Timedelta",
282     "Timestamp",
283     "NaT",
284     "PeriodIndex",
285     "Categorical",
286     "__version__",
287     "melt",
288     "crosstab",
289     "plotting",
290     "Interval",
291     "UInt8Dtype",
292     "UInt16Dtype",
293     "UInt32Dtype",
294     "UInt64Dtype",
295     "SparseDtype",
296     "Int8Dtype",
297     "Int16Dtype",
298     "Int32Dtype",
299     "Int64Dtype",
300     "CategoricalDtype",
301     "DatetimeTZDtype",
302     "IntervalDtype",
303     "PeriodDtype",
304     "RangeIndex",
305     "Int64Index",
306     "UInt64Index",
307     "Float64Index",
308     "TimedeltaIndex",
309     "IntervalIndex",
310     "IndexSlice",
311     "Grouper",
312     "array",
313     "Period",
314     "show_versions",
315     "DateOffset",
316     "timedelta_range",
317     "infer_freq",
318     "interval_range",
319     "ExcelWriter",
320     "read_fwf",
321     "read_sql_table",
322     "read_sql_query",
323     "ExcelFile",
324     "to_pickle",
325     "HDFStore",
326     "lreshape",
327     "wide_to_long",
328     "merge_asof",
329     "merge_ordered",
330     "notnull",
331     "notna",
332     "pivot",
333     "SparseArray",
334     "SparseSeries",
335     "SparseDataFrame",
336     "datetime",
337     "NamedAgg",
338     "DEFAULT_NPARTITIONS",
339 ]
340 
341 del pandas
342
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/modin/pandas/__init__.py b/modin/pandas/__init__.py
--- a/modin/pandas/__init__.py
+++ b/modin/pandas/__init__.py
@@ -130,15 +130,19 @@
 
     """Initializes ray based on environment variables and internal defaults."""
     if threading.current_thread().name == "MainThread":
+        import secrets
+
         plasma_directory = None
         cluster = os.environ.get("MODIN_RAY_CLUSTER", None)
         redis_address = os.environ.get("MODIN_REDIS_ADDRESS", None)
+        redis_password = secrets.token_hex(16)
         if cluster == "True" and redis_address is not None:
             # We only start ray in a cluster setting for the head node.
             ray.init(
                 include_webui=False,
                 ignore_reinit_error=True,
                 redis_address=redis_address,
+                redis_password=redis_password,
                 logging_level=100,
             )
         elif cluster is None:
@@ -171,6 +175,7 @@
                 plasma_directory=plasma_directory,
                 object_store_memory=object_store_memory,
                 redis_address=redis_address,
+                redis_password=redis_password,
                 logging_level=100,
                 memory=object_store_memory,
             )

{"golden_diff": "diff --git a/modin/pandas/__init__.py b/modin/pandas/__init__.py\n--- a/modin/pandas/__init__.py\n+++ b/modin/pandas/__init__.py\n@@ -130,15 +130,19 @@\n \n     \"\"\"Initializes ray based on environment variables and internal defaults.\"\"\"\n     if threading.current_thread().name == \"MainThread\":\n+        import secrets\n+\n         plasma_directory = None\n         cluster = os.environ.get(\"MODIN_RAY_CLUSTER\", None)\n         redis_address = os.environ.get(\"MODIN_REDIS_ADDRESS\", None)\n+        redis_password = secrets.token_hex(16)\n         if cluster == \"True\" and redis_address is not None:\n             # We only start ray in a cluster setting for the head node.\n             ray.init(\n                 include_webui=False,\n                 ignore_reinit_error=True,\n                 redis_address=redis_address,\n+                redis_password=redis_password,\n                 logging_level=100,\n             )\n         elif cluster is None:\n@@ -171,6 +175,7 @@\n                 plasma_directory=plasma_directory,\n                 object_store_memory=object_store_memory,\n                 redis_address=redis_address,\n+                redis_password=redis_password,\n                 logging_level=100,\n                 memory=object_store_memory,\n             )\n", "issue": "[Ray] Secure Redis ports\nCurrently Ray's Redis ports are not secured by default which is a problem on systems exposed to the internet.\r\n\r\n Once ray-project/ray#2952 is merged, I recommend securing Redis ports with `ray.init(redis_password=password)` where `password` is securely generated e.g. by using the [secrets module](https://docs.python.org/3.6/library/secrets.html).\n", "before_files": [{"content": "import pandas\n\n__pandas_version__ = \"0.25.3\"\n\nif pandas.__version__ != __pandas_version__:\n    import warnings\n\n    warnings.warn(\n        \"The pandas version installed does not match the required pandas version in \"\n        \"Modin. This may cause undesired side effects!\".format(__pandas_version__)\n    )\n\nfrom pandas import (\n    eval,\n    unique,\n    value_counts,\n    cut,\n    to_numeric,\n    factorize,\n    test,\n    qcut,\n    date_range,\n    period_range,\n    Index,\n    MultiIndex,\n    CategoricalIndex,\n    bdate_range,\n    DatetimeIndex,\n    Timedelta,\n    Timestamp,\n    to_timedelta,\n    set_eng_float_format,\n    options,\n    set_option,\n    NaT,\n    PeriodIndex,\n    Categorical,\n    Interval,\n    UInt8Dtype,\n    UInt16Dtype,\n    UInt32Dtype,\n    UInt64Dtype,\n    SparseDtype,\n    Int8Dtype,\n    Int16Dtype,\n    Int32Dtype,\n    Int64Dtype,\n    CategoricalDtype,\n    DatetimeTZDtype,\n    IntervalDtype,\n    PeriodDtype,\n    RangeIndex,\n    Int64Index,\n    UInt64Index,\n    Float64Index,\n    TimedeltaIndex,\n    IntervalIndex,\n    IndexSlice,\n    Grouper,\n    array,\n    Period,\n    show_versions,\n    DateOffset,\n    timedelta_range,\n    infer_freq,\n    interval_range,\n    ExcelWriter,\n    SparseArray,\n    SparseSeries,\n    SparseDataFrame,\n    datetime,\n    NamedAgg,\n)\nimport threading\nimport os\nimport types\nimport sys\n\nfrom .. import __version__\nfrom .concat import concat\nfrom .dataframe import DataFrame\nfrom .datetimes import to_datetime\nfrom .io import (\n    read_csv,\n    read_parquet,\n    read_json,\n    read_html,\n    read_clipboard,\n    read_excel,\n    read_hdf,\n    read_feather,\n    read_msgpack,\n    read_stata,\n    read_sas,\n    read_pickle,\n    read_sql,\n    read_gbq,\n    read_table,\n    read_fwf,\n    read_sql_table,\n    read_sql_query,\n    read_spss,\n    ExcelFile,\n    to_pickle,\n    HDFStore,\n)\nfrom .reshape import get_dummies, melt, crosstab, lreshape, wide_to_long\nfrom .series import Series\nfrom .general import (\n    isna,\n    isnull,\n    merge,\n    merge_asof,\n    merge_ordered,\n    pivot_table,\n    notnull,\n    notna,\n    pivot,\n)\nfrom .plotting import Plotting as plotting\nfrom .. import __execution_engine__ as execution_engine\n\n# Set this so that Pandas doesn't try to multithread by itself\nos.environ[\"OMP_NUM_THREADS\"] = \"1\"\nnum_cpus = 1\n\n\ndef initialize_ray():\n    import ray\n\n    \"\"\"Initializes ray based on environment variables and internal defaults.\"\"\"\n    if threading.current_thread().name == \"MainThread\":\n        plasma_directory = None\n        cluster = os.environ.get(\"MODIN_RAY_CLUSTER\", None)\n        redis_address = os.environ.get(\"MODIN_REDIS_ADDRESS\", None)\n        if cluster == \"True\" and redis_address is not None:\n            # We only start ray in a cluster setting for the head node.\n            ray.init(\n                include_webui=False,\n                ignore_reinit_error=True,\n                redis_address=redis_address,\n                logging_level=100,\n            )\n        elif cluster is None:\n            object_store_memory = os.environ.get(\"MODIN_MEMORY\", None)\n            if os.environ.get(\"MODIN_OUT_OF_CORE\", \"False\").title() == \"True\":\n                from tempfile import gettempdir\n\n                plasma_directory = gettempdir()\n                # We may have already set the memory from the environment variable, we don't\n                # want to overwrite that value if we have.\n                if object_store_memory is None:\n                    # Round down to the nearest Gigabyte.\n                    mem_bytes = ray.utils.get_system_memory() // 10 ** 9 * 10 ** 9\n                    # Default to 8x memory for out of core\n                    object_store_memory = 8 * mem_bytes\n            # In case anything failed above, we can still improve the memory for Modin.\n            if object_store_memory is None:\n                # Round down to the nearest Gigabyte.\n                object_store_memory = int(\n                    0.6 * ray.utils.get_system_memory() // 10 ** 9 * 10 ** 9\n                )\n                # If the memory pool is smaller than 2GB, just use the default in ray.\n                if object_store_memory == 0:\n                    object_store_memory = None\n            else:\n                object_store_memory = int(object_store_memory)\n            ray.init(\n                include_webui=False,\n                ignore_reinit_error=True,\n                plasma_directory=plasma_directory,\n                object_store_memory=object_store_memory,\n                redis_address=redis_address,\n                logging_level=100,\n                memory=object_store_memory,\n            )\n        # Register custom serializer for method objects to avoid warning message.\n        # We serialize `MethodType` objects when we use AxisPartition operations.\n        ray.register_custom_serializer(types.MethodType, use_pickle=True)\n\n        # Register a fix import function to run on all_workers including the driver.\n        # This is a hack solution to fix #647, #746\n        def move_stdlib_ahead_of_site_packages(*args):\n            site_packages_path = None\n            site_packages_path_index = -1\n            for i, path in enumerate(sys.path):\n                if sys.exec_prefix in path and path.endswith(\"site-packages\"):\n                    site_packages_path = path\n                    site_packages_path_index = i\n                    # break on first found\n                    break\n\n            if site_packages_path is not None:\n                # stdlib packages layout as follows:\n                # - python3.x\n                #   - typing.py\n                #   - site-packages/\n                #     - pandas\n                # So extracting the dirname of the site_packages can point us\n                # to the directory containing standard libraries.\n                sys.path.insert(\n                    site_packages_path_index, os.path.dirname(site_packages_path)\n                )\n\n        move_stdlib_ahead_of_site_packages()\n        ray.worker.global_worker.run_function_on_all_workers(\n            move_stdlib_ahead_of_site_packages\n        )\n\n\nif execution_engine == \"Ray\":\n    import ray\n\n    initialize_ray()\n    num_cpus = ray.cluster_resources()[\"CPU\"]\nelif execution_engine == \"Dask\":  # pragma: no cover\n    from distributed.client import get_client\n    import warnings\n\n    if threading.current_thread().name == \"MainThread\":\n        warnings.warn(\"The Dask Engine for Modin is experimental.\")\n        try:\n            client = get_client()\n        except ValueError:\n            from distributed import Client\n            import multiprocessing\n\n            num_cpus = multiprocessing.cpu_count()\n            client = Client(n_workers=num_cpus)\nelif execution_engine != \"Python\":\n    raise ImportError(\"Unrecognized execution engine: {}.\".format(execution_engine))\n\nDEFAULT_NPARTITIONS = max(4, int(num_cpus))\n\n__all__ = [\n    \"DataFrame\",\n    \"Series\",\n    \"read_csv\",\n    \"read_parquet\",\n    \"read_json\",\n    \"read_html\",\n    \"read_clipboard\",\n    \"read_excel\",\n    \"read_hdf\",\n    \"read_feather\",\n    \"read_msgpack\",\n    \"read_stata\",\n    \"read_sas\",\n    \"read_pickle\",\n    \"read_sql\",\n    \"read_gbq\",\n    \"read_table\",\n    \"read_spss\",\n    \"concat\",\n    \"eval\",\n    \"unique\",\n    \"value_counts\",\n    \"cut\",\n    \"to_numeric\",\n    \"factorize\",\n    \"test\",\n    \"qcut\",\n    \"to_datetime\",\n    \"get_dummies\",\n    \"isna\",\n    \"isnull\",\n    \"merge\",\n    \"pivot_table\",\n    \"date_range\",\n    \"Index\",\n    \"MultiIndex\",\n    \"Series\",\n    \"bdate_range\",\n    \"period_range\",\n    \"DatetimeIndex\",\n    \"to_timedelta\",\n    \"set_eng_float_format\",\n    \"options\",\n    \"set_option\",\n    \"CategoricalIndex\",\n    \"Timedelta\",\n    \"Timestamp\",\n    \"NaT\",\n    \"PeriodIndex\",\n    \"Categorical\",\n    \"__version__\",\n    \"melt\",\n    \"crosstab\",\n    \"plotting\",\n    \"Interval\",\n    \"UInt8Dtype\",\n    \"UInt16Dtype\",\n    \"UInt32Dtype\",\n    \"UInt64Dtype\",\n    \"SparseDtype\",\n    \"Int8Dtype\",\n    \"Int16Dtype\",\n    \"Int32Dtype\",\n    \"Int64Dtype\",\n    \"CategoricalDtype\",\n    \"DatetimeTZDtype\",\n    \"IntervalDtype\",\n    \"PeriodDtype\",\n    \"RangeIndex\",\n    \"Int64Index\",\n    \"UInt64Index\",\n    \"Float64Index\",\n    \"TimedeltaIndex\",\n    \"IntervalIndex\",\n    \"IndexSlice\",\n    \"Grouper\",\n    \"array\",\n    \"Period\",\n    \"show_versions\",\n    \"DateOffset\",\n    \"timedelta_range\",\n    \"infer_freq\",\n    \"interval_range\",\n    \"ExcelWriter\",\n    \"read_fwf\",\n    \"read_sql_table\",\n    \"read_sql_query\",\n    \"ExcelFile\",\n    \"to_pickle\",\n    \"HDFStore\",\n    \"lreshape\",\n    \"wide_to_long\",\n    \"merge_asof\",\n    \"merge_ordered\",\n    \"notnull\",\n    \"notna\",\n    \"pivot\",\n    \"SparseArray\",\n    \"SparseSeries\",\n    \"SparseDataFrame\",\n    \"datetime\",\n    \"NamedAgg\",\n    \"DEFAULT_NPARTITIONS\",\n]\n\ndel pandas\n", "path": "modin/pandas/__init__.py"}], "after_files": [{"content": "import pandas\n\n__pandas_version__ = \"0.25.3\"\n\nif pandas.__version__ != __pandas_version__:\n    import warnings\n\n    warnings.warn(\n        \"The pandas version installed does not match the required pandas version in \"\n        \"Modin. This may cause undesired side effects!\".format(__pandas_version__)\n    )\n\nfrom pandas import (\n    eval,\n    unique,\n    value_counts,\n    cut,\n    to_numeric,\n    factorize,\n    test,\n    qcut,\n    date_range,\n    period_range,\n    Index,\n    MultiIndex,\n    CategoricalIndex,\n    bdate_range,\n    DatetimeIndex,\n    Timedelta,\n    Timestamp,\n    to_timedelta,\n    set_eng_float_format,\n    options,\n    set_option,\n    NaT,\n    PeriodIndex,\n    Categorical,\n    Interval,\n    UInt8Dtype,\n    UInt16Dtype,\n    UInt32Dtype,\n    UInt64Dtype,\n    SparseDtype,\n    Int8Dtype,\n    Int16Dtype,\n    Int32Dtype,\n    Int64Dtype,\n    CategoricalDtype,\n    DatetimeTZDtype,\n    IntervalDtype,\n    PeriodDtype,\n    RangeIndex,\n    Int64Index,\n    UInt64Index,\n    Float64Index,\n    TimedeltaIndex,\n    IntervalIndex,\n    IndexSlice,\n    Grouper,\n    array,\n    Period,\n    show_versions,\n    DateOffset,\n    timedelta_range,\n    infer_freq,\n    interval_range,\n    ExcelWriter,\n    SparseArray,\n    SparseSeries,\n    SparseDataFrame,\n    datetime,\n    NamedAgg,\n)\nimport threading\nimport os\nimport types\nimport sys\n\nfrom .. import __version__\nfrom .concat import concat\nfrom .dataframe import DataFrame\nfrom .datetimes import to_datetime\nfrom .io import (\n    read_csv,\n    read_parquet,\n    read_json,\n    read_html,\n    read_clipboard,\n    read_excel,\n    read_hdf,\n    read_feather,\n    read_msgpack,\n    read_stata,\n    read_sas,\n    read_pickle,\n    read_sql,\n    read_gbq,\n    read_table,\n    read_fwf,\n    read_sql_table,\n    read_sql_query,\n    read_spss,\n    ExcelFile,\n    to_pickle,\n    HDFStore,\n)\nfrom .reshape import get_dummies, melt, crosstab, lreshape, wide_to_long\nfrom .series import Series\nfrom .general import (\n    isna,\n    isnull,\n    merge,\n    merge_asof,\n    merge_ordered,\n    pivot_table,\n    notnull,\n    notna,\n    pivot,\n)\nfrom .plotting import Plotting as plotting\nfrom .. import __execution_engine__ as execution_engine\n\n# Set this so that Pandas doesn't try to multithread by itself\nos.environ[\"OMP_NUM_THREADS\"] = \"1\"\nnum_cpus = 1\n\n\ndef initialize_ray():\n    import ray\n\n    \"\"\"Initializes ray based on environment variables and internal defaults.\"\"\"\n    if threading.current_thread().name == \"MainThread\":\n        import secrets\n\n        plasma_directory = None\n        cluster = os.environ.get(\"MODIN_RAY_CLUSTER\", None)\n        redis_address = os.environ.get(\"MODIN_REDIS_ADDRESS\", None)\n        redis_password = secrets.token_hex(16)\n        if cluster == \"True\" and redis_address is not None:\n            # We only start ray in a cluster setting for the head node.\n            ray.init(\n                include_webui=False,\n                ignore_reinit_error=True,\n                redis_address=redis_address,\n                redis_password=redis_password,\n                logging_level=100,\n            )\n        elif cluster is None:\n            object_store_memory = os.environ.get(\"MODIN_MEMORY\", None)\n            if os.environ.get(\"MODIN_OUT_OF_CORE\", \"False\").title() == \"True\":\n                from tempfile import gettempdir\n\n                plasma_directory = gettempdir()\n                # We may have already set the memory from the environment variable, we don't\n                # want to overwrite that value if we have.\n                if object_store_memory is None:\n                    # Round down to the nearest Gigabyte.\n                    mem_bytes = ray.utils.get_system_memory() // 10 ** 9 * 10 ** 9\n                    # Default to 8x memory for out of core\n                    object_store_memory = 8 * mem_bytes\n            # In case anything failed above, we can still improve the memory for Modin.\n            if object_store_memory is None:\n                # Round down to the nearest Gigabyte.\n                object_store_memory = int(\n                    0.6 * ray.utils.get_system_memory() // 10 ** 9 * 10 ** 9\n                )\n                # If the memory pool is smaller than 2GB, just use the default in ray.\n                if object_store_memory == 0:\n                    object_store_memory = None\n            else:\n                object_store_memory = int(object_store_memory)\n            ray.init(\n                include_webui=False,\n                ignore_reinit_error=True,\n                plasma_directory=plasma_directory,\n                object_store_memory=object_store_memory,\n                redis_address=redis_address,\n                redis_password=redis_password,\n                logging_level=100,\n                memory=object_store_memory,\n            )\n        # Register custom serializer for method objects to avoid warning message.\n        # We serialize `MethodType` objects when we use AxisPartition operations.\n        ray.register_custom_serializer(types.MethodType, use_pickle=True)\n\n        # Register a fix import function to run on all_workers including the driver.\n        # This is a hack solution to fix #647, #746\n        def move_stdlib_ahead_of_site_packages(*args):\n            site_packages_path = None\n            site_packages_path_index = -1\n            for i, path in enumerate(sys.path):\n                if sys.exec_prefix in path and path.endswith(\"site-packages\"):\n                    site_packages_path = path\n                    site_packages_path_index = i\n                    # break on first found\n                    break\n\n            if site_packages_path is not None:\n                # stdlib packages layout as follows:\n                # - python3.x\n                #   - typing.py\n                #   - site-packages/\n                #     - pandas\n                # So extracting the dirname of the site_packages can point us\n                # to the directory containing standard libraries.\n                sys.path.insert(\n                    site_packages_path_index, os.path.dirname(site_packages_path)\n                )\n\n        move_stdlib_ahead_of_site_packages()\n        ray.worker.global_worker.run_function_on_all_workers(\n            move_stdlib_ahead_of_site_packages\n        )\n\n\nif execution_engine == \"Ray\":\n    import ray\n\n    initialize_ray()\n    num_cpus = ray.cluster_resources()[\"CPU\"]\nelif execution_engine == \"Dask\":  # pragma: no cover\n    from distributed.client import get_client\n    import warnings\n\n    if threading.current_thread().name == \"MainThread\":\n        warnings.warn(\"The Dask Engine for Modin is experimental.\")\n        try:\n            client = get_client()\n        except ValueError:\n            from distributed import Client\n            import multiprocessing\n\n            num_cpus = multiprocessing.cpu_count()\n            client = Client(n_workers=num_cpus)\nelif execution_engine != \"Python\":\n    raise ImportError(\"Unrecognized execution engine: {}.\".format(execution_engine))\n\nDEFAULT_NPARTITIONS = max(4, int(num_cpus))\n\n__all__ = [\n    \"DataFrame\",\n    \"Series\",\n    \"read_csv\",\n    \"read_parquet\",\n    \"read_json\",\n    \"read_html\",\n    \"read_clipboard\",\n    \"read_excel\",\n    \"read_hdf\",\n    \"read_feather\",\n    \"read_msgpack\",\n    \"read_stata\",\n    \"read_sas\",\n    \"read_pickle\",\n    \"read_sql\",\n    \"read_gbq\",\n    \"read_table\",\n    \"read_spss\",\n    \"concat\",\n    \"eval\",\n    \"unique\",\n    \"value_counts\",\n    \"cut\",\n    \"to_numeric\",\n    \"factorize\",\n    \"test\",\n    \"qcut\",\n    \"to_datetime\",\n    \"get_dummies\",\n    \"isna\",\n    \"isnull\",\n    \"merge\",\n    \"pivot_table\",\n    \"date_range\",\n    \"Index\",\n    \"MultiIndex\",\n    \"Series\",\n    \"bdate_range\",\n    \"period_range\",\n    \"DatetimeIndex\",\n    \"to_timedelta\",\n    \"set_eng_float_format\",\n    \"options\",\n    \"set_option\",\n    \"CategoricalIndex\",\n    \"Timedelta\",\n    \"Timestamp\",\n    \"NaT\",\n    \"PeriodIndex\",\n    \"Categorical\",\n    \"__version__\",\n    \"melt\",\n    \"crosstab\",\n    \"plotting\",\n    \"Interval\",\n    \"UInt8Dtype\",\n    \"UInt16Dtype\",\n    \"UInt32Dtype\",\n    \"UInt64Dtype\",\n    \"SparseDtype\",\n    \"Int8Dtype\",\n    \"Int16Dtype\",\n    \"Int32Dtype\",\n    \"Int64Dtype\",\n    \"CategoricalDtype\",\n    \"DatetimeTZDtype\",\n    \"IntervalDtype\",\n    \"PeriodDtype\",\n    \"RangeIndex\",\n    \"Int64Index\",\n    \"UInt64Index\",\n    \"Float64Index\",\n    \"TimedeltaIndex\",\n    \"IntervalIndex\",\n    \"IndexSlice\",\n    \"Grouper\",\n    \"array\",\n    \"Period\",\n    \"show_versions\",\n    \"DateOffset\",\n    \"timedelta_range\",\n    \"infer_freq\",\n    \"interval_range\",\n    \"ExcelWriter\",\n    \"read_fwf\",\n    \"read_sql_table\",\n    \"read_sql_query\",\n    \"ExcelFile\",\n    \"to_pickle\",\n    \"HDFStore\",\n    \"lreshape\",\n    \"wide_to_long\",\n    \"merge_asof\",\n    \"merge_ordered\",\n    \"notnull\",\n    \"notna\",\n    \"pivot\",\n    \"SparseArray\",\n    \"SparseSeries\",\n    \"SparseDataFrame\",\n    \"datetime\",\n    \"NamedAgg\",\n    \"DEFAULT_NPARTITIONS\",\n]\n\ndel pandas\n", "path": "modin/pandas/__init__.py"}]}