MCPcopy
hub / github.com/dask/dask / set

Class set

dask/config.py:372–496  ·  view source on GitHub ↗

Temporarily set configuration values within a context manager Parameters ---------- arg : mapping or None, optional A mapping of configuration key-value pairs to set. **kwargs : Additional key-value pairs to set. If ``arg`` is provided, values set in ``arg``

Source from the content-addressed store, hash-verified

370
371
372class set:
373 """Temporarily set configuration values within a context manager
374
375 Parameters
376 ----------
377 arg : mapping or None, optional
378 A mapping of configuration key-value pairs to set.
379 **kwargs :
380 Additional key-value pairs to set. If ``arg`` is provided, values set
381 in ``arg`` will be applied before those in ``kwargs``.
382 Double-underscores (``__``) in keyword arguments will be replaced with
383 ``.``, allowing nested values to be easily set.
384
385 Examples
386 --------
387 >>> import dask
388
389 Set ``'foo.bar'`` in a context, by providing a mapping.
390
391 >>> with dask.config.set({'foo.bar': 123}):
392 ... pass
393
394 Set ``'foo.bar'`` in a context, by providing a keyword argument.
395
396 >>> with dask.config.set(foo__bar=123):
397 ... pass
398
399 Set ``'foo.bar'`` globally.
400
401 >>> dask.config.set(foo__bar=123) # doctest: +SKIP
402
403 See Also
404 --------
405 dask.config.get
406 """
407
408 config: dict
409 # [(op, path, value), ...]
410 _record: list[tuple[Literal["insert", "replace"], tuple[str, ...], Any]]
411
412 def __init__(
413 self,
414 arg: Mapping | None = None,
415 config: dict | None = None,
416 lock: threading.Lock = config_lock,
417 **kwargs,
418 ):
419 if config is None: # Keep Sphinx autofunction documentation clean
420 config = global_config
421
422 with lock:
423 self.config = config
424 self._record = []
425
426 if arg is not None:
427 for key, value in arg.items():
428 key = check_deprecations(key)
429 self._assign(key.split("."), value, config)

Callers 15

collect_envFunction · 0.85
renameFunction · 0.85
__init__Method · 0.85
to_graphvizFunction · 0.85
_to_cytoscape_jsonFunction · 0.85
getFunction · 0.85
keys_in_tasksFunction · 0.85
_toposortFunction · 0.85
getFunction · 0.85
project_columnsMethod · 0.85
cullMethod · 0.85

Calls

no outgoing calls

Tested by 15

test_read_bytesFunction · 0.68
test_read_bytes_blockFunction · 0.68
test_open_files_writeFunction · 0.68
test_read_bytesFunction · 0.68
test_read_bytes_blockFunction · 0.68
test_files_per_partitionFunction · 0.68
test_pluckFunction · 0.68
test_foldFunction · 0.68
test_fold_bagFunction · 0.68
test_foldbyFunction · 0.68
test_read_textFunction · 0.68