Skip to main content

Masterpiece framework

Project description

Masterpiece™

Welcome to Masterpiece™ - Quite a Piece of Work!

Masterpiece™ is a Python framework designed for creating modular, scalable, plugin-aware, multi-threaded, and object-oriented IoT applications — and even non-IoT applications!

Note: While Python's Global Interpreter Lock (GIL) might make multi-threading a challenging topic for some developers, I trust the Python community will continue to evolve and address these concerns over time.

Goals

The primary goal of Masterpiece™ is to have fun while learning the Python ecosystem!

Please note: This is an alpha release. It is not ready for production use. Please experiment, explore, and provide feedback, but avoid using it for critical applications!

Design Concepts and Features

  • MQTT Communication: Enables seamless communication between components using the MQTT protocol, ideal for distributed systems.
  • Pythonic Purity: Adheres to Python conventions, ensuring idiomatic, readable, and maintainable code.
  • First-Time Excellence: Designed to be reliable, correct, and efficient from the start—while keeping things fun!
  • Completeness: A minimal yet robust API that gives developers total control over all aspects of their applications.
  • Productivity: Highly modular and reusable codebase to achieve maximum functionality with minimal effort. Productivity grows with the size of the project.
  • Proper Abstraction: Provides clean abstractions for essential third-party libraries, shielding application code from underlying framework changes.
  • User Interface/Time Series Support: Leverages InfluxDB V3 for time-series databases, enabling seamless integration with third-party visualization tools like Grafana.

Project Status and Current State

Here’s what’s currently available in Masterpiece™:

  • Absolutely Bug-free Status!: Just kidding—there are no known bugs (so far).
  • Wiki: The initial Wiki pages are under construction. Visit the Masterpiece Wiki <https://gitlab.com/juham/masterpiece/-/wikis/home>_.
  • Tutorial: A tutorial <docs/source/tutorial.rst>_ to help you get started with building your masterpieces.
  • Package Infrastructure: The Python package setup is finalized, using pyproject.toml.
  • Classes: Existing classes have been finalized and tested in a production environment.
  • Example Application: A sample application (examples/myhome.py) prints out its instance structure when run. Despite its simplicity, it demonstrates the structure of a typical scalable and fully configurable software.
  • Plugin Projects: Several plugin examples, such as masterpiece_plugin, which adds a "Hello World" greeting to myhome.py, demonstrate minimal yet functional plugin implementations.
  • MQTT API: Enables communication between all Masterpiece™ objects.
  • InfluxDB V3 Time Series: Supports writing and reading from time-series databases.
  • Serialization: Built-in support for JSON serialization, with options to extend to other formats via plugins.
  • ...: And probably more features I’ve forgotten while writing this.

Projects

Masterpiece comes in a set of Python projects:

  1. Masterpiece (core framework):

This is the core framework for building plugin-aware, multi-threaded applications. It includes a simple yet fully functional application to help you get started and serves as a plugin-aware reference application that can be scaled up to any size.

  1. Masterpiece Plugin (plugin example):

This is a basic plugin example that demonstrates how to create third-party plugins for applications built using Masterpiece. It’s as simple as saying "Hello, World!", literally.

  1. Masterpiece XML Format plugin::

Plugin that adds XML serialization format support to Masterpiece.

  1. Masterpiece Yaml Format plugin::

Another format plugin. Adds Yaml support to Masterpiece.

  1. Masterpiece Influx::

Support for InfluxDB V3 time series database.

  1. Masterpiece Paho MQTT::

Support for Paho Mosquitto MQTT.

Installing Masterpiece

Step 1: Install Masterpiece and run the example application ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

To install the core framework:

.. code-block:: bash

pip install masterpiece

Then, navigate to the example folder and run the application:

.. code-block:: bash

python examples/myhome.py

The application will print out its instance hierarchy. This is a simple example application to demonstrate the basic structure of any multi-threaded, plugin-based, scalable MasterPiece applications.

Example output:

.. code-block:: text

home
    ├─ grid
    ├─ downstairs
    │   └─ kitchen
    │       ├─ oven
    │       └─ fridge
    └─ garage
        └─ EV charger

Step 2: Install the desired Masterpiece Plugins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

To extend the application with the say masterpiece_plugin:

.. code-block:: bash

pip install masterpiece_plugin

Run the application again:

.. code-block:: bash

python examples/myhome.py

You'll now see a new object in the instance hierarchy, along with a friendly "Hello, World!" object.

Example output:

.. code-block:: text

home
    ├─ grid
    ├─ downstairs
    │   └─ kitchen
    │       ├─ oven
    │       └─ fridge
    ├─ garage
    │   └─ EV charger
    └─ Hello World - A Plugin

Step 3: Configurating ^^^^^^^^^^^^^^^^^^^^^^^^^

The application also demonstrates the usage of startup arguments. Run the application again:

.. code-block:: text

examples/myhome.py --init --solar 10 --color red

and new 'Solar plant 10 kW' object appears in the tree.

  • The --init argument tells the application to save its current configuration to a configuration files.
  • The --solar argument creates an instance of a solar power plant with a specified peak power of 10 kW.
  • The --color argument can be used for setting the color for the tree diagram.

The above class properties (and many more) can also be defined in the class configuration files. By default, the configuration files are created in the ~/.myhome/config folder, as determined by the application identifier and --config [anyname].

For example, --config temp will use the configuration files stored in the ~/.myhome/temp/ folder.

What's next

Congratulations! You've successfully installed Masterpiece, extended it with a plugin, and explored its configuration system. But what is all this for?

That part is up to your imagination. Here's what you can explore next:

  • Write Plugins: Develop your own plugins to extend Masterpiece with domain-specific functionality. Use the masterpiece_plugin as a starting point for inspiration.

  • Leverage Configurations: Take advantage of configuration files to fine-tune your application's behavior without changing the code. Experiment with the --config argument to manage multiple configurations for different scenarios.

  • Design a Custom Application: Build a unique application that fits your needs by combining existing plugins, creating new objects in the instance hierarchy, and integrating external services or data sources.

  • Contribute to the Community: Share your plugins or improvements with the Masterpiece community.

Masterpiece provides the building blocks. Where you go from here is entirely up to you. Happy coding!

Contributing

Please check out the Masterpiece Issue Board <https://gitlab.com/juham/masterpiece/-/boards>_ for tracking progress and tasks.

Developer Documentation

For full documentation and usage details, see the full documentation at Documentation Index <docs/build/html/index.html>_ (The docs may look rough; I’m still unraveling Sphinx's mysteries).

Special Thanks

Big thanks to the generous support of Mahi.fi for helping bring this framework to life.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

masterpiece-0.1.14.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

masterpiece-0.1.14-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file masterpiece-0.1.14.tar.gz.

File metadata

  • Download URL: masterpiece-0.1.14.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for masterpiece-0.1.14.tar.gz
Algorithm Hash digest
SHA256 58ca9cda6577e5eb8443ac9f4d909b89aa84a4de4cc636b902f57165584ace04
MD5 ea42ecd5ade198e86604a7fa55d51878
BLAKE2b-256 6166488b320b9ccb551583c746b7361e3165b205e37da421cb01b7b9366cc693

See more details on using hashes here.

File details

Details for the file masterpiece-0.1.14-py3-none-any.whl.

File metadata

  • Download URL: masterpiece-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 34.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for masterpiece-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 d8a948305d90e3683e960e285da9d3b1721f361a9cc89f96643d726ea3e15351
MD5 104d918af84187beb377dfb5c4c2b3d4
BLAKE2b-256 64c5efa29566581a7d78948fea8736c25dfc63bb11f3161825692c9e6cfca661

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page