Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/datasets/arrow_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
)

import fsspec
import multiprocessing as mp
import numpy as np
import pandas as pd
import pyarrow as pa
Expand All @@ -69,7 +70,6 @@
HfApi,
)
from huggingface_hub.hf_api import HfHubHTTPError, RepoFile, RepositoryNotFoundError
from multiprocess import Pool
from requests import HTTPError
from tqdm.contrib.concurrent import thread_map

Expand Down Expand Up @@ -150,6 +150,12 @@

logger = logging.get_logger(__name__)

# Prefer spawn-based Pool on platforms where fork can be problematic
try:
Pool = mp.get_context("spawn").Pool # type: ignore[assignment]
except Exception:
Pool = mp.Pool # type: ignore[assignment]

PUSH_TO_HUB_WITHOUT_METADATA_CONFIGS_SPLIT_PATTERN_SHARDED = (
"data/{split}-[0-9][0-9][0-9][0-9][0-9]-of-[0-9][0-9][0-9][0-9][0-9]*.parquet"
)
Expand Down
Loading