fsspec_utils.utils.misc
API Reference¶
run_parallel()
¶
Run a function for a list of parameters in parallel.
Provides parallel execution with progress tracking and flexible argument handling.
Parameters:
Name | Type | Description |
---|---|---|
func |
Callable |
The function to be executed in parallel. |
*args |
Any |
Positional arguments to pass to func . If an iterable, func will be called for each item. |
n_jobs |
int |
The number of CPU cores to use. -1 means all available cores. |
backend |
str |
The backend to use for parallel processing. Options include 'loky', 'threading', 'multiprocessing', and 'sequential'. |
verbose |
bool |
If True, a progress bar will be displayed during execution. |
**kwargs |
Any |
Keyword arguments to pass to func . If an iterable, func will be called for each item. |
Returns:
list
: List of function outputs in the same order as inputs.
Raises:
ValueError
: If no iterable arguments provided or length mismatch.
Examples:
get_partitions_from_path()
¶
Extract dataset partitions from a file path.
Parses file paths to extract partition information based on different partitioning schemes.
Parameters:
Name | Type | Description |
---|---|---|
path |
str |
The file path from which to extract partition information. |
partitioning |
str or list[str] or None |
The partitioning scheme to use. Can be "hive" for Hive-style, a string for a single partition column, a list of strings for multiple partition columns, or None for no specific partitioning. |
Returns:
list[tuple[str, str]]
: List of tuples containing (column, value) pairs.
Examples:
path_to_glob()
¶
Convert a path to a glob pattern for file matching.
Intelligently converts paths to glob patterns that match files of the specified format, handling various directory and wildcard patterns.
Parameters:
Name | Type | Description |
---|---|---|
path |
str |
The file or directory path to convert into a glob pattern. |
format |
str or None |
The desired file format or extension to match (e.g., "parquet", "csv", "json"). If None, the format is inferred from the path. |
Returns:
str
: Glob pattern for matching files
Example:
check_optional_dependency()
¶
Check if an optional dependency is available.
Parameters:
Name | Type | Description |
---|---|---|
package_name |
str |
The name of the optional package to check for availability. |
feature_name |
str |
A descriptive name of the feature that requires this package. |
Raises:
ImportError
: If the package is not available