Main entities
To know the entities that compose PyMAPE, and their relationships, you can see a shrink version of its metamodel.
Metamodel¶
Entities¶
Explore the entities (used to develop your loops), starting from left to right:
mapepackage allows the configuration byinit()method and also by a config file (default:mape.ymlin your working directory) or a mix of both.init()has priority over the file. Frommapeyou have direct access toappandconfig.configdict exposes all your configuration (eg.mape.config['debug']), and you can also use it for your purpose, putting what you want in the configuration file.Appgives access to all declared MAPE loops, levels, and the global KnowledgeLoopis identified by a uid, contains its Element, has its Knowledge, and give access to the mainappobject (ie.loop.app) and its level (if exists).Levelis optional (there is an empty one by default), It can be used to describe a hierarchical control pattern. At each level with its uid can be associated more loops.Element(ie. M, A, P, E) is the pillar of PyMAPE framework, the center of the metamodel. They have an uid, but must be unique only inside its loop. There are different kinds of elements (Monitor, Analyze, Plan, Execute) and relative behaviors (base, StartOnSubscribe, StartOnInit). It has two ports (in and out), that allow to put within a stream. The operators can be added in the ports itself, or between elements (in the operators pipe).- There are three different
Knowledge, with different scopes (App, Level, and Loop). You can access each of them from its object (eg.loop.k). You can use it like a local storage object, or as centralized memory shared by the app deployed on a different machine (using redis). operatorsare the ones defined in the ReactiveX standard enriched with some specific and useful to our purpose.- The classes
MessageandCallMethodcan be used as items of the stream, enriched with additional information in the payload. This allows addressing our stream give at each item a destination or applying some kind of routing algorithm (Message), like the IP packets. TheCallMethoditem allows calling the remote methods (of elements) using the stream. - you have already seen the
loop_decoratorin the First loop section, used to register elements to a loop. element_decoratorprovides a set of decorators to define the Element class starting from a simple function. These decorators (as the above) are syntactic sugar to speed up development.
Info
Please refer to the First loop section and the following sections, to see how and when these entities are used.
mape¶
mape.init(debug=False, asyncio_loop=None, redis_url=None, rest_host_port=None, config_file=None) ¶
Initialize the PyMAPE framework, internal variables and services. Allow configuration by passed arguments and/or config_file, giving priority on the first one.
Call it before start using the framework.
Examples:
mape.init(debug=True,
redis_url="redis://localhost:6379",
rest_host_port="0.0.0.0:6060",
config_file="custom.yml")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
debug | bool | Enable more verbose mode. | False |
asyncio_loop | AbstractEventLoop | None | Provide your asyncio loop or leave PyMAPE to generate one for you. | None |
redis_url | string | None | Url of your Redis instance (eg. | None |
rest_host_port | string | None | Web server "host:port", where REST API endpoint will be provided (eg. | None |
config_file | string | None | Path (absolute or relative to working directory) to the config file (default | None |
Source code in mape/__init__.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
