{ "info": { "author": "Nicholas Tietz-Sokolsky", "author_email": "me@ntietz.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Science/Research", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "\n\n# modmod\n\nmodmod is a library for making *Mod*-ular *Mod*-els. The primary problem that\nmodmod solves is how to load models at runtime without instantiating them\nmultiple times; in that respect, it is essentially a dependency injection\nsystem for models.\n\n# Installation\n\nTo use modmod, just install it with your package manager in the usual way. If\nyou use [Pipenv](https://docs.pipenv.org/), you can copy/paste this:\n\n```\npipenv install modmod\n```\n\n# Usage\n\nThere are two main pieces of modmod: Models and Pools.\n\nA `Pool` is a container for models. A `Model` can be treated like an augmented\nfunction which is a `Model` factory.\n\nHere's an example of defining the simplest possible model:\n\n```\nfrom modmod.model import Model\n\nclass AddThings(Model):\n def call(self, x: int, y: int) -> int:\n return x + y\n```\n\nAnd here is how you would use it:\n\n```\nimport modmod.pool\n\npool = modmod.pool.get()\n\nadder = pool.get(AddThings)\n\nz = adder(1, 2)\nprint(z) # prints 3\n```\n\nYou can also take a shortcut to get the model:\n\n```\nadder = AddThings.get()\n```\n\nHowever, this should never be done inside a model, bceause it will use the\ndefault pool and will have strange side effects if anyone tries to use your\nmodel in a non-default pool.\n\n## Models with initialization\n\nSometimes a model needs to be initialized to load in data or do other one-time\nstartup tasks. To do this, you just override the constructor and the `create`\nmethod. Here's an example for stripping stopwords:\n\n```\nimport nltk\nfrom modmod.model import Model\n\nclass RemoveStopwords(Model):\n def __init__(self, pool: Pool, config: Dict[str, Any], stopwords: List[str]) -> None:\n super().__init__(pool, config)\n self.stopwords = stopwords\n\n @classmethod\n def create(cls, pool: Pool, config: Dict[str, Any]) -> 'RemoveStopwords':\n nltk.download('stopwords')\n stopwords = nltk.corpus.stopwords.words('english')\n stopwords.append('')\n stopwords.remove('not')\n stopwords.remove('no')\n return RemoveStopwords(pool, config, stopwords)\n\n def call(self, words: List[str]) -> List[str]:\n return list(filter(lambda w: w not in self.stopwords, words))\n```\n\nThe `create` method is invoked when you call `RemoveStopwords.get()`. It is\nonly called the _first_ time you get a model; after that, the created model\nlives in the pool, and it will not be re-initialized.\n\n*Why are *`__init__`* and *`create`* both required?* This is a good question.\nThe reason comes down to configurability and use in testing environments.\nIn the example above, if you wanted to experiment with a new list of\nstopwords, you could use the constructor to create a model with that list and\nthen add it into the pool:\n```\npool = modmod.pool.get('stopwords-experiment')\nconfig = {}\n\nremove_new_stopwords = RemoveStopwords(pool, config, ['stop', 'word', 'list'])\npool.add_model(remove_new_stopwords, RemoveStopwords)\n```\nOnce it's added to the pool, any calls to\n`RemoveStopwords.get('stopwords-experiment')` will find and retrieve the\nmanually created model.\n\nNote: `create` is generally overridden if you have to do a heavy operation,\nlike downloading a file or reading in some data. If you are just using the pool\nand the config object, it's perfectly acceptable to override `__init__` and\nleave the default behavior for `create`.\n\n\n## Configuring the pool\n\nEvery model gets configuration passed into them, and this comes from the pool.\nSo, if you need configuration, you need to configure the pool.\n\n**Note:** the pool must be configured *before* you get any models, since\nconfiguring it overwrites the existing pool.\n\nTo configure the default pool:\n\n```\nimport modmod.pool\n\nconfig = {'opt1': 2}\n\nmodmod.pool.configure(config)\n```\n\n## Non-default Pools\n\nSometimes you will want separate pools for separate tasks. One example of this\nis for unit testing: you may want to test with multiple configurations of the\nmodel. To do this, you can use separate pools.\n\nThe first step is to configure the pool:\n\n```\nimport modmod.pool\n\npoolname = 'my-pool'\nconfig = {'opt1': 2}\n\nmodmod.pool.configure(config, poolname)\n```\n\nThe second step is just to use the pool!\n\n```\nimport modmod.pool\n\npool = modmod.pool.get('my-pool')\n\nadder = pool.get(AddThings)\n# Equivalent:\nadder = AddThings.get('my-pool')\n```\n\n# Roadmap\n\nWe have a few initiatives on the roadmap. Each of these will be a version bump:\n\n* [ ] Add support for data and model versioning, add support for model training\n* [ ] Add hooks for profiling, debugging, caching\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/Remesh/modmod", "keywords": "", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "modmod", "package_url": "https://pypi.org/project/modmod/", "platform": "", "project_url": "https://pypi.org/project/modmod/", "project_urls": { "Homepage": "https://github.com/Remesh/modmod" }, "release_url": "https://pypi.org/project/modmod/0.2.5/", "requires_dist": null, "requires_python": ">=3.6.0", "summary": "modular models for efficient ML development", "version": "0.2.5" }, "last_serial": 3978575, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "3642c14281fef97e4c9c9459def6b776", "sha256": "42536c3538ad2446b585b1e42f48c0bcdb8bfd491ceb57cf3e7781de9999f37b" }, "downloads": -1, "filename": "modmod-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "3642c14281fef97e4c9c9459def6b776", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 7372, "upload_time": "2018-06-14T13:52:29", "url": "https://files.pythonhosted.org/packages/3a/e1/728e02e1c7acc6256e02d631ae04ae55a95a633331231834965aa1a78d95/modmod-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "183c1d7bbffddfb0198cac71da749bba", "sha256": "688fddcded5649cac4c46ab53318c81c9e6878bacd626afcf9cd398395a809f4" }, "downloads": -1, "filename": "modmod-0.1.0.tar.gz", "has_sig": false, "md5_digest": "183c1d7bbffddfb0198cac71da749bba", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 10332, "upload_time": "2018-06-14T13:52:30", "url": "https://files.pythonhosted.org/packages/53/42/30be4fd62c273e89f50a4e71c1798416f023948501b9d1eb94e974f54dce/modmod-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "414112cf0634ec7e4fa0ec39d02e1f0b", "sha256": "6fda1fecd90b1cad9bc82a7a25bba3068edb0f3b806910a3b46107d3dbbf20d0" }, "downloads": -1, "filename": "modmod-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "414112cf0634ec7e4fa0ec39d02e1f0b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 9355, "upload_time": "2018-06-14T16:25:32", "url": "https://files.pythonhosted.org/packages/36/de/d8ba5ba25610dbb461d1888874d3255f2ba38f0cfde3a15480f537972f31/modmod-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "adc6bdc08d317ea7c081760d1f78e572", "sha256": "78f21c320d7c05afd9bd4828e6fa1c833cb7c9f47160a527947fd1a005ac41b8" }, "downloads": -1, "filename": "modmod-0.2.0.tar.gz", "has_sig": false, "md5_digest": "adc6bdc08d317ea7c081760d1f78e572", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 9144, "upload_time": "2018-06-14T16:25:34", "url": "https://files.pythonhosted.org/packages/13/6b/4896326a70e16943515ae753cb406ec6c12e6b646f33c8d4113ac0473ac0/modmod-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "081ca35cf3a43c4c8c12ed08b1d90f5d", "sha256": "ec53995795c8be58e6a3161e662c24537cd1a310d704cd3914ae25c1bc9e2e45" }, "downloads": -1, "filename": "modmod-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "081ca35cf3a43c4c8c12ed08b1d90f5d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 9380, "upload_time": "2018-06-14T16:27:35", "url": "https://files.pythonhosted.org/packages/67/3a/2518eec19a9c8b707041d04ff720c9684522775251b6cc47d53bc58f4413/modmod-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2ae909331a222a64a5bf8382e8548535", "sha256": "115fb02f20a1723a232bb42ed03e66dd70eace0cc00d086bf029c86210b9949c" }, "downloads": -1, "filename": "modmod-0.2.1.tar.gz", "has_sig": false, "md5_digest": "2ae909331a222a64a5bf8382e8548535", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 9195, "upload_time": "2018-06-14T16:27:36", "url": "https://files.pythonhosted.org/packages/c8/90/cee2d7ade9f482fd512a24e5cb932a4d52f9a8c8012332cddd11b8cc7304/modmod-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "ddc16a40e661596624779f8846f4ca2e", "sha256": "6299fcb9622588a12263b707c19b479a6b352ddc9a3ed94ef499ab5d917d61ea" }, "downloads": -1, "filename": "modmod-0.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "ddc16a40e661596624779f8846f4ca2e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 9804, "upload_time": "2018-06-14T17:56:18", "url": "https://files.pythonhosted.org/packages/c7/26/8efc60de8ecd1c34b8f1d8fba753babc55aba0ac440deeff84b09d9d3272/modmod-0.2.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7c4f8a667ac5793449e7726cc1b99165", "sha256": "778236a62b5dd5f62ae59c5f67369249974d718858157f35601ccb2c3fc3f06a" }, "downloads": -1, "filename": "modmod-0.2.2.tar.gz", "has_sig": false, "md5_digest": "7c4f8a667ac5793449e7726cc1b99165", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 9735, "upload_time": "2018-06-14T17:56:19", "url": "https://files.pythonhosted.org/packages/0f/79/93e6c22fb615c844c0b76bdf07c7e2900b91818c69f26a9bbda991c2f325/modmod-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "7a6ce00819c80ebbd0f3c38c552815a8", "sha256": "eaa4b66978a9f617492bc1dcda7cd81772634d59d12a32287a16f597eb9bf240" }, "downloads": -1, "filename": "modmod-0.2.3-py3-none-any.whl", "has_sig": false, "md5_digest": "7a6ce00819c80ebbd0f3c38c552815a8", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 9872, "upload_time": "2018-06-15T17:55:50", "url": "https://files.pythonhosted.org/packages/0f/25/bba6fabce4ffe9506b8f78b44e838d1a69bcf663d3a4b5bf00c9fdc731c8/modmod-0.2.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6e5f046172ece81ca2082db8daff9186", "sha256": "9e4fe5a8e84e88fabff11ba99b45aba92ac8f1f6cfa9ec0dcac365b5666fd9dd" }, "downloads": -1, "filename": "modmod-0.2.3.tar.gz", "has_sig": false, "md5_digest": "6e5f046172ece81ca2082db8daff9186", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 9754, "upload_time": "2018-06-15T17:55:51", "url": "https://files.pythonhosted.org/packages/5c/e2/f0260f1e4caa11336fb57b351d4a81e51d386449bc4155c4e8a603e5582c/modmod-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "28841952edbf5834362b07c56456dc66", "sha256": "d81438a2df68c36cc573e12bed8d521ab133e356af3d3fa16a23efc0c721a4cc" }, "downloads": -1, "filename": "modmod-0.2.4-py3-none-any.whl", "has_sig": false, "md5_digest": "28841952edbf5834362b07c56456dc66", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 9904, "upload_time": "2018-06-15T19:38:55", "url": "https://files.pythonhosted.org/packages/d9/b7/036a8637506c074a0a850e997f4d6828456023d453ebcffef02ec8452425/modmod-0.2.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "644cbbe50baa969ea2e2c0a8a1584f10", "sha256": "6dabf069da453f1dd1571724a18818a40b13d76421b38e022293e9a36ed78e92" }, "downloads": -1, "filename": "modmod-0.2.4.tar.gz", "has_sig": false, "md5_digest": "644cbbe50baa969ea2e2c0a8a1584f10", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 9798, "upload_time": "2018-06-15T19:38:56", "url": "https://files.pythonhosted.org/packages/0f/00/f037b72186528f23c600ce9a7b300819e8b30bf5e8a48645b1f66e718f80/modmod-0.2.4.tar.gz" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "8aca5d7353726fe6c2fbcf1a57af0c33", "sha256": "20b0e23032fd4b7d73ca6f67085d08f094d7ba18dbaa96c3312caf55f65ba505" }, "downloads": -1, "filename": "modmod-0.2.5-py3-none-any.whl", "has_sig": false, "md5_digest": "8aca5d7353726fe6c2fbcf1a57af0c33", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 5539, "upload_time": "2018-06-19T18:37:12", "url": "https://files.pythonhosted.org/packages/67/db/600b0e3ad735b628fb3c752a738bc1ffa7b039198cf9b5c65fe76810e63c/modmod-0.2.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3df88ca23f60d65f585f7a806ea8cda9", "sha256": "01f8f913334924daefd831aef6e8e0322177f05c5e176116e6d348ec1f73cd01" }, "downloads": -1, "filename": "modmod-0.2.5.tar.gz", "has_sig": false, "md5_digest": "3df88ca23f60d65f585f7a806ea8cda9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 9800, "upload_time": "2018-06-19T18:37:13", "url": "https://files.pythonhosted.org/packages/e2/a6/fc1aa6d794efd0121c41ef88013b51128d8a93141a4d09441a8708a56150/modmod-0.2.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8aca5d7353726fe6c2fbcf1a57af0c33", "sha256": "20b0e23032fd4b7d73ca6f67085d08f094d7ba18dbaa96c3312caf55f65ba505" }, "downloads": -1, "filename": "modmod-0.2.5-py3-none-any.whl", "has_sig": false, "md5_digest": "8aca5d7353726fe6c2fbcf1a57af0c33", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6.0", "size": 5539, "upload_time": "2018-06-19T18:37:12", "url": "https://files.pythonhosted.org/packages/67/db/600b0e3ad735b628fb3c752a738bc1ffa7b039198cf9b5c65fe76810e63c/modmod-0.2.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3df88ca23f60d65f585f7a806ea8cda9", "sha256": "01f8f913334924daefd831aef6e8e0322177f05c5e176116e6d348ec1f73cd01" }, "downloads": -1, "filename": "modmod-0.2.5.tar.gz", "has_sig": false, "md5_digest": "3df88ca23f60d65f585f7a806ea8cda9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 9800, "upload_time": "2018-06-19T18:37:13", "url": "https://files.pythonhosted.org/packages/e2/a6/fc1aa6d794efd0121c41ef88013b51128d8a93141a4d09441a8708a56150/modmod-0.2.5.tar.gz" } ] }