datalad.api.x_configuration(action='dump', spec=None, scope=None, dataset=None, recursive=False, recursion_limit=None)

Get and set dataset, dataset-clone-local, or global configuration

This command works similar to git-config, but some features are not supported (e.g., modifying system configuration), while other features are not available in git-config (e.g., multi-configuration queries).

Query and modification of three distinct configuration scopes is supported:

  • 'branch': the persistent configuration in .datalad/config of a dataset branch

  • 'local': a dataset clone's Git repository configuration in .git/config

  • 'global': non-dataset-specific configuration (usually in $USER/.gitconfig)

Modifications of the persistent 'branch' configuration will not be saved by this command, but have to be committed with a subsequent save call.

Rules of precedence regarding different configuration scopes are the same as in Git, with two exceptions: 1) environment variables can be used to override any datalad configuration, and have precedence over any other configuration scope (see below). 2) the 'branch' scope is considered in addition to the standard git configuration scopes. Its content has lower precedence than Git configuration scopes, but it is committed to a branch, hence can be used to ship (default and branch-specific) configuration with a dataset.

Any DATALAD_* environment variable is also mapped to a configuration item. Their values take precedence over any other specification. In variable names '_' encodes a '.' in the configuration name, and '__' encodes a '-', such that 'DATALAD_SOME__VAR' is mapped to 'datalad.some-var'.

Recursive operation is supported for querying and modifying configuration across a hierarchy of datasets.


Dump the effective configuration, including an annotation for common items:

> configuration()

Query two configuration items:

> configuration('get', ['', ''])

Recursively set configuration in all (sub)dataset repositories:

> configuration('set', [('', 'value')], recursive=True)

Modify the persistent branch configuration (changes are not committed):

> configuration('set', [('', 'value')], scope='branch')
  • action ({'dump', 'get', 'set', 'unset'}, optional) -- which action to perform. [Default: 'dump']

  • spec -- configuration name (for actions 'get' and 'unset'), or name/value pair (for action 'set'). [Default: None]

  • scope ({'global', 'local', 'branch', None}, optional) -- scope for getting or setting configuration. If no scope is declared for a query, all configuration sources (including overrides via environment variables) are considered according to the normal rules of precedence. For action 'get' only 'branch' and 'local' (with include 'global' here) are supported. For action 'dump', a scope selection is ignored and all scopes are considered. [Default: None]

  • dataset (Dataset or None, optional) -- specify the dataset to query or to configure. [Default: None]

  • recursive (bool, optional) -- if set, recurse into potential subdataset. [Default: False]

  • recursion_limit (int or None, optional) -- limit recursion into subdataset to the given number of levels. [Default: None]

  • on_failure ({'ignore', 'continue', 'stop'}, optional) -- behavior to perform on failure: 'ignore' any failure is reported, but does not cause an exception; 'continue' if any failure occurs an exception will be raised at the end, but processing other actions will continue for as long as possible; 'stop': processing will stop on first failure and an exception is raised. A failure is any result with status 'impossible' or 'error'. Raised exception is an IncompleteResultsError that carries the result dictionaries of the failures in its failed attribute. [Default: 'continue']

  • result_filter (callable or None, optional) -- if given, each to-be-returned status dictionary is passed to this callable, and is only returned if the callable's return value does not evaluate to False or a ValueError exception is raised. If the given callable supports **kwargs it will additionally be passed the keyword arguments of the original API call. [Default: None]

  • result_renderer ({'default', 'json', 'json_pp', 'tailored'} or None, optional) -- format of return value rendering on stdout. [Default: 'tailored']

  • result_xfm ({'datasets', 'successdatasets-or-none', 'paths', 'relpaths', 'metadata'} or callable or None, optional) -- if given, each to-be-returned result status dictionary is passed to this callable, and its return value becomes the result instead. This is different from result_filter, as it can perform arbitrary transformation of the result value. This is mostly useful for top- level command invocations that need to provide the results in a particular format. Instead of a callable, a label for a pre-crafted result transformation can be given. [Default: None]

  • return_type ({'generator', 'list', 'item-or-list'}, optional) -- return value behavior switch. If 'item-or-list' a single value is returned instead of a one-item return value list, or a list in case of multiple return values. None is return in case of an empty list. [Default: 'list']