so_magic.data.backend package¶
Subpackages¶
Submodules¶
so_magic.data.backend.backend module¶
This module defines a way to create Data Engines and to register new commands that a Data Engine can execute.
- class so_magic.data.backend.backend.BackendType(*args, **kwargs)[source]¶
Bases:
so_magic.data.backend.backend.CommandRegistrator
Tabular Data Backend type representation.
Classes using this class as metaclass gain certain class attributes such as attributes related to tabular data operations (retriever, iterator, mutator) and attributes related to constructing command object prototypes (command_factory attribute).
- dec(data_structure='tabular-data') → Callable[[Callable], Callable][source]¶
Register a new command that executes the business logic supplied at runtime.
Decorate a function so that its body acts as the business logic that runs as part of a Command. The name of the function can be used to later reference the Command (or a prototype object of the Command).
Using the ‘observations’ name for your function will register a command that upon execution creates a new instance of Datapoints (see Datapoints class), provided that the runtime function returns an object that acts as the ‘observations’ attribute of a Datapoints object.
- Parameters
data_structure (str, optional) – useful when the function name is ‘observations’. Defaults to ‘tabular-data’.
- class so_magic.data.backend.backend.CommandRegistrator(*args, **kwargs)[source]¶
Bases:
so_magic.data.backend.backend.MyDecorator
Classes can use this class as metaclass to obtain a single registration point accessible as class attribute.
- class so_magic.data.backend.backend.EngineBackend[source]¶
Bases:
object
Facility to create Data Engines.
- command_factory = MagicCommandFactory(command_factory=<so_magic.data.backend.engine_command_factory.CommandFactory object>, subject=<so_magic.utils.notification.Subject object>)¶
- datapoints_factory = None¶
- iterator = None¶
- mutator = None¶
- classmethod new(engine_name: str) → so_magic.data.backend.backend.BackendType[source]¶
Create a Data Engine object and register it under the given name, to be able to reference it by name.
Creates a Data Engine that serves as an empty canvas to add attributes and Commands.
- Parameters
engine_name (str) – the name under which to register the Data Engine
- Returns
the Data Engine object
- Return type
- classmethod register_as_subclass(backend_type: str)[source]¶
Indicate that a class is a subclass of DataEngine and register it under the given name.
It also sets the engine_type attribute on the decorate class to be equal to the subclass.
- Parameters
backend_type (str) – the name under which to register the Data Engine
- registry = {}¶
- retriever = None¶
- state = None¶
- subclasses = {}¶
so_magic.data.backend.engine module¶
Define a wrapper around an Engine as the Backend class which constructor can initialize Backend instances.
- class so_magic.data.backend.engine.Engine(backend_instance, backends=NOTHING)[source]¶
Bases:
object
Wrapper of a data engine, a datapoints manager and a datapoints factory.
Instances of this class act as data placeholders (aka data classes) and take at runtime a data engine (eg a set of pandas-dependent implementations of the “Tabular Data interfaces” defined in so_magic.data.interfaces).
- Parameters
engine_instance (DataEngine) – a data engine represented as a class object (eg class MyClass: pass)
- property backend¶
The Data Engine instance, that this object wraps around.
- Returns
the Data Engine instance object
- Return type
DataEngine
so_magic.data.backend.engine_command_factory module¶
- class so_magic.data.backend.engine_command_factory.BaseCommandFactory[source]¶
Bases:
object
- subclasses = {'function': <class 'so_magic.data.backend.engine_command_factory.FunctionCommandFactory'>, 'generic': <class 'so_magic.data.backend.engine_command_factory.GenericCommandFactory'>}¶
- class so_magic.data.backend.engine_command_factory.CommandFactory[source]¶
Bases:
object
A factory class able to construct new command objects.
- constructors = {'function': <bound method FunctionCommandFactory.construct of <so_magic.data.backend.engine_command_factory.FunctionCommandFactory object>>, 'generic': <bound method GenericCommandFactory.construct of <so_magic.data.backend.engine_command_factory.GenericCommandFactory object>>}¶
- classmethod create(*args, **kwargs) → Tuple[so_magic.utils.commands.Command, str][source]¶
- class so_magic.data.backend.engine_command_factory.FunctionCommandFactory[source]¶
Bases:
so_magic.utils.command_factory_interface.CommandFactoryInterface
Command Factory that constructs a command assuming the 1st argument is a python function.
Assumes that the function (1st argument) acts as the the ‘receiver’ (see Command module), 2nd is the method to call on the receiver and the rest are the method’s runtime arguments.
- construct(*args, **kwargs) → so_magic.utils.commands.Command[source]¶
Construct a command object (Command class instance).
Assumes that the 1st argument is a python function and that it acts as the the ‘receiver’ (see Command module). The rest are the function’s runtime arguments.
- Raises
RuntimeError – [description]
- Returns
[description]
- Return type
- class so_magic.data.backend.engine_command_factory.GenericCommandFactory[source]¶
Bases:
so_magic.utils.command_factory_interface.CommandFactoryInterface
Command Factory that constructs a generic command given all the necessary arguments.
Assumes the 1st argument is the ‘receiver’ (see Command module), 2nd is the method to call on the receiver and the rest are the method’s runtime arguments.
- construct(*args, **kwargs) → so_magic.utils.commands.Command[source]¶
Construct a command object (Command class instance).
Assumes the 1st argument is the ‘receiver’ (see Command module), 2nd is the method to call on the receiver and the rest are the method’s runtime arguments.
- Returns
the command object
- Return type
- class so_magic.data.backend.engine_command_factory.MagicCommandFactory(command_factory=<so_magic.data.backend.engine_command_factory.CommandFactory object>)[source]¶
Bases:
object
Instances of this class act as callable command factories that notify, subscribed observers/listeners upon new command object creation.
- Parameters
command_factory (CommandFactory, optional) – an instance of a CommandFActory
- subject: so_magic.utils.notification.Subject¶
so_magic.data.backend.backend_specs module¶
- class so_magic.data.backend.backend_specs.BackendSpecifications(name_abbreviation, name=NOTHING)[source]¶
Bases:
object
- class so_magic.data.backend.backend_specs.EngineTabularIterator[source]¶
Bases:
object
- subclasses = {}¶