Runtime Configuration

DASCore exposes a small runtime configuration surface through dascore.config.

from pathlib import Path

from dascore.config import get_config, config_context

print(get_config().remote_cache_dir)

with config_context(remote_cache_dir=Path("/tmp/dascore-remote-cache")):
    ...

Configuration changes affect subsequent operations only. For example, changing remote_cache_dir changes where future remote-file materializations are cached.

Two configuration tiers

Config can be changed in two ways:

  • set_config(...) changes the process-wide base permanently. The change is visible from every thread and task and is not restored automatically; reset_config() returns to defaults. Use it for application-level settings applied once at startup.
  • config_context(...) overrides the config only for the current thread or task. The override is restored when the block exits, and concurrent blocks in different threads never clobber one another.
import dascore as dc

dc.set_config(display_float_precision=5)  # permanent

with dc.config_context(display_float_precision=8):  # scoped to this block
    ...

dc.reset_config()  # drop the permanent change

Spool.map binds the config active when map is called and re-applies it in each worker, so overrides also reach thread- and process-pool workers.

History recording is also configurable:

  • patch_history="standard" preserves the default behavior and appends new entries to Patch.attrs.history.
  • patch_history="disabled" preserves any existing history but stops DASCore from appending new entries inside that config context.
from dascore.config import config_context

with config_context(patch_history="disabled"):
    ...

For remote IO settings such as allow_remote_cache, allow_remote_cache_for_metadata, warn_on_remote_cache, remote_hdf5_block_size, remote_hdf5_max_blocks, and warn_on_gc_pause, plus examples of metadata-only vs read-time behavior, see Working with Remote Patches.