Repository: modin-project/modin

Issue:
`read_csv` defaults to pandas in case of reading from buffer
### System information
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: `Windows 10`
- **Modin version** (`modin.__version__`): 7a36071c0b00e0392615a0dd9d5c2ddd5f7c0d27
- **Python version**: `3.8.13`
- **Code we can use to reproduce**:

```python
import modin.pandas as pd
import pandas


df = pd.DataFrame({"col1": [1,2,3,4,5], "col2": [2,3,4,5,6]})

unique_filename = "test_read_csv_buffer.csv"
df.to_csv(unique_filename)

with open(unique_filename) as buffer:
    df_pandas = pandas.read_csv(buffer)
    buffer.seek(0)
    df_modin = pd.read_csv(buffer)
    print(df_pandas, "\n")
    print(df_modin)
```

<!--
You can obtain the Modin version with

python -c "import modin; print(modin.__version__)"
-->

### Describe the problem
<!-- Describe the problem clearly here. -->

Code was added some time ago to speed up this case, however it is currently not being used correctly. This is because the original variable (buffer) is being passed, not the filename associated with the buffer and computed by our function (name in `filepath_or_buffer_md`).

Wrong place:
https://github.com/modin-project/modin/blob/7a36071c0b00e0392615a0dd9d5c2ddd5f7c0d27/modin/core/io/text/text_file_dispatcher.py#L990

### Source code / logs
<!-- Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem. -->

```python
UserWarning: Ray execution environment not yet initialized. Initializing...
To remove this warning, run the following python code before doing dataframe operations:

    import ray
    ray.init(runtime_env={'env_vars': {'__MODIN_AUTOIMPORT_PANDAS__': '1'}})

UserWarning: Distributing <class 'dict'> object. This may take some time.
UserWarning: For performance reasons, the filepath will be used in place of the file handle passed in to load the data
UserWarning: Parameters provided defaulting to pandas implementation.
Please refer to https://modin.readthedocs.io/en/stable/supported_apis/defaulting_to_pandas.html for explanation.
   Unnamed: 0  col1  col2
0           0     1     2
1           1     2     3
2           2     3     4
3           3     4     5
4           4     5     6

   Unnamed: 0  col1  col2
0           0     1     2
1           1     2     3
2           2     3     4
3           3     4     5
4           4     5     6
```


Discussion:

Resolving patch:
diff --git a/modin/core/io/text/text_file_dispatcher.py b/modin/core/io/text/text_file_dispatcher.py
--- a/modin/core/io/text/text_file_dispatcher.py
+++ b/modin/core/io/text/text_file_dispatcher.py
@@ -68,7 +68,12 @@ def get_path_or_buffer(cls, filepath_or_buffer):
         use it without having to fall back to pandas and share file objects between
         workers. Given a filepath, return it immediately.
         """
-        if hasattr(filepath_or_buffer, "name"):
+        if (
+            hasattr(filepath_or_buffer, "name")
+            and hasattr(filepath_or_buffer, "seekable")
+            and filepath_or_buffer.seekable()
+            and filepath_or_buffer.tell() == 0
+        ):
             buffer_filepath = filepath_or_buffer.name
             if cls.file_exists(buffer_filepath):
                 warnings.warn(
@@ -990,7 +995,7 @@ def _read(cls, filepath_or_buffer, **kwargs):
         )
 
         (use_modin_impl, fallback_reason) = cls.check_parameters_support(
-            filepath_or_buffer,
+            filepath_or_buffer_md,
             kwargs,
             skiprows_md,
             header_size,
@@ -1009,7 +1014,7 @@ def _read(cls, filepath_or_buffer, **kwargs):
         )
 
         pd_df_metadata = cls.read_callback(
-            filepath_or_buffer,
+            filepath_or_buffer_md,
             **dict(kwargs, nrows=1, skipfooter=0, index_col=index_col),
         )
         column_names = pd_df_metadata.columns


Test patch:
diff --git a/modin/pandas/test/test_io.py b/modin/pandas/test/test_io.py
--- a/modin/pandas/test/test_io.py
+++ b/modin/pandas/test/test_io.py
@@ -1205,14 +1205,15 @@ def wrapped_read_csv(file, method):
             ),
         ],
     )
-    def test_read_csv_file_handle(self, read_mode, make_csv_file):
-
+    @pytest.mark.parametrize("buffer_start_pos", [0, 10])
+    def test_read_csv_file_handle(self, read_mode, make_csv_file, buffer_start_pos):
         unique_filename = get_unique_filename()
         make_csv_file(filename=unique_filename)
 
         with open(unique_filename, mode=read_mode) as buffer:
+            buffer.seek(buffer_start_pos)
             df_pandas = pandas.read_csv(buffer)
-            buffer.seek(0)
+            buffer.seek(buffer_start_pos)
             df_modin = pd.read_csv(buffer)
             df_equals(df_modin, df_pandas)