Runtime Configuration

Open in JupyterLite

Runtime settings live in dascore.config and affect subsequent operations.

import dascore as dc

print(dc.get_config().display_float_precision)
3

Scope

Function Scope Restoration
set_config(...) Process-wide base Until reset_config()
config_context(...) Current thread or task When the block exits
dc.set_config(display_float_precision=5)

with dc.config_context(display_float_precision=8):
    ...

dc.reset_config()

Concurrent contexts do not overwrite one another. Spool.map captures the active configuration and reapplies it in workers.

set_config is intended for application startup. Prefer config_context in libraries, tests, notebooks, and any operation that should restore the caller’s settings.

Common settings

  • patch_history="disabled" preserves existing history but stops appending entries.
  • patch_kind_attrs selects metadata fields that determine whether patches are compatible; see Patch compatibility.
  • display_float_precision controls displayed decimals.
  • display_array_threshold limits printed array values.
  • display_max_items limits children shown at each representation level.
  • display_max_patches disables expensive spool summaries above a threshold.
  • display_html switches notebook output to text.
  • display_html_open_lines sets when HTML sections start folded; 0 folds all sections.

patch_kind_attrs affects operators and spool partitioning. Conflicting values prevent combination; missing values act as wildcards for operators but form their own partition in spool operations.

with dc.config_context(patch_kind_attrs=("acquisition_key",)):
    ...  # tag and data_category no longer separate patch kinds
from IPython.display import HTML

with dc.config_context(patch_history="disabled", display_max_items=3):
    patch = dc.get_example_patch().abs()
    compact_html = HTML(patch._repr_html_())

compact_html
DASCore Patch ⚡
Coordinates (distance: 300, time: 2000)
kind min max span step shape dtype
*distance CoordRange 0 m 299 m <299 m> 1 m (300,) int64
*time CoordRange 2017-09-18T00:00:00 :07.996 <8 s> 0.004s · 250 Hz (2000,) datetime64[ns]
Data (float64, 4.6 MiB)
   [[0.778 0.238 0.824 ... 0.37  0.077 0.232]
    [0.497 0.442 0.703 ... 0.126 0.118 0.78 ]
    [0.207 0.195 0.174 ... 0.849 0.365 0.807]
    ...
    [0.619 0.105 0.669 ... 0.621 0.436 0.5  ]
    [0.757 0.259 0.091 ... 0.361 0.937 0.104]
    [0.158 0.295 0.585 ... 0.229 0.24  0.494]]
Attributes
    tag: random
    category: DAS

HTML output uses collapsible sections in notebooks and rendered documentation. Text output contains the same underlying summary and is suitable for terminals and logs.

with dc.config_context(display_html=False):
    text_output = repr(patch)

print(text_output)
DASCore Patch ⚡
----------------
➤ Coordinates (distance: 300, time: 2000)
    *distance: CoordRange( min: 0 m max: 299 m <299 m> step: 1 m shape: (300,) dtype: int64 )
    *time: CoordRange( min: 2017-09-18T00:00:00 max: …:07.996 <8 s> step: 0.004s · 250 Hz shape: (2000,) dtype: datetime64[ns] )
➤ Data (float64, 4.6 MiB)
   [[0.778 0.238 0.824 ... 0.37  0.077 0.232]
    [0.497 0.442 0.703 ... 0.126 0.118 0.78 ]
    [0.207 0.195 0.174 ... 0.849 0.365 0.807]
    ...
    [0.619 0.105 0.669 ... 0.621 0.436 0.5  ]
    [0.757 0.259 0.091 ... 0.361 0.937 0.104]
    [0.158 0.295 0.585 ... 0.229 0.24  0.494]]
➤ Attributes
    tag: random
    category: DAS
with dc.config_context(display_html_open_lines=0):
    folded_html = HTML(patch._repr_html_())

folded_html
DASCore Patch ⚡
Coordinates (distance: 300, time: 2000)
kind min max span step shape dtype
*distance CoordRange 0 m 299 m <299 m> 1 m (300,) int64
*time CoordRange 2017-09-18T00:00:00 :07.996 <8 s> 0.004s · 250 Hz (2000,) datetime64[ns]
Data (float64, 4.6 MiB)
   [[0.778 0.238 0.824 ... 0.37  0.077 0.232]
    [0.497 0.442 0.703 ... 0.126 0.118 0.78 ]
    [0.207 0.195 0.174 ... 0.849 0.365 0.807]
    ...
    [0.619 0.105 0.669 ... 0.621 0.436 0.5  ]
    [0.757 0.259 0.091 ... 0.361 0.937 0.104]
    [0.158 0.295 0.585 ... 0.229 0.24  0.494]]
Attributes
    tag: random
    category: DAS

For allow_remote_cache, HDF5 block-cache settings, and metadata-versus-read behavior, see Working with remote patches.

Remote settings include the cache directory, separate permissions for metadata and data materialization, first-download warnings, HDF5 block size, block count, and garbage-collection warnings. Keep conservative metadata defaults unless a workflow explicitly accepts downloads.