abtem.core.config#

Module Contents#

Classes#

set

Temporarily set configuration values within a context manager

Functions#

check_deprecations

Check if the provided value has been renamed or removed

get

Get elements from global config

refresh

Update configuration by re-reading yaml files and env variables

update_defaults

Add a new set of defaults to the configuration

Data#

API#

abtem.core.config.check_deprecations(...) str[source]#

Check if the provided value has been renamed or removed

Parameters:
  • key (str) – The configuration key to check

  • deprecations (Dict[str, str]) – The mapping of aliases

Returns:

new – The proper key, whether the original (if no deprecation) or the aliased value

Return type:

str

abtem.core.config.config: dict#

None

abtem.core.config.config_lock#

‘Lock(…)’

abtem.core.config.defaults: list[Mapping]#

[]

abtem.core.config.deprecations: dict[str, str | None]#

None

abtem.core.config.get(...) Any[source]#

Get elements from global config

If override_with is not None this value will be passed straight back. Useful for getting kwarg defaults from abtek config.

Use ‘.’ for nested access

abtem.core.config.no_default#

no_default

abtem.core.config.refresh(...) None[source]#

Update configuration by re-reading yaml files and env variables

This mutates the global abtem.config.config, or the config parameter if passed in.

This goes through the following stages:

  1. Clearing out all old configuration

  2. Updating from the stored defaults from downstream libraries (see update_defaults)

  3. Updating from yaml files and environment variables

Note that some functionality only checks configuration once at startup and may not change behavior, even if configuration changes. It is recommended to restart your python process if convenient to ensure that new configuration changes take place.

See also

abtem.config.collect

for parameters

abtem.config.update_defaults

class abtem.core.config.set(...)[source]#

Temporarily set configuration values within a context manager

Parameters:
  • arg (mapping or None, optional) – A mapping of configuration key-value pairs to set.

  • **kwargs – Additional key-value pairs to set. If arg is provided, values set in arg will be applied before those in kwargs. Double-underscores (__) in keyword arguments will be replaced with ., allowing nested values to be easily set.

Initialization

config: dict#

None

abtem.core.config.update_defaults(...) None[source]#

Add a new set of defaults to the configuration

It does two things:

  1. Add the defaults to a global collection to be used by refresh later

  2. Updates the global config with the new configuration prioritizing older values over newer ones