{ "info": { "author": "('Joao Pimentel',)", "author_email": "joaofelipenp@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Scientific/Engineering :: Visualization", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# Extensible PROV-N\n\nThis tool intends to provide a way to visualize and query PROV-N with custom extensions. It was extracted from the [Versioned-PROV repository](https://github.com/dew-uff/versioned-prov).\n\n## Installation\n\nThis tool supports **Python 3.6** or greater. To install, please run:\n\n```\n$ pip install extensible_prov\n```\n\n## Basic visualization usage\n\nThis project installs three CLI commands to convert PROV-N to Graphviz Dot files:\n\n* `provn`: converts Plain PROV-N to dot. It generates a graph similar to [ProvToolbox](https://lucmoreau.github.io/ProvToolbox/)\n* `prov-dictionary`: converts PROV-Dictionary files to dot\n* `versioned-prov`: converts Versioned-PROV files to dot\n\nThese three commands have the same interface. To convert a PROV-N file to dot, just run:\n```\n$ provn --infile input.prov --outfile output.dot\n```\n\nThese commands also support input redirection:\n```\necho \"entity(e1)\" | provn | dot -Tpng -o pipe.png\n```\n![Resulting pipe.png](pipe.png)\n\n\nFor other options, see the the help:\n```\n$ versioned-prov -h\nusage: versioned-prov [-h] [-i INFILE] [-o OUTFILE] [-x WIDTH] [-y HEIGHT]\n [-r RANKDIR] [-s STYLE]\n\nConvert PROV-N to GraphViz Dot\n\noptional arguments:\n -h, --help show this help message and exit\n -i INFILE, --infile INFILE\n Input PROV-N file\n -o OUTFILE, --outfile OUTFILE\n Output dot file\n -x WIDTH, --width WIDTH\n Graph width\n -y HEIGHT, --height HEIGHT\n Graph height\n -r RANKDIR, --rankdir RANKDIR\n Graph rankdir\n -s STYLE, --style STYLE\n Graph style\n```\n\n## Styling\n\nThese commands support custom styles. It has four main built-in styles:\n\n* `default`: Default style that highlights nodes and edges specific to Prov-Dictionary and Versioned-PROV\n* `nohighlight`: Style that works for plain PROV, PROV-Dictionary, and Versioned-PROV, but does not highlight anything\n* `blackwhite`: Black and white style based on `nohighlight`\n* `provtoolbox`: Style based on [ProvToolbox](https://lucmoreau.github.io/ProvToolbox/). Labels are smaller than `nohighlight` style.\n\nUsage:\n```\necho \"entity(e1)\" | provn -s blackwhite | dot -Tpng -o blackwhite.png\n```\n![Resulting blackwhite.png](blackwhite.png)\n\n### Defining new Styles\n\nStyles are defined as modules with an EXPORT variable with a Style class. This class uses the `style` dictionary attribute to define individual styles for every element type.\n\nIn this dictionary, the *key* indicate which PROV-N statements or elements are affect by the style. Using a `*` at the end of the *key* overrides the other styles. It supports the following keys:\n* `label`: applies to general labels\n* `{statement}_label`: applies to statement labels\n* `{statement}{part}_label`: applies to part of statement labels\n* `arrow`: applies to general arrows\n* `node`: applies to general nodes\n* `{statement}`: applies to statement arrows or nodes\n* `{statement}{part}`: applies to part of statement arrows\n* `point`: applies to general points\n* `{statement}_point`: applies to statement points\n* `{statement}{part}_point`: applies to part of statement points\n* `attrs`: applies to general optional attributes\n* `{statement}_attrs`: applies to statement optional attributes\n* `attrs_arrow`: applies to general optional attributes arrows\n* `{statement}_attrs_arrow`: applies to statement optional attributes arrows\n* `after`: applies to statements after other styles\n* `arrow_after`: applies to arrows after other styles\n* `point_after`: applies to points after other styles\n* `node_after`: applies to nodes after other styles\n* `attrs_after`: applies to optional attributes after other styles\n\nIn this dictionary, the *value* can be either a dictionary with dot attributes, or a function that receives the statement and the attributes as arguments and returns a dictionary with dot attributes.\n\nThe following [module](opposite_bw.py) code presents a style example that outputs the opposite colors of the blackwhite style:\n\n```python\nfrom extensible_provn.view.style.nohighlight import NoHighlightStyle\n\nclass WhiteBlackStyle(NoHighlightStyle):\n\n def __init__(self):\n super(WhiteBlackStyle, self).__init__()\n self.style = self.join(self.style, {\n \"entity\": {\"fillcolor\": \"#000000\", \"fontcolor\": \"#FFFFFF\", \"style\": \"filled\"},\n \"activity\": {\n \"fillcolor\": \"#000000\", \"fontcolor\": \"#FFFFFF\",\n \"shape\": \"polygon\", \"sides\": \"4\", \"style\": \"filled\"\n },\n \"agent\": {\"fillcolor\": \"#000000\", \"fontcolor\": \"#FFFFFF\", \"shape\": \"house\", \"style\": \"filled\"},\n \"value\": {\"fillcolor\": \"#000000\", \"fontcolor\": \"#FFFFFF\", \"style\": \"filled\"},\n \"version\": {\"fillcolor\": \"#000000\", \"fontcolor\": \"#FFFFFF\", \"style\": \"filled\"},\n })\n\n\nEXPORT = WhiteBlackStyle\n```\n\nUsage:\n```\necho \"entity(e1)\" | provn -s opposite_bw | dot -Tpng -o opposite_bw.png\n```\n![Resulting opposite_bw.png](opposite_bw.png)\n\n\nOther styles that can be used as reference are available at: https://github.com/JoaoFelipe/extensible_provn/tree/master/extensible_provn/view/style\n\n## Extending PROV-N with views\n\nThis project supports extending PROV-N by adding new statements or overriding existing ones to add more options. It can be performed by using the decorator view.dot.graph.prov as following:\n\n```python\n\"\"\"\nPROV-N with entlist(lid; e1, e2, ..., en) statement that is equivalent to:\nentity(lid)\nentity(e1)\nhadMember(lid, e1)\nentity(e2)\nhadMember(lid, e2)\n...\nentity(en)\nhadMember(lid, en)\n\"\"\"\n\nfrom extensible_provn.view import provn # Use Plain PROV as base\nfrom extensible_provn.view.dot import graph\n\n@graph.prov(\"entlist\")\ndef entlist(dot, *args, attrs=None, id_=None):\n lines = [dot.node(attrs, \"entity\", id_)]\n for entity_id in args:\n lines.append(dot.node(attrs, \"entity\", entity_id))\n lines.append(dot.arrow2(attrs, \"hadMember\", id_, entity_id))\n return \"\\n\".join(lines)\n\nif __name__ == \"__main__\":\n graph.main()\n```\nNote: This code is valid for Python 3. Some changes are required for Python 2.\n\nThe `graph.main()` adds the default CLI to this extension.\n\nUsage:\n\n```\necho \"entlist(lid; e1, e2, e3)\" | python prov_list.py | dot -Tpng -o prov_list.png\n```\n\n![Resulting prov_list.png](prov_list.png)\n\n## Jupyter Integration\n\nBesides the CLI for converting PROV-N files to GraphViz files, this project also provides a *Cell Magic* to visualize the Provenance in Jupyter Noteboks. To do so, you must load the IPython extension and import the desirable PROV-N extension as follows:\n\n```python\n%load_ext extensible_provn.prov_magics\nimport extensible_provn.view.provn # Use Plain PROV as base\n```\n\nAnd then, use the `%%provn` cell magic in a Cell that you want to display the Graph.\n\n![Jupyter Notebook Example](jupyter.png)\n\nNote that it requires GraphViz to be installed. The option `-e pdf` may also benefit from an inkscape installation. However it uses GraphViz if inkscape is not installed.\n\n## Querying\n\nBesides visualizing provenance, we also support querying PROV-N files by pattern matching. The built-in queries are rather simple and incomplete, but extending them is similar to creating a visualization extension.\n\n```python\n\"\"\"Defines a pattern matching query for entlist\"\"\"\nfrom extensible_provn.query.provn import *\n\n@querier.prov(\"entlist\", [\"id\", \"elements\", \"text\"])\ndef entlist(querier, eid, *args, attrs={}, id_=None):\n return [\n id_, args,\n querier.text(\"entlist\", list(args), attrs, id_)\n ]\n```\n\nThis code does not need to be in a separate python file. It can be in a notebook.\n\nThen, to execute the query, you must load it into the querier:\n\n```python\nquerier.load_text(\"\"\"\nentity(lid1)\nentlist(lid1; e1, e2, e3)\nentlist(lid2; e4, e5)\n\"\"\")\n```\n\nAnd execute the pattern matching queries:\n\n```python\nEid, Elements, Text = var(\"Eid Elements Text\")\n_ = BLANK\nfor __ in entity(Eid, _) & entlist(Eid, Elements, Text):\n print(Eid.bound, Elements.bound, Text.bound)\n```\nThis query gets all entities that share the entity id with entlist, and prints their id, a tuple with the entlist elements, and the entlist text.\n\nOutput:\n```\nlid1 ('e2', 'e3') entlist(lid1; e2, e3)\n```\n\nNote in the query that we define variables (`var`) for elements that we want to extract and join across multiple rules. Additionally, we use `BLANK` for elements we want to ignore.\n\nNote also that the query function signature is based on the second argument of the `@querier.prov` decorator. Thus, the `entlist` query accepts only 3 parameters, while the `entlist` statement may accept many more.\n\n## Contributing\n\nFeel free to contribute with this project and submit pull requests, bug reports, or questions as issues.\n\nTo install the project for development, please run on the root of the repository.\n```\n$ pip install -e .\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/JoaoFelipe/extensible_provn", "keywords": "provenance visualization", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "extensible-provn", "package_url": "https://pypi.org/project/extensible-provn/", "platform": "", "project_url": "https://pypi.org/project/extensible-provn/", "project_urls": { "Homepage": "https://github.com/JoaoFelipe/extensible_provn" }, "release_url": "https://pypi.org/project/extensible-provn/0.2.1/", "requires_dist": [ "lark-parser" ], "requires_python": "", "summary": "Extensible PROV-N visualizer and querier", "version": "0.2.1" }, "last_serial": 3948132, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "d94d28fd31739fdde9769f50a683cfcd", "sha256": "f6dce10d3dcb81bdc6111d437f5eb9d0fe7273aea6a145ef42ff9b55a2a8265b" }, "downloads": -1, "filename": "extensible_provn-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "d94d28fd31739fdde9769f50a683cfcd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 39089, "upload_time": "2018-06-09T23:41:38", "url": "https://files.pythonhosted.org/packages/4d/78/b4d729c043f19a69794b8eb931d232999faaf42ca468f30dbee4dacba0cc/extensible_provn-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "349f95eeae60acb4e9b620d091fa678d", "sha256": "fbeb7631fbcfd0b3ddab97c54725521bcbde241fc088e20699312408f2948828" }, "downloads": -1, "filename": "extensible_provn-0.1.0.tar.gz", "has_sig": false, "md5_digest": "349f95eeae60acb4e9b620d091fa678d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28473, "upload_time": "2018-06-09T23:41:40", "url": "https://files.pythonhosted.org/packages/d6/fa/e09940f9d445aa5334de132f9811725c94b961c3c0c5994ade8fe492ac77/extensible_provn-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "ceb753007c303ebf317ca880a19e6d72", "sha256": "bee533a353533a0908fcc7eaffe0384b691897d4bda53858d420bc4ce3710d29" }, "downloads": -1, "filename": "extensible_provn-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ceb753007c303ebf317ca880a19e6d72", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 39104, "upload_time": "2018-06-09T23:44:25", "url": "https://files.pythonhosted.org/packages/0a/d0/0a30ad8335cedaf24afb955f44beb2feeb9788fac234d22484d934839236/extensible_provn-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "62ce3a7a3b3595c5a4176dc73daa32d4", "sha256": "441fc112130a84fcda50ade48a0ae473825b1924d08b98fa1cd4d39c174d3a7a" }, "downloads": -1, "filename": "extensible_provn-0.1.1.tar.gz", "has_sig": false, "md5_digest": "62ce3a7a3b3595c5a4176dc73daa32d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28500, "upload_time": "2018-06-09T23:44:26", "url": "https://files.pythonhosted.org/packages/76/8d/21564ea1af6b1ca599222073c983a1a36f92e9b8452d1639fe5abaa01090/extensible_provn-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "c26b6ebb1fc92a3d49437aa98cb060de", "sha256": "ea5d3cb67e8fbadf54da4660dad215d1cc34b7f2b2bc1e65703dd0ee086f8159" }, "downloads": -1, "filename": "extensible_provn-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c26b6ebb1fc92a3d49437aa98cb060de", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 41984, "upload_time": "2018-06-10T20:02:55", "url": "https://files.pythonhosted.org/packages/8c/33/0bae96ccddb39781d0803d6b0bbf035c641d6f39bb412ae02ba256cf725e/extensible_provn-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "520191f2ee979368dcdc4c3d7f494de8", "sha256": "12ff584521636bdf232c65642824e571b89056791de6fd221519148ad3859d0d" }, "downloads": -1, "filename": "extensible_provn-0.2.0.tar.gz", "has_sig": false, "md5_digest": "520191f2ee979368dcdc4c3d7f494de8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30301, "upload_time": "2018-06-10T20:02:56", "url": "https://files.pythonhosted.org/packages/84/33/845ca9696b10daee818fb0aa8e1c7a6271ee337e1efd1a8a653663d21d07/extensible_provn-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "69faeed476d656eb2e1f1f8b4d88e149", "sha256": "9fb984d3e90239b345c7a1085ae14e79663743eb50411a82c64961fc089dfc10" }, "downloads": -1, "filename": "extensible_provn-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "69faeed476d656eb2e1f1f8b4d88e149", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 37733, "upload_time": "2018-06-10T20:12:41", "url": "https://files.pythonhosted.org/packages/33/ac/864860c7a93bbc5df7cf6019eda27d0d90fe28f64bef2d1de5fc4d22e804/extensible_provn-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f57e2d383a48d9a9015926df71378379", "sha256": "1e403e939a249ca55cd64f3462a8d15ccf6a52553cc2a5755ea628ba920d84fc" }, "downloads": -1, "filename": "extensible_provn-0.2.1.tar.gz", "has_sig": false, "md5_digest": "f57e2d383a48d9a9015926df71378379", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30316, "upload_time": "2018-06-10T20:12:43", "url": "https://files.pythonhosted.org/packages/68/fb/1d42062f7ce2bdba227b7f3360c29aceb705f1341661c3cf44105dc8e73e/extensible_provn-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "69faeed476d656eb2e1f1f8b4d88e149", "sha256": "9fb984d3e90239b345c7a1085ae14e79663743eb50411a82c64961fc089dfc10" }, "downloads": -1, "filename": "extensible_provn-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "69faeed476d656eb2e1f1f8b4d88e149", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 37733, "upload_time": "2018-06-10T20:12:41", "url": "https://files.pythonhosted.org/packages/33/ac/864860c7a93bbc5df7cf6019eda27d0d90fe28f64bef2d1de5fc4d22e804/extensible_provn-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f57e2d383a48d9a9015926df71378379", "sha256": "1e403e939a249ca55cd64f3462a8d15ccf6a52553cc2a5755ea628ba920d84fc" }, "downloads": -1, "filename": "extensible_provn-0.2.1.tar.gz", "has_sig": false, "md5_digest": "f57e2d383a48d9a9015926df71378379", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30316, "upload_time": "2018-06-10T20:12:43", "url": "https://files.pythonhosted.org/packages/68/fb/1d42062f7ce2bdba227b7f3360c29aceb705f1341661c3cf44105dc8e73e/extensible_provn-0.2.1.tar.gz" } ] }