Load me later. A lazy plugin management system.
Project description
lml seamlessly finds the lml based plugins from your current python environment but loads your plugins on demand. It is designed to support plugins that have external dependencies, especially bulky and/or memory hungry ones. lml provides the plugin management system only and the plugin interface is on your shoulder.
lml enabled applications helps your customers [1] in two ways:
Your customers could cherry-pick the plugins from pypi per python environment. They could remove a plugin using pip uninstall command.
Only the plugins used at runtime gets loaded into computer memory.
When you would use lml to refactor your existing code, it aims to flatten the complexity and to shrink the size of your bulky python library by distributing the similar functionalities across its plugins. However, you as the developer need to do the code refactoring by yourself and lml would lend you a hand.
Quick start
The following code tries to get you started quickly with non-lazy loading.
from lml.plugin import PluginInfo, PluginManager
@PluginInfo("cuisine", tags=["Portable Battery"])
class Boost(object):
def make(self, food=None, **keywords):
print("I can cook %s for robots" % food)
class CuisineManager(PluginManager):
def __init__(self):
PluginManager.__init__(self, "cuisine")
def get_a_plugin(self, food_name=None, **keywords):
return PluginManager.get_a_plugin(self, key=food_name, **keywords)
if __name__ == '__main__':
manager = CuisineManager()
chef = manager.get_a_plugin("Portable Battery")
chef.make()
At a glance, above code simply replaces the Factory pattern should you write them without lml. What’s not obvious is, that once you got hands-on with it, you can start work on how to do lazy loading.
Installation
You can install lml via pip:
$ pip install lml
or clone it and install it:
$ git clone https://github.com/python-lml/lml.git
$ cd lml
$ python setup.py install
lml enabled project
Beyond the documentation above, here is a list of projects using lml:
lml is available on these distributions:
License
New BSD
Change log
0.1.0 - 21/10/2020
Updated
non class object can be a plugin too
#20: When a plugin was not installed, it now calls raise_exception method
0.0.9 - 7/1/2019
Updated
#11: more test contents for OpenSuse package validation
0.0.8 - 4/1/2019
Updated
#9: include tests, docs for OpenSuse package validation
0.0.7 - 17/11/2018
Fixed
#8: get_primary_key will fail when a module is loaded later
deprecated old style plugin scanner: scan_plugins
0.0.6 - 07/11/2018
Fixed
Revert the version 0.0.5 changes. Raise Import error and log the exception
0.0.5 - 06/11/2018
Fixed
#6: Catch and Ignore ModuleNotFoundError
0.0.4 - 07.08.2018
Added
#4: to find plugin names with different naming patterns
0.0.3 - 12/06/2018
Added
dict can be a pluggable type in addition to function, class
get primary tag of your tag, helping you find out which category of plugins your tag points to
0.0.2 - 23/10/2017
Updated
pyexcel#103: include LICENSE in tar ball
0.0.1 - 30/05/2017
Added
First release
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
File details
Details for the file lml-0.1.0.tar.gz
.
File metadata
- Download URL: lml-0.1.0.tar.gz
- Upload date:
- Size: 42.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57a085a29bb7991d70d41c6c3144c560a8e35b4c1030ffb36d85fa058773bcc5 |
|
MD5 | df74fb9e2298f416d3364d382912a7d3 |
|
BLAKE2b-256 | c55a006d93401d382f82584711c848826ac24bce9d79eb19d25da9cf1d783815 |
File details
Details for the file lml-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: lml-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec06e850019942a485639c8c2a26bdb99eae24505bee7492b649df98a0bed101 |
|
MD5 | 0065d8daef21aee7c19db8a1dad27ba0 |
|
BLAKE2b-256 | 1076b0967eae4af4b7ea22e8b8ece6f7655fb6a3f4f49428f41910f53a552e1e |