bittensor.core.config#

Implementation of the config class, which manages the configuration of different Bittensor modules.

Attributes#

T

Exceptions#

InvalidConfigFile

In place of YAMLError

Classes#

Config

Implementation of the config class, which manages the configuration of different Bittensor modules.

DefaultConfig

A Config with a set of default values.

Module Contents#

class bittensor.core.config.Config(parser=None, args=None, strict=False, default=None)[source]#

Bases: munch.DefaultMunch

Implementation of the config class, which manages the configuration of different Bittensor modules.

Translates the passed parser into a nested Bittensor config.

Parameters:
  • parser (argparse.ArgumentParser) – Command line parser object.

  • strict (bool) – If true, the command line arguments are strictly parsed.

  • args (list of str) – Command line arguments.

  • default (Optional[Any]) – Default value for the Config. Defaults to None. This default will be returned for attributes that are undefined.

Returns:

Nested config object created from parser arguments.

Return type:

config (bittensor.core.config.Config)

Construct a new DefaultMunch. Like collections.defaultdict, the first argument is the default value; subsequent arguments are the same as those for dict.

__check_for_missing_required_args(parser, args)#
Parameters:
Return type:

list[str]

__deepcopy__(memo)[source]#
Return type:

Config

static __get_required_args_from_parser(parser)#
Parameters:

parser (argparse.ArgumentParser)

Return type:

list[str]

__is_set: dict[str, bool]#
static __parse_args__(args, parser=None, strict=False)[source]#

Parses the passed args use the passed parser.

Parameters:
  • args (list[str]) – List of arguments to parse.

  • parser (argparse.ArgumentParser) – Command line parser object.

  • strict (bool) – If true, the command line arguments are strictly parsed.

Returns:

Namespace object created from parser arguments.

Return type:

Namespace

__repr__()[source]#

Invertible* string-form of a Munch.

>>> b = Munch(foo=Munch(lol=True), hello=42, ponies='are pretty!')
>>> print (repr(b))
Munch({'ponies': 'are pretty!', 'foo': Munch({'lol': True}), 'hello': 42})
>>> eval(repr(b))
Munch({'ponies': 'are pretty!', 'foo': Munch({'lol': True}), 'hello': 42})
>>> with_spaces = Munch({1: 2, 'a b': 9, 'c': Munch({'simple': 5})})
>>> print (repr(with_spaces))
Munch({'a b': 9, 1: 2, 'c': Munch({'simple': 5})})
>>> eval(repr(with_spaces))
Munch({'a b': 9, 1: 2, 'c': Munch({'simple': 5})})

(*) Invertible so long as collection contents are each repr-invertible.

Return type:

str

static __split_params__(params, _config)[source]#
Parameters:
__str__()[source]#

Return str(self).

Return type:

str

_config#
classmethod _merge(a, b)[source]#

Merge two configurations recursively. If there is a conflict, the value from the second configuration will take precedence.

static _remove_private_keys(d)[source]#
all_default_args#
config_params#
copy()[source]#

D.copy() -> a shallow copy of D

Return type:

Config

default_param_args#
default_params#
defaults_as_suppress#
is_set(param_name)[source]#

Returns a boolean indicating whether the parameter has been set or is still the default.

Parameters:

param_name (str)

Return type:

bool

merge(b)[source]#

Merges the current config with another config.

Parameters:

b (bittensor.core.config.Config) – Another config to merge.

classmethod merge_all(configs)[source]#

Merge all configs in the list into one config. If there is a conflict, the value from the last configuration in the list will take precedence.

Parameters:

configs (list[bittensor.core.config.Config]) – List of configs to be merged.

Returns:

Merged config object.

Return type:

config (bittensor.core.config.Config)

missing_required_args#
params#
params_no_defaults#
parser_no_defaults#
strict#
static to_string(items)[source]#

Get string from items.

Return type:

str

update_with_kwargs(kwargs)[source]#

Add config to self

class bittensor.core.config.DefaultConfig(parser=None, args=None, strict=False, default=None)[source]#

Bases: Config

A Config with a set of default values.

Construct a new DefaultMunch. Like collections.defaultdict, the first argument is the default value; subsequent arguments are the same as those for dict.

Parameters:
classmethod default()[source]#
Abstractmethod:

Return type:

T

Get default config.

exception bittensor.core.config.InvalidConfigFile[source]#

Bases: Exception

In place of YAMLError

Initialize self. See help(type(self)) for accurate signature.

bittensor.core.config.T#