MCPcopy Create free account
hub / github.com/dask/dask / collect

Function collect

dask/config.py:499–561  ·  view source on GitHub ↗

Collect configuration from paths and environment variables Parameters ---------- paths : list[str] A list of paths to search for yaml config files env : Mapping[str, str] The system environment variables Returns ------- config: dict See Also

(paths: list[str] = paths, env: Mapping[str, str] | None = None)

Source from the content-addressed store, hash-verified

497
498
499def collect(paths: list[str] = paths, env: Mapping[str, str] | None = None) -> dict:
500 """
501 Collect configuration from paths and environment variables
502
503 Parameters
504 ----------
505 paths : list[str]
506 A list of paths to search for yaml config files
507
508 env : Mapping[str, str]
509 The system environment variables
510
511 Returns
512 -------
513 config: dict
514
515 See Also
516 --------
517 dask.config.refresh: collect configuration and update into primary config
518 """
519 if env is None:
520 env = os.environ
521
522 configs = [*collect_yaml(paths=paths), collect_env(env=env)]
523 result: dict[str, Any] = {}
524
525 # In case there is deprecated key in a lower-priority config (e.g. deployed by the
526 # root user for an old version of Dask), suppress the warning if the key is
527 # explicitly overridden in a higher-priority config (e.g. the user's venv for a
528 # newer version of Dask).
529
530 # Only warn once per deprecated key across all configs
531 seen_deprecations = builtins.set()
532
533 for config in configs[::-1]:
534 for depr_key, new_key in rename(config=config).items():
535 if depr_key in seen_deprecations:
536 continue
537 seen_deprecations.add(depr_key)
538 try:
539 get(new_key or f"ignore-deprecated.{depr_key}", config=result)
540 # Updated key is present in a higher-priority config;
541 # suppress the warning
542 except KeyError:
543 if new_key:
544 warnings.warn(
545 f"Dask configuration key {depr_key!r} has been deprecated; "
546 f"please use {new_key!r} instead",
547 FutureWarning,
548 )
549 else:
550 warnings.warn(
551 f"Dask configuration key {depr_key!r} has been removed; you "
552 f"may suppress this warning by setting "
553 f"'ignore-deprecated.{depr_key}' in a higher-priority "
554 "configuration file or in the environment variables",
555 FutureWarning,
556 )

Callers 3

test_collectFunction · 0.90
test_collect_env_noneFunction · 0.90
refreshFunction · 0.70

Calls 8

collect_yamlFunction · 0.85
collect_envFunction · 0.85
renameFunction · 0.85
updateFunction · 0.85
setMethod · 0.80
getFunction · 0.70
itemsMethod · 0.45
addMethod · 0.45

Tested by 2

test_collectFunction · 0.72
test_collect_env_noneFunction · 0.72