experiment_runner.defaults ========================== .. py:module:: experiment_runner.defaults .. autoapi-nested-parse:: Where the runner's default settings come from. The package's own function signatures are the single source of truth for every default a component consumes. This module records which signature owns which config key and reads the value off it, so a renamed or removed parameter fails here at startup instead of leaving a stale literal behind. ``master.yaml`` documents the same values for people writing configs, and a test holds the two in step. Keys the package knows nothing about - the runner's own control flow, and the Quantus parameter blocks - are listed in :data:`_RUNNER_OWNED` instead, where ``master.yaml`` stays authoritative. Between them the two tables must cover every key in every ``default_settings`` block; a test enforces that, so a new key has to be classified rather than quietly joining neither group. Attributes ---------- .. autoapisummary:: experiment_runner.defaults.logger Functions --------- .. autoapisummary:: experiment_runner.defaults.package_default experiment_runner.defaults.hyperparam_names experiment_runner.defaults.apply_package_defaults experiment_runner.defaults.default_settings_leaves Module Contents --------------- .. py:data:: logger .. py:function:: package_default(section: str, key: str) -> object Read one package-backed default off the signature that owns it. :param section: Config section, e.g. ``"data_config"``. :type section: str :param key: Key within that section's ``default_settings``, dotted for a nested one (e.g. ``"hyperparams.epochs"``). :type key: str :returns: The owning parameter's default. A tuple default is returned as a list, so the value stays plain YAML rather than reaching the resolved config and the run log as a Python tuple. :rtype: object :raises KeyError: If the key is not package-backed, or if the owning callable no longer has that parameter - which is the point of the table: a rename fails loudly here rather than leaving the runner on a stale literal. .. py:function:: hyperparam_names() -> frozenset[str] Return the training hyperparameters a model entry may set. Derived from both pointer tables rather than listed again, so adding a hyperparameter to :meth:`~xai4tsc.models.base.ModelBase.train_model` and the table is enough to make it configurable. Both tables, not just the package-backed one: ``loss_func`` and ``optimizer`` name library objects the runner builds, and ``loss_params`` / ``optimizer_params`` are consumed by the runner and never reach ``train_model`` at all. Deriving from ``_PACKAGE_BACKED`` alone would make all four "not a training parameter" in config validation. :returns: The accepted key names inside a ``hyperparams`` block. :rtype: frozenset[str] .. py:function:: apply_package_defaults(user_config: dict, resolved: dict) -> None Replace master's copy of every package-backed default with the derived one. Modifies *resolved* in place. A key the user states in their own ``default_settings`` is left alone, so user settings still win; for every other key master's value is overwritten by the package's, which is what makes master documentation rather than a second authority. The two agree by test, so this changes no value - it removes the possibility of them disagreeing. :param user_config: The raw user config, consulted only to see which keys the user stated. :type user_config: dict :param resolved: The config after master has been merged in, modified in place. :type resolved: dict .. py:function:: default_settings_leaves(section: str, block: dict) -> list[str] List the (possibly dotted) keys of one ``default_settings`` block. Nested mappings are descended into, so ``hyperparams`` contributes one key per hyperparameter - except where the parent itself is runner-owned, which stops the descent, since the whole subtree then belongs to ``master.yaml``. :param section: Config section the block belongs to. :type section: str :param block: The ``default_settings`` mapping. :type block: dict :returns: One entry per leaf, in declaration order. :rtype: list[str]