omnisolver.common.plugin#
Hook specifications for omnisolver.
Module Contents#
Classes#
Namedtuple storing all information needed from plugin. |
Functions#
|
Create Plugin constructed from given specification. |
|
Hook for defining plugin instances. |
|
Filter namespace, leaving only attribute present in given filter. |
|
Given specification of the argument, add it to parser. |
|
Imports object specified by its full dotted_path. |
Attributes#
- omnisolver.common.plugin.T#
- omnisolver.common.plugin.plugin_spec#
- omnisolver.common.plugin.plugin_impl#
- class omnisolver.common.plugin.Plugin#
Bases:
NamedTupleNamedtuple storing all information needed from plugin.
- name: str#
- description: str#
- create_sampler: Callable[Ellipsis, dimod.Sampler]#
- populate_parser: Callable[[argparse.ArgumentParser], None]#
- init_args: Iterable[str]#
- sample_args: Iterable[str]#
- omnisolver.common.plugin.plugin_from_specification(specification, loader=importlib.import_module) Plugin#
Create Plugin constructed from given specification.
- Parameters:
specification – dictionary specifying properties of the solver. For reference, see random.yml in omnisolver.random package.
loader – function used for loading modules. Usually no need to override this.
- Returns:
a instance of Plugin with the following properties: - plugin.name is taken from “name” in specification - create_solver of a class pointed to by specification[“sampler_class”] - populate_parser acts in such a way, that it adds to the target parser all arguments
present in specification[“args”]
- omnisolver.common.plugin.filter_namespace_by_iterable(namespace: argparse.Namespace, attribute_filter: Iterable[str]) Dict[str, Any]#
Filter namespace, leaving only attribute present in given filter.
- Parameters:
namespace – namespace to be filtered.
attribute_filter – iterable of attribute names to be used as a filter.
- return dictionary containing mapping attribute name -> attribute value for every
attribute of a signature such that its name is in attribute_filter.
- omnisolver.common.plugin.TYPE_MAP#
- omnisolver.common.plugin.add_argument(parser: argparse.ArgumentParser, specification: Dict[str, Any]) None#
Given specification of the argument, add it to parser.
- omnisolver.common.plugin.import_object(dotted_path: str, loader=importlib.import_module)#
Imports object specified by its full dotted_path.
- Parameters:
dotted_path – full path of the object, e.g. omnisolver.random.sampler.RandomSampler.
loader – function used to load module from the given path. Usually you don’t need to specify that, this is here for testability purposes.
- Returns:
whatever dotted path points to.