def determine_processes(
    parallel: Optional[Union[bool, int]] = None,
    rows_total: Optional[int] = None,
) -> Union[bool, int]:
    """Determine the number of processes to use for parallel processing."""
    if rows_total is not None and rows_total <= 1:
        # Disable parallel processing if there is no rows or only one row.
        return False
    if parallel is None and os.environ.get("DATACHAIN_SETTINGS_PARALLEL") is not None:
        parallel = int(os.environ["DATACHAIN_SETTINGS_PARALLEL"])
    if parallel is None or parallel is False or parallel == 0:
        return False
    if parallel is True:
        return True
    if parallel < 0:
        return True
    if parallel == 1:
        # Disable parallel processing if only one process is requested.
        return False
    return parallel
Determine the number of processes to use for parallel processing.
src/datachain/utils.py