{ "info": { "author": "Othoz GmbH", "author_email": "bourguignon@othoz.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation" ], "description": "Paragraph\n=========\n\nA pure Python micro-framework supporting seamless lazy and concurrent evaluation of computation graphs.\n\n.. image:: https://img.shields.io/pypi/v/paragraph.svg\n :target: https://pypi.org/project/paragraph/\n\n.. image:: https://img.shields.io/pypi/pyversions/paragraph.svg\n :target: https://pypi.org/project/paragraph/\n\n.. image:: https://travis-ci.org/Othoz/paragraph.svg?branch=master\n :target: https://travis-ci.org/Othoz/paragraph\n\n.. image:: https://readthedocs.org/projects/paragraph/badge/?version=latest\n :target: https://paragraph.readthedocs.io/en/latest/?badge=latest\n\n.. image:: https://api.codacy.com/project/badge/Coverage/9797bcf310104a38ab46098d366d9606\n :target: https://www.codacy.com/manual/Othoz/paragraph?utm_source=github.com&utm_medium=referral&utm_content=Othoz/paragraph&utm_campaign=Badge_Coverage\n\n.. image:: https://api.codacy.com/project/badge/Grade/9797bcf310104a38ab46098d366d9606\n :target: https://www.codacy.com/manual/Othoz/paragraph?utm_source=github.com&utm_medium=referral&utm_content=Othoz/paragraph&utm_campaign=Badge_Grade\n\n\nIntroduction\n''''''''''''\n\nParagraph adds the *functional programming paradigm* to Python in a minimal fashion. One additional class, ``Variable``, and a\nfunction decorator, ``op``, is all it takes to turn regular Python code into a *computation graph*, i.e. a computer representation of a system of\nequations:\n\n>>> import paragraph as pg\n>>> import operator\n>>> x, y = pg.Variable(\"x\"), pg.Variable(\"y\")\n>>> add = pg.op(operator.add)\n>>> s = add.op(x, y)\n\n\nThe few lines above fully instantiate a computation graph, here in its simplest form with just one equation relating ``x``, ``y`` and ``s`` via the function\n``add``. Given values for the input variables ``x`` and ``y``, the value of ``s`` is resolved as follows:\n\n>>> pg.evaluate([s], {x: 5, y: 10})\n[15]\n\n\nKey features\n''''''''''''\n\nThe main benefits of using paragraph stem from the following features of ``pg.session.evaluate``:\n\nLazy evaluation\n Irrespective of the size of the computation graph, only the operations required to evaluate the output variables are executed. Consider the following\n extension of the above graph:\n\n >>> z = pg.Variable(\"z\")\n >>> t = add.op(y, z)\n\n Then the statement:\n\n >>> pg.evaluate([t], {y: 10, z: 50})\n [60]\n\n just ignores the variables ``s`` and ``x`` altogether, since they do not contribute to the evaluation of ``t``. In particular, the operation ``add(x, y)``\n is not executed.\n\nEager currying\n Invoking an op with invariable arguments (that is, arguments that are not of type ``Variable``) just returns an invariable value: evaluation is\n eager whenever possible. If invariable arguments are provided for a subset of the input variables, the computation graph can be simplified using ``solve``,\n which returns a new variable:\n \n >>> u_x = pg.solve([u], {y: 10, z: 50})[0]\n \n Here, ``u_x`` is a different variable from ``u``: it now depends on a single input variable (``x``), and it knows nothing about a variable ``y`` or ``z``,\n instead storing a reference to the value of their sum ``t``, i.e. ``60``.\n\n Thus, ``pg.session.solve`` acts much as ``functools.partial``, except it simplifies the system of equations where possible by executing dependent\n operations whose arguments are invariable.\n\nGraph composition\n Assume a variable ``y`` depends on a number of input variables ``x_1``,..., ``x_p``, and another variable ``v`` on ``u_1``,...,``u_q`` (not necessarily\n different), and ``v`` should be identified to ``x_p``. The following statement:\n\n >>> y_v = pg.solve([y], args={x_p: v})[0]\n\n returns a new variable ``y_v`` that depends on ``x_1``,..., ``x_{p-1}`` as well as on ``u_1``,..., ``u_q``, as if the two computation graphs defining ``y``\n and ``v`` had been pieced together.\n\n Note that the respective input variables may overlap, with the restriction that ``v`` should not depend on ``x_p`` as that would result in a circular\n dependency. Also, additional arguments may be added to ``args`` in the statement above to set further values of the input variables ``x_1``,...,\n ``x_{p-1}``. However, values cannot be set for ``u_1``,..., ``u_q`` here, since they are not dependencies of ``y``, but of ``y_v``.\n\nTransparent multithreading\n Invoking ``evaluate`` or ``solve`` with an instance of ``concurrent.ThreadPoolExecutor`` will allow independent blocks of the computation graph to run in\n separate threads:\n\n >>> with ThreadPoolExecutor as ex:\n ... res = pg.evaluate([z_t], {t: 5}, ex)\n\n This is particularly beneficial if large subsets of the graph are independent.\n\n\nConstraints\n'''''''''''\n\nSide-effects\n------------\n\nThe features listed above come at some price, essentially because the order in which operations are actually executed generally differs from the order of\ntheir invocations. For paragraph to guarantee that a variable always evaluates to the same value given the same inputs, as in a system of mathematical\nequations, it is paramount that operations remain free of side-effects, i.e. they **never** mutate an object they received as an argument, or store as an\nattribute. The state sequence of the object would be, by definition, out of the control of the programmer.\n\nThere is close to nothing paragraph can do to prevent such a thing happening. When in doubt, make sure to operate on a copy of the argument.\n\nTyping\n------\n\nVariables do not carry any information regarding the type of the value they represent, which precludes binding a method of the underlying value to an\ninstance of ``Variable``: such instructions can appear only within the code of an op. Since binary operators are implemented using special methods in\nPython, this also precludes such statements as:\n\n>>> s = x + y\n\nfor this would be resolved by the Python interpreter into ``s = x.__add__(y)``, then ``s = y.__radd__(x)``, yet none of these methods is defined by\n``Variable``.\n\nFor more information please consult the `documentation `_.", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Othoz/paragraph", "keywords": "computation graph,concurrent,lazy", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "paragraph", "package_url": "https://pypi.org/project/paragraph/", "platform": "", "project_url": "https://pypi.org/project/paragraph/", "project_urls": { "Bug Tracker": "https://github.com/Othoz/paragraph/issues", "Documentation": "http://paragraph.readthedocs.io/en/latest/", "Homepage": "https://github.com/Othoz/paragraph" }, "release_url": "https://pypi.org/project/paragraph/1.2.1/", "requires_dist": null, "requires_python": ">=3.6", "summary": "A computation graph micro-framework providing seamless lazy and concurrent evaluation.", "version": "1.2.1", "yanked": false, "yanked_reason": null }, "last_serial": 6575131, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "bbe7c9f2fee41274fce9bb1a5b91dddc", "sha256": "5507561d8c5659047e16eb2e9cded1d9a4c1fc88489dd2bc09b76e660381c363" }, "downloads": -1, "filename": "paragraph-1.0.0.tar.gz", "has_sig": false, "md5_digest": "bbe7c9f2fee41274fce9bb1a5b91dddc", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 25480, "upload_time": "2019-10-28T11:40:44", "upload_time_iso_8601": "2019-10-28T11:40:44.019101Z", "url": "https://files.pythonhosted.org/packages/c9/c7/bab74663a13007bcfa4bd7aa1db38b3d159194e99535bb8c2262f1a93d90/paragraph-1.0.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.0.0a2": [ { "comment_text": "", "digests": { "md5": "07225680831c22b751bfbf461b84ab0d", "sha256": "db847f8c192a613046eeb1f6670517cdbd5a8082b33615037df90cb99fc13a8b" }, "downloads": -1, "filename": "paragraph-1.0.0a2.tar.gz", "has_sig": false, "md5_digest": "07225680831c22b751bfbf461b84ab0d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 27386, "upload_time": "2019-10-24T13:52:38", "upload_time_iso_8601": "2019-10-24T13:52:38.682704Z", "url": "https://files.pythonhosted.org/packages/2a/85/366bc614b16bbdddb95a119bf00c6612764b811425f8dd2942c1637abf70/paragraph-1.0.0a2.tar.gz", "yanked": false, "yanked_reason": null } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "9def84445c0548126440eb3a3e6bbfe2", "sha256": "2280fa05f253d26196768872f54977dcd223732e82776532f1b3d36602196b78" }, "downloads": -1, "filename": "paragraph-1.0.1.tar.gz", "has_sig": false, "md5_digest": "9def84445c0548126440eb3a3e6bbfe2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 25534, "upload_time": "2020-01-07T12:46:02", "upload_time_iso_8601": "2020-01-07T12:46:02.977459Z", "url": "https://files.pythonhosted.org/packages/bb/a0/e8932771a881e5f4b3c42e0e591fe1ff94a2a55926959e4bb7acfe1bf5c8/paragraph-1.0.1.tar.gz", "yanked": false, "yanked_reason": null } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "cd7d2852145893a1afe1e00c40feb25e", "sha256": "dacf086df7ed71ed3af50756a86ff9f44f95cba0f92498769096ec9fd168e2c1" }, "downloads": -1, "filename": "paragraph-1.1.0.tar.gz", "has_sig": false, "md5_digest": "cd7d2852145893a1afe1e00c40feb25e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 29156, "upload_time": "2020-01-22T10:45:25", "upload_time_iso_8601": "2020-01-22T10:45:25.412101Z", "url": "https://files.pythonhosted.org/packages/ee/95/a9a47c644c337d426b9512dc146dfda547d26d77bc2b3e6ef1702e283095/paragraph-1.1.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "3eaaea02e859e68cf58187010ccf0c04", "sha256": "aa0d7fc3080c96509eba36c2709fe8e6aba9ffebb5c71b794e59355ccdef4716" }, "downloads": -1, "filename": "paragraph-1.1.1.tar.gz", "has_sig": false, "md5_digest": "3eaaea02e859e68cf58187010ccf0c04", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 29494, "upload_time": "2020-01-23T13:33:10", "upload_time_iso_8601": "2020-01-23T13:33:10.885848Z", "url": "https://files.pythonhosted.org/packages/37/d3/cbd962ab347a0630877678da5810df5f579a6a72099f2f9a95aa1e2f6406/paragraph-1.1.1.tar.gz", "yanked": false, "yanked_reason": null } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "3f29304addd8b5724a7e52657a342c6d", "sha256": "9bd2ad34733c9f1c52f27e586dad90eaa2bca58c5865bd74a0f360fbba24981f" }, "downloads": -1, "filename": "paragraph-1.2.0.tar.gz", "has_sig": false, "md5_digest": "3f29304addd8b5724a7e52657a342c6d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 29567, "upload_time": "2020-01-27T14:59:44", "upload_time_iso_8601": "2020-01-27T14:59:44.118272Z", "url": "https://files.pythonhosted.org/packages/d1/1e/fa82a467d2c8d5c7451eab5b5ed05ee05c176be341036973423f8e97f4bd/paragraph-1.2.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "178964fa1ae46af47e8c13b2b4b3601e", "sha256": "b202701a79d24468dc0c75f59d21007012e1115edf9ca5d8e67a2938ee4daa1f" }, "downloads": -1, "filename": "paragraph-1.2.1.tar.gz", "has_sig": false, "md5_digest": "178964fa1ae46af47e8c13b2b4b3601e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 29635, "upload_time": "2020-02-05T09:56:14", "upload_time_iso_8601": "2020-02-05T09:56:14.776399Z", "url": "https://files.pythonhosted.org/packages/43/37/1635f9d77ecdc08318e7853bc3410184cd3f8137e34e9828717fb25f74d1/paragraph-1.2.1.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "178964fa1ae46af47e8c13b2b4b3601e", "sha256": "b202701a79d24468dc0c75f59d21007012e1115edf9ca5d8e67a2938ee4daa1f" }, "downloads": -1, "filename": "paragraph-1.2.1.tar.gz", "has_sig": false, "md5_digest": "178964fa1ae46af47e8c13b2b4b3601e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 29635, "upload_time": "2020-02-05T09:56:14", "upload_time_iso_8601": "2020-02-05T09:56:14.776399Z", "url": "https://files.pythonhosted.org/packages/43/37/1635f9d77ecdc08318e7853bc3410184cd3f8137e34e9828717fb25f74d1/paragraph-1.2.1.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }