topostats.config#
Functions and tools for working with configuration files.
Attributes#
Functions#
|
Reconcile command line arguments with the default configuration. |
|
Update the args.module argument if processing TopoStats objects. |
|
Merge two mappings (dictionaries), with priority given to the second mapping. |
|
Write a sample configuration with in-line comments. |
|
Update the configuration with any arguments. |
|
Update the plotting config for each of the plots in plot_dict. |
Module Contents#
- topostats.config.MutableMappingType#
- topostats.config.LOGGER#
- topostats.config.reconcile_config_args(args: argparse.Namespace | None) dict[source]#
Reconcile command line arguments with the default configuration.
Command line arguments take precedence over the default configuration. If a partial configuration file is specified (with ‘-c’ or ‘–config-file’) the defaults are over-ridden by these values (internally the configuration dictionary is updated with these values). Any other command line arguments take precedence over both the default and those supplied in a configuration file (again the dictionary is updated).
The final configuration is validated before processing begins.
- Parameters:
args (Namespace) – Command line arguments passed into TopoStats.
- Returns:
The configuration dictionary.
- Return type:
dict
- topostats.config.update_module(args: argparse.Namespace, topostats_modules: tuple = ('bruker-rename', 'curvature', 'disordered_tracing', 'filter', 'grains', 'grainstats', 'nodestats', 'ordered_tracing', 'process', 'splining')) None[source]#
Update the args.module argument if processing TopoStats objects.
This function allows the sub-parser command to map to the pipeline we wish to use. For now TopoStats has sub-parsers but it is the intention to introduce sub-sub-parsers for other modules such that eventually we invoke
topostats`with a module argument followed by the step of processing.>>> topostats topostats filter >>> topostats topostats process >>> topostats afmslicer slice >>> topostats afmslicer process >>> topostats perovstats process
- Parameters:
args (Namespace) – Default arguments that need parsing and updating.
topostats_modules (tuple) – List of module names that are unique to TopoStats.
- topostats.config.merge_mappings(map1: MutableMappingType, map2: MutableMappingType) MutableMappingType[source]#
Merge two mappings (dictionaries), with priority given to the second mapping.
Note: Using a Mapping should make this robust to any mapping type, not just dictionaries. MutableMapping was needed as Mapping is not a mutable type, and this function needs to be able to change the dictionaries.
- Parameters:
map1 (MutableMapping) – First mapping to merge, with secondary priority.
map2 (MutableMapping) – Second mapping to merge, with primary priority.
- Returns:
Merged dictionary.
- Return type:
dict
- topostats.config.write_config_with_comments(args: argparse.Namespace = None) None[source]#
Write a sample configuration with in-line comments.
This function is not designed to be used interactively but can be, just call it without any arguments and it will write a configuration to ‘./config.yaml’.
- Parameters:
args (Namespace) – A Namespace object parsed from argparse with values for ‘filename’.
- topostats.config.update_config(config: dict, args: dict | argparse.Namespace) dict[source]#
Update the configuration with any arguments.
- Parameters:
config (dict) – Dictionary of configuration (typically read from YAML file specified with ‘-c/–config <filename>’).
args (Namespace) – Command line arguments.
- Returns:
Dictionary updated with command arguments.
- Return type:
dict
- topostats.config.update_plotting_config(plotting_config: dict) dict[source]#
Update the plotting config for each of the plots in plot_dict.
Ensures that each entry has all the plotting configuration values that are needed.
- Parameters:
plotting_config (dict) – Plotting configuration to be updated.
- Returns:
Updated plotting configuration.
- Return type:
dict