Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEA parallel_config context manager to allow more fine-grained control #1392

Merged
merged 19 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ In development
previous versions of Joblib.
https://github.com/joblib/joblib/pull/1374

- Add the `parallel_config` context manager to allow for more fine-grained
control over the backend configuration. It should be used in place of the
`parallel_backend` context manager. In particular, it has the advantage
of not requiring to set a specific backend in the context manager.
https://github.com/joblib/joblib/pull/1392

Release 1.2.0
-------------

Expand Down
3 changes: 2 additions & 1 deletion joblib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
from .parallel import cpu_count
from .parallel import register_parallel_backend
from .parallel import parallel_backend
from .parallel import parallel_config
from .parallel import effective_n_jobs
from ._cloudpickle_wrapper import wrap_non_picklable_objects

Expand All @@ -130,7 +131,7 @@
'load', 'Parallel', 'delayed', 'cpu_count', 'effective_n_jobs',
'register_parallel_backend', 'parallel_backend',
'register_store_backend', 'register_compressor',
'wrap_non_picklable_objects']
'wrap_non_picklable_objects', 'parallel_config']


# Workaround issue discovered in intel-openmp 2019.5:
Expand Down
10 changes: 10 additions & 0 deletions joblib/_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Adapted from https://stackoverflow.com/a/9558001/2536294

import ast
from dataclasses import dataclass
import operator as op

# supported operators
Expand Down Expand Up @@ -42,3 +43,12 @@ def eval_(node):
return operators[type(node.op)](eval_(node.operand))
else:
raise TypeError(node)


@dataclass(frozen=True)
class _Sentinel:
"""A sentinel to mark a parameter as not explicitly set"""
default_value: object

def __repr__(self):
return f"default({self.default_value!r})"