soleil.overrides.overridable#

Classes

Overridable()

When an overridable is assigned as a value to a member variable, soleil overrides will be applied to that member using its set() and get() methods (see _soleil_override()).

choices(values, default)

Choice supporting convenient string-based CLI override

submodule(*args[, reqs])

Loads, from a sub-package, a submodule with an overridable name.

class soleil.overrides.overridable.Overridable#

Bases: ABC

When an overridable is assigned as a value to a member variable, soleil overrides will be applied to that member using its set() and get() methods (see _soleil_override()).

abstract get(target: str, frame: frame) Any#
Parameters:
  • target – The name of the variable that this overridable is being assigned to.

  • frame – The frame where the overridable is being assigned.

class soleil.overrides.overridable.submodule(*args, reqs=None)#

Bases: Overridable

Loads, from a sub-package, a submodule with an overridable name. The sub-package can be explicitly provided or inferred from the target variable name.

For example, the .colors.red package can be loaded using either of

color = submodule('.colors', 'red')
color = submodule('red')

As an overridable, submodule supports interpreting the override string as a new submodule name. Using

$ solex main.solconf color='"green"'

for example, will assign the load value of .color.green to color.

get(target: str, frame: frame)#
Parameters:
  • target – The name of the variable that this overridable is being assigned to.

  • frame – The frame where the overridable is being assigned.

class soleil.overrides.overridable.choices(values: Dict[str, Any], default)#

Bases: Overridable

Choice supporting convenient string-based CLI override

# main.solconf
a:as_type = choices({'A':'submod1:A', 'B':'symbod2:B'}, 'A')
color = choices({'red':[1,0,0], 'green':[0,1,0], 'blue':[0,0,1]}, 'red')
bash:~$ solex ./main a='"B"' color='"green"'
get(*args, **kwargs)#
Parameters:
  • target – The name of the variable that this overridable is being assigned to.

  • frame – The frame where the overridable is being assigned.