def test_logging_mutual_exclusive(): """ Ensure that 'logging-file-config' and 'logging' have to be mutual exclusive. """ config = {"logging": {"dask": "warning"}, "logging-file-config": "/path/to/config"} with pytest.raises(RuntimeError): initialize_logging(config)
def test_logging_mutual_exclusive(): """ Ensure that 'logging-file-config' and 'logging' have to be mutual exclusive. """ config = {'logging': {'dask': 'warning'}, 'logging-file-config': '/path/to/config'} with pytest.raises(RuntimeError): initialize_logging(config)
def load_and_overwrite_dask_config(cluster_type, dask_config_path=None, overwrite=False): """ Load dask config, inject defaults for (selected) missing entries, and optionally overwrite in-place. Note: Also re-initializes the distributed logging configuration. """ if dask_config_path is None and 'DASK_CONFIG' in os.environ: dask_config_path = os.environ["DASK_CONFIG"] dask_config_path = dask_config_path or 'dask-config.yaml' dask_config_path = os.path.abspath(dask_config_path) if os.path.exists(dask_config_path): # Check for completely empty dask config file from ruamel.yaml import YAML yaml = YAML() config = yaml.load(open(dask_config_path, 'r')) if not config: dask_config = {} validate(dask_config, DaskConfigSchema, inject_defaults=True) else: dask_config = load_config(dask_config_path, DaskConfigSchema) else: dask_config = {} validate(dask_config, DaskConfigSchema, inject_defaults=True) # Don't pollute the config file with extra jobqueue parameters we aren't using if "jobqueue" in dask_config: for key in list(dask_config["jobqueue"].keys()): if key != cluster_type: del dask_config["jobqueue"][key] if len(dask_config["jobqueue"]) == 0: del dask_config["jobqueue"] if overwrite: dump_config(dask_config, dask_config_path) # This environment variable is recognized by dask itself os.environ["DASK_CONFIG"] = dask_config_path dask.config.paths.append(dask_config_path) dask.config.refresh() # Must be imported this way due to aliased name 'config' in distributed.__init__ from distributed.config import initialize_logging initialize_logging(dask.config.config)