DataBrewery / cubes

[NOT MAINTAINED] Light-weight Python OLAP framework for multi-dimensional data analysis
http://cubes.databrewery.org
Other
1.49k stars 312 forks source link

Settings and type-aware extension creation #430

Closed Stiivi closed 7 years ago

Stiivi commented 7 years ago

This change introduces a SettingsDict – a dictionary tied to a list of Setting objects which describe the keys and their types. The extension is now defined as:

from cubes.settings import Setting, SettingType

# Store is subclass of Extensible
class MyStore(Store, name="my"):
    extension_desc = "My custom store. It limits number of the queries."

    extension_settings = [
        Setting("url", SettingType.str, desc="Connection URL),
        Setting("query_limit", SettingType.int, desc="Max number of rows returned", default=1000),
    ]

    url: str
    query_limit: int

    def __init__(self, url: str, query_limit: int):
        self.url = url
        self.query_limit = query_limit

The extension can be initialized in two ways:

One can see all the details of extensions by running: slicer extension TYPE NAME. To list all extensions: slicer extension TYPE or just slicer extension.

Other changes