soleil.resolvers.module_resolver#

Module Attributes

as_run

Indicates that the annotated member is a callable that solex() will run on the module

promoted

When a module's member is annotated as promoted it will be returned when that module is loaded without resolving.

resolves

When a module's member is annotated as resolves, the module will resolve to the resolution of that member.

Classes

ModuleResolver(resolvable[, _build])

SolConfModule(soleil_module, soleil_path[, ...])

The class used to represent *.solconf modules.

soleil.resolvers.module_resolver.as_run = {'as_run': True}#

Indicates that the annotated member is a callable that solex() will run on the module

soleil.resolvers.module_resolver.promoted = {'promoted': True}#

When a module’s member is annotated as promoted it will be returned when that module is loaded without resolving. Accordingly, the module will also resolve to the resolution of that member. When a member in a module is marked as promoted, all other members in the module no longer have a variable path, since the module’s variable path becomes the promoted member’s variable path. Hence, no other members can be overriden by CLI overrides.

Modifier promoted is special because it also operates as a pre-processor directive. The reason is that correct dereferencing of CLI overrides in modules with promoted members requires knowing the name of the promoted member before executing the code.

soleil.resolvers.module_resolver.resolves = {'resolves': True}#

When a module’s member is annotated as resolves, the module will resolve to the resolution of that member. Unlike promoted members, loading a module (without resolving) containing a resolves-annoted member will still produce that module.

class soleil.resolvers.module_resolver.SolConfModule(soleil_module: str, soleil_path: Path, soleil_var_path: VarPath | str | None = None, soleil_reqs: List[Override] | None = None, root_config: SolConfModule | None = None)#

Bases: module

The class used to represent *.solconf modules.

load(module_name, promoted=True, resolve=False, reqs: List[str | Dict[str, Any] | Override] | None = None, _target: str | None = None, _frame: frame | int | None = 0, **kwargs)#

Loads a module by relative name. Names with leading dots are interepreted relative to this module. Names with no leading dots are interpreted relative to the parent package.

If the loaded module contains a promoted member, that member is returned by default.

Parameters:
  • module_name – The relative or absolute (without package name) module name.

  • promoted – Whether the return the promoted member, if it exists, otherwise (or if promoted=False) the full module.

  • resolve – Whether to resolve the module.

  • reqs – Default values for req members.

class soleil.resolvers.module_resolver.ModuleResolver(resolvable, _build=True)#

Bases: ClassResolver

special_members = mappingproxy({'args': 'as_args', 'type': 'as_type', 'run': 'as_run', 'promoted': 'promoted', 'resolves': 'resolves'})#

Tuples of attribute names and modifier type for special members.

promoted#

The promoted member

alias of Unassigned

resolves#

The member that the module resolves to. Modules must have at most one resolved or promoted member.

alias of Unassigned

compute_resolved()#

If no as_type member is provided, applies the following resolution:

If a single variable is explicitly promoted, resolves to that variable. Otherwise, resolves to a dictionary with all visible members resolved.

classmethod can_handle(value)#

Must by a type and have an as_type modifier.