Return a list of open-file objects given a list of input-file paths. WARNING: This utility is experimental, and is meant for internal ``dask.dataframe`` use only. Parameters ---------- paths : list(str) Remote or local path of the parquet file fs : fsspec object
(
paths,
fs=None,
context_stack=None,
open_file_func=None,
precache_options=None,
**kwargs,
)
| 145 | |
| 146 | |
| 147 | def _open_input_files( |
| 148 | paths, |
| 149 | fs=None, |
| 150 | context_stack=None, |
| 151 | open_file_func=None, |
| 152 | precache_options=None, |
| 153 | **kwargs, |
| 154 | ): |
| 155 | """Return a list of open-file objects given |
| 156 | a list of input-file paths. |
| 157 | |
| 158 | WARNING: This utility is experimental, and is meant |
| 159 | for internal ``dask.dataframe`` use only. |
| 160 | |
| 161 | Parameters |
| 162 | ---------- |
| 163 | paths : list(str) |
| 164 | Remote or local path of the parquet file |
| 165 | fs : fsspec object, optional |
| 166 | File-system instance to use for file handling |
| 167 | context_stack : contextlib.ExitStack, Optional |
| 168 | Context manager to use for open files. |
| 169 | open_file_func : callable, optional |
| 170 | Callable function to use for file opening. If this argument |
| 171 | is specified, ``open_file_func(path, **kwargs)`` will be used |
| 172 | to open each file in ``paths``. Default is ``fs.open``. |
| 173 | precache_options : dict, optional |
| 174 | Dictionary of key-word arguments to use for precaching. |
| 175 | If ``precache_options`` contains ``{"method": "parquet"}``, |
| 176 | ``fsspec.parquet.open_parquet_file`` will be used for remote |
| 177 | storage. |
| 178 | **kwargs : |
| 179 | Key-word arguments to pass to the appropriate open function |
| 180 | """ |
| 181 | # Use call-back function if specified |
| 182 | if open_file_func is not None: |
| 183 | return [ |
| 184 | _set_context(open_file_func(path, **kwargs), context_stack) |
| 185 | for path in paths |
| 186 | ] |
| 187 | |
| 188 | # Check if we are using `fsspec.parquet`. |
| 189 | # In the future, fsspec should be able to handle |
| 190 | # `{"method": "parquet"}`. However, for now we |
| 191 | # will redirect to `open_parquet_file` manually |
| 192 | precache_options = (precache_options or {}).copy() |
| 193 | precache = precache_options.pop("method", None) |
| 194 | if ( |
| 195 | precache == "parquet" |
| 196 | and fs is not None |
| 197 | and not _is_local_fs(fs) |
| 198 | and Version(fsspec.__version__) > Version("2021.11.0") |
| 199 | ): |
| 200 | kwargs.update(precache_options) |
| 201 | row_groups = kwargs.pop("row_groups", None) or ([None] * len(paths)) |
| 202 | cache_type = kwargs.pop("cache_type", "parts") |
| 203 | if cache_type != "parts": |
| 204 | raise ValueError( |
no test coverage detected