I made a simple DI container with python. Below is a block diagram of the architecture.
The role of the Application layer is as follows.
The role of the Container layer is as follows.
Suppose the following logic is defined.
INPUT: None * OUTPU: ISample1Output
When creating a container, specify the logic execution order and I / O with the following code.
application.py
logic_dict: LogicDict = LogicDict(
[
{
LogicDict.LOGIC_EXEC_KEY: 'Sample1Logic',
LogicDict.LOGIC_EXEC_INPUT_KEY: '',
LogicDict.LOGIC_EXEC_OUTPUT_KEY: 'ISample1Output',
},
{
LogicDict.LOGIC_EXEC_KEY: 'Sample2Logic',
LogicDict.LOGIC_EXEC_INPUT_KEY: 'ISample1Output',
LogicDict.LOGIC_EXEC_OUTPUT_KEY: 'ISample2Output',
}
]
)
container.execute ()
and the logic is executed by the I / O defined in the specified order.application.py
container = SimulatorContainer(logic_dict)
container.execute()
Below is an example of how kaggle can be used for Titanic. https://github.com/chikugoy/kaggle_titanic
The source is published on the following github. https://github.com/chikugoy/analysis_container
Recommended Posts