# Buggy code
def parse(fname, **kwargs):
    num_splits = kwargs.pop("num_splits", None)
    columns = kwargs.get("columns", None)
    if num_splits is None:
        return pandas.read_parquet(fname, **kwargs)
    kwargs["use_pandas_metadata"] = True
    df = pandas.read_parquet(fname, **kwargs)
    if isinstance(df.index, pandas.RangeIndex):
        idx = len(df.index)
    else:
        idx = df.index
    columns = [c for c in columns if c not in df.index.names and c in df.columns]
    if columns is not None:
        df = df[columns]
    # Append the length of the index here to build it externally
    return _split_result_for_readers(0, num_splits, df) + [idx, df.dtypes]


# Traceback (FileNotFoundError)
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-14-814dc08ef229> in <module>
----> 1 df2 = mpd.read_parquet(path)

/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/modin/pandas/io.py in read_parquet(path, engine, columns, **kwargs)
40     return DataFrame(
41         query_compiler=EngineDispatcher.read_parquet(
---> 42             path=path, columns=columns, engine=engine, **kwargs
43         )
44     )

/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/modin/data_management/dispatcher.py in read_parquet(cls, **kwargs)
105     @classmethod
106     def read_parquet(cls, **kwargs):
--> 107         return cls.__engine._read_parquet(**kwargs)
108
109     @classmethod

/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/modin/data_management/factories.py in _read_parquet(cls, **kwargs)
46     @classmethod
47     def _read_parquet(cls, **kwargs):
---> 48         return cls.io_cls.read_parquet(**kwargs)
49
50     @classmethod

/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/modin/engines/base/io/file_reader.py in read(cls, *args, **kwargs)
27     @classmethod
28     def read(cls, *args, **kwargs):
---> 29         query_compiler = cls._read(*args, **kwargs)
30         # TODO (devin-petersohn): Make this section more general for non-pandas kernel
31         # implementations.

/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/modin/engines/base/io/column_stores/parquet_reader.py in _read(cls, path, engine, columns, **kwargs)
68                 column_names = pd.schema.names
69             else:
---> 70                 meta = ParquetFile(path).metadata
71                 column_names = meta.schema.names
72             if meta is not None:

/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/pyarrow/parquet.py in __init__(self, source, metadata, common_metadata, read_dictionary, memory_map, buffer_size)
135         self.reader.open(source, use_memory_map=memory_map,
136                          buffer_size=buffer_size,
--> 137                          read_dictionary=read_dictionary, metadata=metadata)
138         self.common_metadata = common_metadata
139         self._nested_paths_by_prefix = self._build_nested_paths()

/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/pyarrow/_parquet.pyx in pyarrow._parquet.ParquetReader.open()

/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/pyarrow/io.pxi in pyarrow.lib.get_reader()

/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/pyarrow/io.pxi in pyarrow.lib._get_native_file()

/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/pyarrow/io.pxi in pyarrow.lib.OSFile.__cinit__()

/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/pyarrow/io.pxi in pyarrow.lib.OSFile._open_readable()

/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/pyarrow/error.pxi in pyarrow.lib.pyarrow_internal_check_status()

/opt/anaconda3/envs/myenv/lib/python3.7/site-packages/pyarrow/error.pxi in pyarrow.lib.check_status()

FileNotFoundError: [Errno 2] Failed to open local file s3://bucket_name/data/dataframe.snappy.parquet'. Detail: [errno 2] No such file or directory

# Fixed code
def parse(fname, **kwargs):
    num_splits = kwargs.pop("num_splits", None)
    columns = kwargs.get("columns", None)
    if fname.startswith("s3://"):
        from botocore.exceptions import NoCredentialsError
        import s3fs

        try:
            fs = s3fs.S3FileSystem()
            fname = fs.open(fname)
        except NoCredentialsError:
            fs = s3fs.S3FileSystem(anon=True)
            fname = fs.open(fname)

    if num_splits is None:
        return pandas.read_parquet(fname, **kwargs)
    kwargs["use_pandas_metadata"] = True
    df = pandas.read_parquet(fname, **kwargs)
    if isinstance(df.index, pandas.RangeIndex):
        idx = len(df.index)
    else:
        idx = df.index
    columns = [c for c in columns if c not in df.index.names and c in df.columns]
    if columns is not None:
        df = df[columns]
    # Append the length of the index here to build it externally
    return _split_result_for_readers(0, num_splits, df) + [idx, df.dtypes]