From 165ccdbea6a7fa5806f67b89b036f78bcdd5fea4 Mon Sep 17 00:00:00 2001 From: Fede Raimondo Date: Mon, 21 Oct 2024 15:03:38 +0200 Subject: [PATCH 1/4] Control parallel column transformer in filter columns --- julearn/transformers/dataframe/filter_columns.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/julearn/transformers/dataframe/filter_columns.py b/julearn/transformers/dataframe/filter_columns.py index d8e863189..cf1e16cbe 100644 --- a/julearn/transformers/dataframe/filter_columns.py +++ b/julearn/transformers/dataframe/filter_columns.py @@ -15,6 +15,7 @@ JuTransformer, ensure_column_types, ) +from ...config import get_config from ...utils.typing import DataLike @@ -53,7 +54,9 @@ def __init__( ) def _fit( - self, X: pd.DataFrame, y: Optional[DataLike] = None # noqa: N803 + self, + X: pd.DataFrame, + y: Optional[DataLike] = None, # noqa: N803 ) -> "FilterColumns": """Fit the transformer. @@ -75,6 +78,9 @@ def _fit( transformers=[("keep", "passthrough", apply_to_selector)], remainder="drop", verbose_feature_names_out=False, + n_jobs=None + if get_config("enable_parallel_column_transformers") + else 1, ) self.filter_columns_.fit(X, y) return self From 73eb553048951e542b8053e2c284d66a1dfcf3db Mon Sep 17 00:00:00 2001 From: Fede Raimondo Date: Mon, 21 Oct 2024 15:06:49 +0200 Subject: [PATCH 2/4] Add newsfragment --- docs/changes/newsfragments/277.enh | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/changes/newsfragments/277.enh diff --git a/docs/changes/newsfragments/277.enh b/docs/changes/newsfragments/277.enh new file mode 100644 index 000000000..d1e26291e --- /dev/null +++ b/docs/changes/newsfragments/277.enh @@ -0,0 +1 @@ +Avoid parallel calls in :class:`.FilterColumns` if not specified by the user in the :mod:`.config` module by `Fede Raimondo`_ \ No newline at end of file From 3aa6f3e0e7daac199cc4559b653a24462592f196 Mon Sep 17 00:00:00 2001 From: Fede Raimondo Date: Mon, 21 Oct 2024 15:08:14 +0200 Subject: [PATCH 3/4] Fix linter --- julearn/transformers/dataframe/filter_columns.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/julearn/transformers/dataframe/filter_columns.py b/julearn/transformers/dataframe/filter_columns.py index cf1e16cbe..84ca07899 100644 --- a/julearn/transformers/dataframe/filter_columns.py +++ b/julearn/transformers/dataframe/filter_columns.py @@ -55,8 +55,8 @@ def __init__( def _fit( self, - X: pd.DataFrame, - y: Optional[DataLike] = None, # noqa: N803 + X: pd.DataFrame, # noqa: N803 + y: Optional[DataLike] = None, ) -> "FilterColumns": """Fit the transformer. From f8b68fa1a10e4ef8481add9e295d9d615ba1f760 Mon Sep 17 00:00:00 2001 From: Fede Raimondo Date: Mon, 21 Oct 2024 18:17:23 +0200 Subject: [PATCH 4/4] Add config module to doc --- docs/api/config.rst | 21 +++++++++++++++++++++ docs/api/index.rst | 1 + 2 files changed, 22 insertions(+) create mode 100644 docs/api/config.rst diff --git a/docs/api/config.rst b/docs/api/config.rst new file mode 100644 index 000000000..525a5ab45 --- /dev/null +++ b/docs/api/config.rst @@ -0,0 +1,21 @@ +Config +====== + +.. automodule:: julearn.config + :no-members: + :no-inherited-members: + + +See :ref:`configuration` for more information on the flags that can be set. + +Functions +--------- + +.. currentmodule:: julearn.config + +.. autosummary:: + :toctree: generated/ + :template: function.rst + + set_config + get_config diff --git a/docs/api/index.rst b/docs/api/index.rst index 31d1f1f17..b05427e8c 100644 --- a/docs/api/index.rst +++ b/docs/api/index.rst @@ -18,3 +18,4 @@ API Reference prepare.rst stats.rst viz.rst + config.rst \ No newline at end of file