Skip to content

Clarify precedence of nuclear data cache dir across config layers #235

@KedoKudo

Description

@KedoKudo

Summary

PleiadesConfig has three fields that can define the nuclear data cache directory:

  1. nuclear_data_cache_dir (top-level legacy field)
  2. nuclear.data_cache_dir (nested NuclearConfig field)
  3. workspace.endf_dir (workspace subdirectory)

The _normalize_config validator syncs these bidirectionally, but the precedence rules are asymmetric and undocumented:

# Lines 309-312 in config.py
if self.nuclear.data_cache_dir is None:
    self.nuclear.data_cache_dir = self.nuclear_data_cache_dir   # legacy wins
else:
    self.nuclear_data_cache_dir = self.nuclear.data_cache_dir   # nested wins

The same pattern applies to nuclear_data_sources vs nuclear.sources (lines 314-317).

Problem

  • If a user sets both nuclear_data_cache_dir and nuclear.data_cache_dir to different values, the nested field silently wins and the top-level value is overwritten with no warning.
  • workspace.endf_dir is then set from nuclear_data_cache_dir (line 321), completing a chain of implicit overrides that is hard to reason about.
  • There is no documentation or log message explaining which value takes precedence.

Suggested Approach

Pick one of:

  • Deprecate the legacy fields (nuclear_data_cache_dir, nuclear_data_sources) and migrate to the nested nuclear.* fields only, emitting a deprecation warning when the legacy fields are used.
  • Emit a warning when both are set to conflicting values, making the precedence explicit in docs and logs.
  • Raise an error when conflicting values are detected, forcing the user to be explicit.

Context

Identified during review of PR #220. Not a blocker — the sync logic works correctly for the common single-source case, but the implicit precedence can surprise users who set values at multiple levels.

Related

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions