{ "info": { "author": "Michael Wright", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "Python Type Registry\n=======================================\n\n[![Build Status](https://travis-ci.org/mikekwright/py-type-registry.svg?branch=master)](https://travis-ci.org/mikekwright/py-type-registry) \n\nThe `type-registry` library provides the ability to easily register factory methods (or classes) that can be\nused in a configuration file to quickly construct complex objects (or models). \n\n## Example\n\nLets demonstrate how to easily use this library. There are a functions and decorators, but the most important is the `register`\ndecorator. By registering a type, we are telling the system that when a configuration section has a special key `__factory__`\nto construct that section into an object. \n\nWe start by registering our `PytorchExample` and give it a more usable name of `pytorch-model`. \n\n```python\nimport torch.nn as nn\n\nfrom type_registry import register\n\n@register('pytorch-model', input_size=1024, output_size=8)\ndef PytorchExample(nn.Module):\n def __init__(self, input_size, hidden_size, output_size):\n ...\n```\n\nNow that we have the type registered with the system, in the configuration we can supplied the details\naround its construction (in this case we are just providing the value of the `hidden_size`) \n\n```yaml\nmodel:\n __factory__: pytorch-model\n hidden_size: ...\n```\n\n### Constructing from config\n\nOnce we have our types registered and a config defined, we need to correctly load the configuration so that\nit will construct the types. This is accomplished using the `load_yaml` and `load_yaml_str` functions. \n\n```python\nfrom type_registery import load_yaml_str\n\nyaml_str = get_config()\nresult = load_yaml_str(yaml_str)\n```\n\nYou can also have environment variables (or custom variables) automatically expanded in the same configuration\nfile. \n\n```yaml\nmodel:\n __factory__: simple-model\n use_aws: $USE_AWS\n```\n\n## Viewing the Registery\n\nTo make working with the library a little easier, there is a function that can be called which will print out\nthe details of the registery (at the time the call takes place). \n\n```python\nfrom type_registery import print_registry\n\nif __name__ == '__main__':\n print_registery(color=True)\n```\n\nSetting the `color` value to True will have the system print out the results using shell coloring (termcolor library).\nYou can also have the output of the `print_registry` call target a file instead of `stdout`. \n\n```python\nfrom type_registery import print_registry\n\nif __name__ == '__main__':\n with open('registry.txt', 'w') as f:\n print_registry(file=f)\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mikewright/py-type-registry.git", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "type-registry", "package_url": "https://pypi.org/project/type-registry/", "platform": "", "project_url": "https://pypi.org/project/type-registry/", "project_urls": { "Homepage": "https://github.com/mikewright/py-type-registry.git" }, "release_url": "https://pypi.org/project/type-registry/1.2/", "requires_dist": [ "PyYAML (<4.0,>=3.13)", "termcolor (<2.0,>=1.1.0)", "wheel (>=0.29) ; extra == 'dev'", "pytest (>=3.0) ; extra == 'dev'", "pytest-cov (>=2.4) ; extra == 'dev'", "pylint (>=1.8.1) ; extra == 'dev'" ], "requires_python": "", "summary": "Package for registering types and creating systems based on config files", "version": "1.2" }, "last_serial": 5679621, "releases": { "0.5": [ { "comment_text": "", "digests": { "md5": "ee02c280e8fa3c7f6e757ccd3fb2b912", "sha256": "38581a29fe5d8ee1bc0bb551e2426dfd85f5815c5bb1607f5a475771876841b0" }, "downloads": -1, "filename": "type_registry-0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "ee02c280e8fa3c7f6e757ccd3fb2b912", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9532, "upload_time": "2019-08-14T07:37:34", "url": "https://files.pythonhosted.org/packages/14/8e/474e066027ead9be8b6c03fceaaad53607aa2f393279773639ff19ef5e82/type_registry-0.5-py3-none-any.whl" } ], "1.0": [ { "comment_text": "", "digests": { "md5": "b40626c447929b816b4bc511af34b811", "sha256": "e84441c053012de6a2e249baaf028ddde3d30aab9b287b423d56606196d30bd5" }, "downloads": -1, "filename": "type_registry-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b40626c447929b816b4bc511af34b811", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12626, "upload_time": "2019-08-14T18:09:35", "url": "https://files.pythonhosted.org/packages/2b/9c/8cd4edd48684f2bbfe2bf9d777bc0b95ce3ced5a6a7df7ca386aba67637e/type_registry-1.0-py3-none-any.whl" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "d48f508ab5e0ff9ba0b48726706e0fb1", "sha256": "3a18351a536d5937a411b3a63736c3748f34e53a464bcdffd1047859cf631432" }, "downloads": -1, "filename": "type_registry-1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "d48f508ab5e0ff9ba0b48726706e0fb1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14120, "upload_time": "2019-08-14T21:40:47", "url": "https://files.pythonhosted.org/packages/ca/7a/11c6db188e2fc3016c0823a674ffd6e2f7d7777c2f66738ed33a48d82d32/type_registry-1.1-py3-none-any.whl" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "99a7943d26e4fba2281fa0ca41afd223", "sha256": "77b74c091d93c6e657e7a829d51578fad45cc508f02367de7ab75e204bf0f0f5" }, "downloads": -1, "filename": "type_registry-1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "99a7943d26e4fba2281fa0ca41afd223", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14166, "upload_time": "2019-08-14T22:30:43", "url": "https://files.pythonhosted.org/packages/76/6f/93564b85c2ec4d794dabcdb0630fe1965d6c4afc372f4b41a689d9af9a80/type_registry-1.2-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "99a7943d26e4fba2281fa0ca41afd223", "sha256": "77b74c091d93c6e657e7a829d51578fad45cc508f02367de7ab75e204bf0f0f5" }, "downloads": -1, "filename": "type_registry-1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "99a7943d26e4fba2281fa0ca41afd223", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14166, "upload_time": "2019-08-14T22:30:43", "url": "https://files.pythonhosted.org/packages/76/6f/93564b85c2ec4d794dabcdb0630fe1965d6c4afc372f4b41a689d9af9a80/type_registry-1.2-py3-none-any.whl" } ] }