Skip to content

set_config

sklearn_wrap.config.set_config(*, trusted_modules=None)

Persistently update the sklearn-wrap configuration for the current thread.

Parameters

Name Type Description Default
trusted_modules frozenset[str] or None

If not None, replace the current set of trusted top-level packages used by EstimatorConfig.build.

None

Examples

>>> set_config(trusted_modules=frozenset({"sklearn", "xgboost"}))
>>> get_config()["trusted_modules"] == frozenset({"sklearn", "xgboost"})
True
>>> reset_config()  # clean up

See Also

get_config : Retrieve the current configuration. config_context : Temporarily update the configuration. reset_config : Restore default configuration.

Source Code

Show/Hide source
def set_config(*, trusted_modules: frozenset[str] | None = None) -> None:
    """Persistently update the sklearn-wrap configuration for the current thread.

    Parameters
    ----------
    trusted_modules : frozenset[str] or None
        If not ``None``, replace the current set of trusted top-level packages
        used by `EstimatorConfig.build`.

    Examples
    --------
    >>> set_config(trusted_modules=frozenset({"sklearn", "xgboost"}))
    >>> get_config()["trusted_modules"] == frozenset({"sklearn", "xgboost"})
    True
    >>> reset_config()  # clean up

    See Also
    --------
    get_config : Retrieve the current configuration.
    config_context : Temporarily update the configuration.
    reset_config : Restore default configuration.
    """
    local_config = getattr(_threadlocal, "config", None)
    if local_config is None:
        _threadlocal.config = {}
    if trusted_modules is not None:
        _threadlocal.config["trusted_modules"] = trusted_modules