Decorator used to capture the arguments of a function. This alternative to `joblib.delayed` is meant to be used in conjunction with `sklearn.utils.parallel.Parallel`. The latter captures the scikit- learn configuration by calling `sklearn.get_config()` in the current thread, prior t
(function)
| 93 | |
| 94 | # remove when https://github.com/joblib/joblib/issues/1071 is fixed |
| 95 | def delayed(function): |
| 96 | """Decorator used to capture the arguments of a function. |
| 97 | |
| 98 | This alternative to `joblib.delayed` is meant to be used in conjunction |
| 99 | with `sklearn.utils.parallel.Parallel`. The latter captures the scikit- |
| 100 | learn configuration by calling `sklearn.get_config()` in the current |
| 101 | thread, prior to dispatching the first task. The captured configuration is |
| 102 | then propagated and enabled for the duration of the execution of the |
| 103 | delayed function in the joblib workers. |
| 104 | |
| 105 | .. versionchanged:: 1.3 |
| 106 | `delayed` was moved from `sklearn.utils.fixes` to `sklearn.utils.parallel` |
| 107 | in scikit-learn 1.3. |
| 108 | |
| 109 | Parameters |
| 110 | ---------- |
| 111 | function : callable |
| 112 | The function to be delayed. |
| 113 | |
| 114 | Returns |
| 115 | ------- |
| 116 | output: tuple |
| 117 | Tuple containing the delayed function, the positional arguments, and the |
| 118 | keyword arguments. |
| 119 | """ |
| 120 | |
| 121 | @functools.wraps(function) |
| 122 | def delayed_function(*args, **kwargs): |
| 123 | return _FuncWrapper(function), args, kwargs |
| 124 | |
| 125 | return delayed_function |
| 126 | |
| 127 | |
| 128 | class _FuncWrapper: |
no outgoing calls
searching dependent graphs…