datalad_core.config

Configuration management

This module provides the standard facilities for configuration management, query, and update. It is built on datasalad.settings.

The key piece is the ConfigManager that supports querying for configuration settings across multiple sources. It also offers a context manager to temporarily override particular configuration items.

With the method ConfigManager.for_dataset(), a manager instance tailored to a specific dataset can be created. A “dataset” in this context is any Git repository, with or without an initialized annex, and with or without initialization as a DataLad dataset. Such an instance will share all sources of the original manager instance, and supports additional sources for the scopes of repository-local Git configuration, and branch-committed DataLad configuration.

Usage

Basic usage is more or less identical to that of the datasalad.settings. Importantly, and unlike the legacy DataLad approach, no instance of ConfigManager is provided. Instead, if and when such a common instance it needed, it must be obtained by calling get_manager(). This is typically done first by a respective “entrypoint” implementation. Subsequent calls will return the same instance.

The same pattern is applied to obtain a common instance of ImplementationDefaults via get_defaults(). This instance can be used to register defaults for any and all configuration settings supported by a particular implementation. This can be done on importing the respective modules.

ConfigItem(value, *, coercer, lazy)

value can be of any type.

ConfigManager(defaults[, sources])

Multi-source (scope) configuration manager

GitConfig()

Abstract base class for sources using git-config to read and write

SystemGitConfig()

Source for Git's system configuration scope

GlobalGitConfig()

Source for Git's global configuration scope

LocalGitConfig(path)

Source for Git's local configuration scope

DataladBranchConfig(path)

Source for configuration committed to a branch's .datalad/config

WorktreeGitConfig(path)

Source for Git's worktree configuration scope

GitEnvironment()

Source for Git's environment variable based command scope

ImplementationDefaults()

Source for registering implementation defaults of settings

UnsetValue()

Placeholder type to indicate a value that has not been set

get_defaults()

Return a a process-unique ImplementationDefault instance

get_manager()

Return a a process-unique, global ConfigManager instance