ENH add a call_context parameter to Parallel to make it possible to propagate runtime configuration to the workers#1668
Open
glemaitre wants to merge 30 commits into
Open
Conversation
glemaitre
marked this pull request as draft
February 26, 2025 16:32
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1668 +/- ##
==========================================
- Coverage 95.51% 95.48% -0.03%
==========================================
Files 46 47 +1
Lines 7711 7849 +138
==========================================
+ Hits 7365 7495 +130
- Misses 346 354 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
glemaitre
commented
Feb 27, 2025
Contributor
|
No, I think you can use the context in `_get_sequential_output`
…On Thu, Feb 27, 2025, 20:46 Guillaume Lemaitre ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In joblib/test/test_parallel.py
<#1668 (comment)>:
> + return get_config()["parameter"]
+
+
+class SilenceWarnings(AbstractContextManager):
+ # With python >= 3.11, we could use directly `warnings.catch_warnings` context
+ # manager since `action` parameter is supported.
+ def __enter__(self):
+ warnings.filterwarnings(action="ignore", category=RuntimeWarning)
+
+ def __exit__(self, exc_type, exc_value, traceback):
+ warnings.resetwarnings()
+
+
***@***.***("n_jobs", [1, 2])
***@***.***("backend", ["loky", "threading", "multiprocessing"])
***@***.***("return_as", ["list", "generator", "generator_unordered"])
So I assume that at the end, we might really need to rewrap the delayed
function to make sure that when consumed, the function is executed within
the context manager.
—
Reply to this email directly, view it on GitHub
<#1668 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZKZ6P4ZS3I4E4TXTWDO432R5TPTAVCNFSM6AAAAABX5VZAP6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDMNBYHEZDKMZXGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
glemaitre
marked this pull request as ready for review
February 28, 2025 22:03
Contributor
Author
|
So this PR should be ready for review with an example, some documentation, some texts, and the code ;) |
Contributor
Author
|
OK so we are in trouble with backward compatibility then :( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR allows to call some context manager before calling the function in the parallel context. It provides the following functionalities:
call_contextinParallelto pass a list of context manager_CALL_CONTEXTaccessible withregister_call_contextandunregister_call_contextandlist_call_context_names.set_config,get_config, andconfig_context.config_contextfor joblib to_CALL_CONTEXT.