{ "info": { "author": "Mara contributors", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "# mara-config\n\nApp composing and configuration infrastructure of the mara ecosystem. The packages functionality contains:\n\n* a way to compose an mara app\n* a simply config system based on replaceable functions\n\n## Build an app\n\nThe goal of mara ecosystem is that if you update a package, new\nfunctionality is added automatically to your app or database\nmigration automatically include newly declared models. To make\nthe app still composable, you build a function `compose_app()` in\nmodule `app.app`. This function should then call\n`mara_config.register_functionality(module)` for all modules it wants\nto include.\n\nYour own app should both contribute functionality (see next section) and\nregister itself via `mara_config.register_functionality(your_module)`.\n\nThe default module can be overwritten by setting the env variable:\n`MARA_APP=module.submodule`.\n\n### Contribute functionality in a package\n\nA package has to expose their functionality via `MARA_*` iterables\n(either lists or functions returning a list or generators). The \niterable contains the to be added functionality. It is advised to \nuse functions returning a list or generators so functionality will be\nlazily loaded when the functionality is actually used. This is\nespecially important if you use optional dependencies (e.g. a flask\nview which exposes the config system, but the config system itself\nis usable without the flask views).\n\nIf a package contains sub-functionality which can be consumed\nindependently from each other, consider putting them into subpackages\nand let the main module return a union of all sub-functionality.\n\n### Consume contributed functionality\n\nContributed functionally can be consumed by calling\n`mara_config.get_contributed_functionality('MARA_VARIABLE_NAME')` which yields\nthe functionality in tuples `(module, content)`. `module` is the\nmodule used in the `mara_config.register_functionality(module)` call.\n\nThe consumer should then add the functionality in the right places, e.g.\nthe `mara` shell command (in the mara-cli package) adds all contributed \nclick commands as subcommands.\n\n## Mara config\n\nConfiguration system based on replaceable functions.\n\nOne side declares a replaceable function as config by decorating that\nfunctions with `@declare_config()`. To change this config,\ndecorate a replacement function with `@set_config('name')`.\n\nThe default name of a config is `orig_package.func` but can be overwritten\nin the `@declare_config('name')` decorator.\n\n### Example\n\n```python\n# in package which declares API\nfrom mara_config import declare_config\n@declare_config(\"name\")\ndef something(argument:str=None) -> str:\n return \"x\"\n\nprint(something())\nprint(something(\"ABC\"))\n\n# In downstream package which want's to overwrite the API\nfrom mara_config import set_config\n@set_config('name')\ndef replacement_for_something(argument:str=None) -> str:\n return argument or 'y'\n\nprint(something())\nprint(something(\"ABC\"))\n```\n\n## Configs from local_setup.py\n\nPer default a `local_setup.py` in the module defined in the environment\nvariable `MARA_APP` and all modules higher up (first one found wins) is\nimported. Use this to place all you local modifications to configs and\nexclude this file from the repo (`.gitignore`).\n\n\n## Configs from Environment\n\nTo aid dockerization, replacement functions are also generated from\nenvironment variables. Environment config is loaded last and wins over\n`local_setup.py`!\n\nThis only works for config items which return either numbers (floats),\nbooleans, or strings.\n\nAny environment variable (case insensitive) which starts with 'MARA_' is\nturned into functions which returns the value. The rest of the environment\nvariable name has any `__` replaced by '.'. If the value is a valid float,\nit's returned as a float. If it's a valid bool, it's returned as a boolean.\nOtherwise it's returned as a string.\n\nE.g. the following variable\n\n MARA_PACKAGENAME__CONFIG_ITEM=y\n\nis equivalent to the following `@set_config` call\n\n```python\nfrom mara_config import set_config\n\n@set_config('packagename.config_item')\ndef replacement():\n return 'y'\n```\n\n## Contributed MARA_* functionality in this package\n\n* a Flask view to show the current configuration (`MARA_FLASK_BLUEPRINTS`)\n* an ACL ressource to protect access to the config view (`MARA_ACL_RESOURCES`)\n* a navigation entry (`MARA_NAVIGATION_ENTRY_FNS`)\n* Some default configuration entries (`MARA_CONFIG_MODULES`)\n\nTo use, add this funcitonality, add `mara_config.register_functionality(mara_config)`\nto your `compose_mara_app()` function.\n\n## Consumed MARA_* functionality\n\nThe packge will load all modules which are declared in `MARA_CONFIG_MODULES` if asked to show the\ncurrent configuration.\n\n`MARA_CONFIG_MODULES` must be a `list/generator/function which returns a list` which\ncontains all modules which declare user facing configuration (`@declare_config()`). \nWhen displaying the config (e.g. via `mara print_config` or the included flask view), \nall modules will be loaded and all included `@declare_config()` decorated functions \ntherefore added to the config system. \n\nOnly user facing configs should be in such modules, interal API can be elsewhere \n(but won't be shown if not set).", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "mara-config", "package_url": "https://pypi.org/project/mara-config/", "platform": "", "project_url": "https://pypi.org/project/mara-config/", "project_urls": null, "release_url": "https://pypi.org/project/mara-config/0.2.0/", "requires_dist": null, "requires_python": "", "summary": "Mara app composing and configuration infrastructure.", "version": "0.2.0" }, "last_serial": 4087228, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "4e38d3a312b2f8daa0fc07b646d7c548", "sha256": "df27fc99ff9e6203372692feebeae60e2b50b1fb8e9a1724af6c80a687be5d96" }, "downloads": -1, "filename": "mara-config-0.1.tar.gz", "has_sig": false, "md5_digest": "4e38d3a312b2f8daa0fc07b646d7c548", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10574, "upload_time": "2018-05-22T09:45:07", "url": "https://files.pythonhosted.org/packages/ee/14/a6a5aa8f3643708b6a3b19c7e3ef338e57eaf1dc8a3e3f4a36682d50a97a/mara-config-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "9777685902e7a51b3824e8f09815ea8a", "sha256": "5dad35248b965b87ad70642c16253569343db63d9d8f594e195df130dea6e310" }, "downloads": -1, "filename": "mara-config-0.1.1.tar.gz", "has_sig": false, "md5_digest": "9777685902e7a51b3824e8f09815ea8a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11016, "upload_time": "2018-05-22T10:49:16", "url": "https://files.pythonhosted.org/packages/d7/b3/8cbc089903d4e5801bb143a66f537f3388479996320e30a736b55f1e4a34/mara-config-0.1.1.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "cfdcf0fcdf564ae9d75c592faf1e37f7", "sha256": "5e0925c410525135e9bbf2499f8a0844489ab7226278bd14dacf27f9623df806" }, "downloads": -1, "filename": "mara-config-0.1.3.tar.gz", "has_sig": false, "md5_digest": "cfdcf0fcdf564ae9d75c592faf1e37f7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11255, "upload_time": "2018-07-03T10:55:59", "url": "https://files.pythonhosted.org/packages/2c/f4/a34c91d5049b554e8ad6871f84efae49328144bd7d1eb8292777b143b3e3/mara-config-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "29135b92d40ed6f5ae7701942a2766a6", "sha256": "07e2a0c0668b81abb2cb318717cda2c76be50be2c00b175bcbda68524a5546ef" }, "downloads": -1, "filename": "mara-config-0.1.4.tar.gz", "has_sig": false, "md5_digest": "29135b92d40ed6f5ae7701942a2766a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12060, "upload_time": "2018-07-09T16:17:23", "url": "https://files.pythonhosted.org/packages/4b/b6/508e000afccc110b9c3ad32caa9dc1951b50e57c5ea1e94bf3ccd184d347/mara-config-0.1.4.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "d7683397b7857ee13a71940cb058f7a6", "sha256": "7e1724b2b49f9b44c57248b01df7d02c9432205c79f56767ed51f97b6e8327a8" }, "downloads": -1, "filename": "mara-config-0.2.0.tar.gz", "has_sig": false, "md5_digest": "d7683397b7857ee13a71940cb058f7a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13158, "upload_time": "2018-07-20T22:19:40", "url": "https://files.pythonhosted.org/packages/0f/cd/969984208263379395130b47402966603c50eb95e8b9f0d5271737385947/mara-config-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d7683397b7857ee13a71940cb058f7a6", "sha256": "7e1724b2b49f9b44c57248b01df7d02c9432205c79f56767ed51f97b6e8327a8" }, "downloads": -1, "filename": "mara-config-0.2.0.tar.gz", "has_sig": false, "md5_digest": "d7683397b7857ee13a71940cb058f7a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13158, "upload_time": "2018-07-20T22:19:40", "url": "https://files.pythonhosted.org/packages/0f/cd/969984208263379395130b47402966603c50eb95e8b9f0d5271737385947/mara-config-0.2.0.tar.gz" } ] }