config_coordinator#
- class ConfigCoordinator(*, config_repo: ConfigRepository, bus: EventBus, scope: AdjusterScope = AdjusterScope.EXPERIMENT, schemas_dir: Path | None = None, defaults_provider: DefaultsProvider | None = None)[source]#
Bases:
BusSubscriberMixinCoordinates the app’s working configuration as one cohesive unit.
Primitives#
apply(patch): merge patch into working model (no validation, no IO) adjust_config(…): run adjusters to derive config; merge their patch (no validation, no IO) validate(): run validators; raise if invalid (no IO) commit(): write working config to disk atomically
One-shots#
submit_patch(patch, …): apply → [adjust_config(filtered)] → [validate] → [commit] submit(…): [adjust_config(full)] → [validate] → [commit]
Notes
Adjusters are pure/idempotent; calling adjust_config multiple times is safe.
Validators must not mutate the model.
Tabs/controllers should not write files; all persistence flows through commit().
- classmethod from_folder(folder: Path, known_names: Iterable[str] | None, *, scope: AdjusterScope = AdjusterScope.EXPERIMENT, auto_load: bool = False, **kwargs) ConfigCoordinator[source]#
- adjust_config(*, sample_manager: SampleManager | None = None, phase: Phase = Phase.PRE_VALIDATE, active_sections: Iterable[str] | None = None, changed_keys: Iterable[ConfigKeys] | None = None, view: Mapping[str, Any] | None = None, apply: bool = True) Dict[str, Any][source]#
Run all config adjusters on the current working config, optionally filtered by changed_keys and pipelines. A global patch dict is returned. If apply is True (default), the patch is merged into the working config.
- Parameters:
sample_manager
phase
active_sections
changed_keys
apply
Returns
- clone_from(template_dir: str | Path, dest_dir: str | Path) None[source]#
Clone the entire working config from another coordinator.
- commit(sections: List[str] | None = None) None[source]#
Persist working configs to disk. If sections is given, only those sections are written; otherwise all are.
- get_config_view(cfg_name: str = '') Dict[str, Any][source]#
Read-only dict for UI using a deep copy of the current working config (or a single section if cfg_name is given).
- seed_missing_from_defaults(*, tabs_only: bool = True) None[source]#
For any known section missing in the working model, seed from DefaultsProvider. Call this after load_all() when creating a new experiment.
- set_active_sections(sections: Iterable[str] | None) None[source]#
Declare which local config sections are in play for this experiment. Global sections (machine, display, etc.) stay untouched.
- This method:
Prunes self.working to only keep active+global sections.
Updates the repo so future load_all()/copy_from_defaults() only touch those sections (plus globals).
- set_defaults_provider(provider) None[source]#
Wire/replace the defaults provider after construction.
- snapshot_to(target_dir: Path | str) Path[source]#
Write each working cfg into target_dir
- Parameters:
target_dir (Path | str) – The target directory where to write the snapshot. Existing files will be overwritten.
Returns
The target directory path.
- submit(*, sample_manager: SampleManager | None = None, do_run_adjusters: bool = True, validate: bool = True, commit: bool = True, phase=Phase.PRE_VALIDATE) None[source]#
Run adjusters on the current working config (unfiltered), then optionally validate and commit. Use this when you haven’t just applied a new patch.
- submit_patch(patch: dict, *, sample_manager: SampleManager | None, do_run_adjusters: bool = True, validate: bool = True, commit: bool = True, origin: str | None = 'ui', phase=Phase.PRE_VALIDATE) None[source]#
Apply patch to the working config, then optionally adjust_config (adjusters filtered by the patch’s changed keys), validate, and commit.
- Equivalent to:
self.apply(patch, origin=origin) if run_adjusters: self.adjust_config(changed_keys=_patch_to_config_keys_sets(patch), sample_manager=sample_manager) if validate: self.validate() if commit: self.commit()
- validate(working_copy=None) None[source]#
Ensure the current working config is valid. Raises if not valid.
- view() Mapping[str, Mapping[str, Any]][source]#
Return an immutable view of the current working config.
- property base_dir: Path#
- property current_channels#
- property rev: int#
- property workspace_config_path#