diff --git a/Config.md b/Config.md index 89c6a93..ab38349 100644 --- a/Config.md +++ b/Config.md @@ -20,7 +20,7 @@ NetworkXConfig(backend_priority=[], backends=Config(parallel=ParallelConfig(back ### Note -The default settings of `joblib.parallel_config` are the same as the default configs in the `ParallelConfig` class, except for the `backend` config, which is `None` in `joblib.parallel_config` and `"loky"` in `ParallelConfig`. This prevents errors when using the NetworkX config, as the internal `joblib.Parallel`'s `backend` default is `"loky"` when not specified. This consistency in user experience is maintained for ease of use. +The default settings of `joblib.parallel_config` are the same as the default configs in the `ParallelConfig` class, except for the `backend` config, which is `None` in `joblib.parallel_config` and `"loky"` in `ParallelConfig`. This prevents errors when using the NetworkX config, as the internal `joblib.Parallel`'s `backend` default is `"loky"` when not specified. This consistency in user experience is maintained for ease of use. Additinally, by default the `n_jobs` value is `-1`. ## Modifying Configuration diff --git a/README.md b/README.md index 7a07258..441e03d 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,6 @@ import networkx as nx import nx_parallel as nxp nxp_config = nx.config.backends.parallel -nxp_config.backend = "loky" nxp_config.n_jobs = 4 nxp_config.verbose = 15 @@ -126,11 +125,9 @@ nxp.betweenness_centrality(G) # method 4 : using nx-parallel implementation with ParallelGraph object nxp.betweenness_centrality(H) - -# output : {0: 0.0, 1: 0.6666666666666666, 2: 0.6666666666666666, 3: 0.0} ``` -For more on how to play with configurations in nx-parallel refer [Config.md](./Config.md)! +In nx-parallel, by default the `loky` backend is used and all the CPU cores are used. For more on how to play with configurations in nx-parallel refer the [Config.md](./Config.md)! ### Notes diff --git a/_nx_parallel/config.py b/_nx_parallel/config.py index b9c590b..13dd35c 100644 --- a/_nx_parallel/config.py +++ b/_nx_parallel/config.py @@ -6,7 +6,7 @@ @dataclass class ParallelConfig(Config): backend: str = "loky" - n_jobs: int = None + n_jobs: int = -1 verbose: int = 0 temp_folder: str = None max_nbytes: Union[int, str] = "1M" diff --git a/nx_parallel/utils/chunk.py b/nx_parallel/utils/chunk.py index bbb7d01..5df28a9 100644 --- a/nx_parallel/utils/chunk.py +++ b/nx_parallel/utils/chunk.py @@ -21,9 +21,8 @@ def chunks(iterable, n): yield x -def cpu_count(n_jobs=None): - """Returns the positive value of `n_jobs` using - `joblib.parallel.get_active_backend()`.""" +def cpu_count(n_jobs=None): # todo: rename to get_n_jobs + """Returns the positive value of `n_jobs`.""" if "PYTEST_CURRENT_TEST" in os.environ: return 2 else: