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

Function get

dask/config.py:604–657  ·  view source on GitHub ↗

Get elements from global config If ``override_with`` is not None this value will be passed straight back. Useful for getting kwarg defaults from Dask config. Use '.' for nested access Examples -------- >>> from dask import config >>> config.get('foo') # doctest:

(
    key: str,
    default: Any = no_default,
    config: dict | None = None,
    override_with: Any = None,
)

Source from the content-addressed store, hash-verified

602
603
604def get(
605 key: str,
606 default: Any = no_default,
607 config: dict | None = None,
608 override_with: Any = None,
609) -> Any:
610 """
611 Get elements from global config
612
613 If ``override_with`` is not None this value will be passed straight back.
614 Useful for getting kwarg defaults from Dask config.
615
616 Use '.' for nested access
617
618 Examples
619 --------
620 >>> from dask import config
621 >>> config.get('foo') # doctest: +SKIP
622 {'x': 1, 'y': 2}
623
624 >>> config.get('foo.x') # doctest: +SKIP
625 1
626
627 >>> config.get('foo.x.y', default=123) # doctest: +SKIP
628 123
629
630 >>> config.get('foo.y', override_with=None) # doctest: +SKIP
631 2
632
633 >>> config.get('foo.y', override_with=3) # doctest: +SKIP
634 3
635
636 See Also
637 --------
638 dask.config.set
639 """
640 if override_with is not None:
641 return override_with
642
643 if config is None: # Keep Sphinx autofunction documentation clean
644 config = global_config
645
646 keys = key.split(".")
647 result = config
648 for k in keys:
649 k = canonical_name(k, result)
650 try:
651 result = result[k]
652 except (TypeError, IndexError, KeyError):
653 if default is no_default:
654 raise
655 return default
656
657 return result
658
659
660def pop(key: str, default: Any = no_default, config: dict = config) -> Any:

Callers 6

test_getFunction · 0.90
paths_containing_keyFunction · 0.70
collectFunction · 0.70

Calls 2

canonical_nameFunction · 0.85
splitMethod · 0.80

Tested by 4

test_getFunction · 0.72