Git Product home page Git Product logo

lml's Introduction

lml - Load me later. A lazy plugin management system.

https://codecov.io/github/python-lml/lml/coverage.png https://pepy.tech/badge/lml/month https://img.shields.io/github/stars/python-lml/lml.svg?style=social&maxAge=3600&label=Star https://img.shields.io/static/v1?label=continuous%20templating&message=%E6%A8%A1%E7%89%88%E6%9B%B4%E6%96%B0&color=blue&style=flat-square https://img.shields.io/static/v1?label=coding%20style&message=black&color=black&style=flat-square https://readthedocs.org/projects/lml/badge/?version=latest

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:

  1. Your customers could cherry-pick the plugins from pypi per python environment. They could remove a plugin using pip uninstall command.
  2. 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.

[1]the end developers who uses your library and packages achieve their objectives.

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:

  1. pyexcel
  2. pyecharts
  3. moban

lml is available on these distributions:

  1. ARCH linux
  2. Conda forge
  3. OpenSuse

License

New BSD

lml's People

Contributors

chfw avatar ayan-b avatar mcepl avatar gitter-badger avatar pgajdos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.