Skip to content

Commit

Permalink
FEA parallel_config context manager to allow more fine-grained control (
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremiedbb committed Apr 26, 2023
1 parent 41b70ff commit ebacd8c
Show file tree
Hide file tree
Showing 5 changed files with 546 additions and 154 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ In development
tracebacks and more efficient running time.
https://github.com/joblib/joblib/pull/1393

- 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})"

0 comments on commit ebacd8c

Please sign in to comment.