No project description provided
Project description
MoBits Module Interface
Library to simplify the creation of modules for the mobits infrastructure.
[!NOTE] This library is still under active development, the API might change. For instance since version 1.0.0 we moved from
pikatoaio-pikaas the underlying RMQ library. Moving from synchronous to asynchronous code is a breaking change, therefore we bumped the major version.
Usage
Install this repository as a dependency of your project to bootstrap the creation process of a module inside the mobits infrastructure.
Example usage
import asyncio
from mobits_module_interface import ModuleInterface, main
class MyInterface(ModuleInterface):
async def callback(self, message):
# do something with message
await self.publish(message)
if __name__ == "__main__":
asyncio.run(main(MyInterface, broker={'uri': 'amqp://localhost'}))
Dev Stuff
Development
Test Execution
To run the tests simply execute
poetry run pytest [-rpP --cov]
To generate HTML reports run
poetry run coverage html
you can find the generated coverage report in ./coverage_html/
High Level Overview
The ModuleInterface class handles two main tasks
- Consume incoming messages from RMQ
- Publish outgoing messages to RMQ
The ModuleInterface class provides a run() method to start the consumer process as well as establish a connection-channel
for the publisher.
The main entry point for module applications is the main() function. It takes a ModuleInterface class as an argument and
starts the run() method. Apart from this, it also simplifies the configuration process of the underlying module.
Documentation
Documentation is created using sphinx docs
To check documentation, open docs/build/index.html in your favorite browser (firefox of course)
Create / update documentation (using sphinx)
poetry run sphinx-build -b html docs/source docs/build
Add new file/module to documentation
Using new file models as example:
-
In
docs/build/_sources/index.rst.txtadd a file name in TOC e.g.models.. toctree:: :maxdepth: 2 :caption: Contents: mobits_module_interface module_interface state_machine models
-
In
docs/build/_sources/create new file with the name of the added module plus.rst.txtextension. Formodelsthis would bedocs/build/_sources/models.rst.txt -
Depending on the added type (file in existing module, or new module), add content in file
- length of the
^^^part must be same length as Headline (HereDataclass Models) - check different content in existing files
Dataclass Models ^^^^^^^^^^^^^^^^ .. automodule:: mobits_module_interface.models :members: :undoc-members: :show-inheritance:
- length of the
-
Update documentation (see section above)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eb_mi-1.0.1.tar.gz.
File metadata
- Download URL: eb_mi-1.0.1.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bfd1b4a51f9a59354eaa7e9c7e17b1cfd7b72fc25a844428d7bac3cb8d5dc26
|
|
| MD5 |
73fc2f09a1b2a175f8250d89a93b50b2
|
|
| BLAKE2b-256 |
5efb4df5146330f2e2e8102def323822c0cb26da6b424d31fc017e37bb8e6206
|
File details
Details for the file eb_mi-1.0.1-py3-none-any.whl.
File metadata
- Download URL: eb_mi-1.0.1-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c148ed69d18921e1715664d88731a1439db8249f307f96ce1d0a8344538850f
|
|
| MD5 |
f3e7dce2d3b0d39bda536f70716fb35c
|
|
| BLAKE2b-256 |
8e129d18155b9f1a96c139ae9875cbe5f33c819deaa85e677ffd8c35f6ac1e5b
|