{ "info": { "author": "Nick Morley", "author_email": "nick.morley111@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# primal-grakn\n\nA convenience wrapper around the official [grakn-python client](https://github.com/graknlabs/grakn/tree/master/client-python).\n\n## Features\n\n- Less code / boilerplate.\n- Response data looks and acts like primitive data structures (python lists / dicts etc.). Thus more immediately intelligble, accessable, and JSON-serialisable.\n- Some added conveniences such as match_or_insert function.\n- Still access all underlying grakn-python client functionality where needed.\n\n## Why\n\nThe [grakn-python client](https://github.com/graknlabs/grakn/tree/master/client-python) provides a complete and efficient object-oriented method of interaction with a Grakn instance. It can require a lot of code and recursion to get data. This extension aims to provide convenience through reducing code involved in connecting to Grakn and working with response data. It reflects a manner of working with Grakn through python that I have found to be preferrable.\n\n## Usage\n\n### Example\n\n```python\nimport primal_grakn.primal_grakn as grakn\n\nwith grakn.Graph(uri='myuri', keyspace='mykeyspace') as graph:\n query = 'insert $a isa animal has name \\\"squirrel\\\";' # Escape your quotes, or use a raw string\n concept_map = graph.execute('match $a isa animal; get;')\n print(concept_map)\n [{'a': {\n 'id': 'V4144',\n 'type': 'animal',\n 'base_type': 'entity',\n 'attributes': [{\n 'id': 'V4216',\n 'label': 'name',\n 'value': 'squirrel'\n }]\n }}]\n print(concept_map.object) # Get the underlying ConceptMap object\n print(concept_map['a'].object) # Get the underlying Concept object\n graph.commit() # Don't forget to commit changes if you make them. N.B. this also closes the session\n```\n\n### API\n\n#### primal_grakn.Graph\n\n| Name | Type | Description | Params | Example |\n| --- | --- |--- | --- | --- |\n| Graph | Class | Initiates the session. | |\nGraph.execute | Method | Executes a query. | | execute('match $a isa animal') |\n| Graph.commit | Method | Commits the changes and ends the session. | |\n| Graph.match_or_insert | Method | Given a graql query string, match if it exists in the graph, or else insert it. | | match_or_insert('$a isa animal has name \\\\\"squirrel\\\\\";') \n\n#### primal_grakn.ConceptDict\n\nDictionary respresenation of a Grakn Concept object.\n\nName | Type | Description | Params | Example\n| --- | --- | --- | --- | --- |\n| ConceptDict.object | Grakn Concept object | Corresponding grakn-python object | | |\n\n### An explanation about explanations\n\nAt the time of writing, the explanation data structures Grakn provides are undocumented. Briefly, the Grakn ConceptMap object exposes the set of facts as a tree. The top level of this tree includes the inferred facts from the response, and the compositional facts are nested within deeper levels. \n\nAt present, we provide two structures to access these facts: one is .explanation, which is the explanation tree as it is exposed by grakn-python, parsed into the form of a python dictionary. The second is .flat_explanation, where the tree is flattened into a list. I found this much more convenient for my purposes, as it meant I could filter the list for only the types of concepts I was interested in for my explanation, and then sort the list into the logical order (Grakn does not provide any ordering in its explanation output).\n\nIf you don't need information about the depth of inferences underlying your response, use .flat_explanation. \n\nI feel this is an area where ripe for improvement both as regards the Grakn API and third party packages such as this.\n\n### Installation\n\n#### Clone the repo\n\n```bash\ngit clone https://github.com/cyclecycle/pygrakn.git\n```\n\n#### Requirements\n\n- Grakn running.\n- Official python-grakn client:\n\n `pip install grakn`\n\n## Contributions\n\nAre welcome :)\n\n\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/cyclecycle/primal-grakn", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "primal-grakn", "package_url": "https://pypi.org/project/primal-grakn/", "platform": "", "project_url": "https://pypi.org/project/primal-grakn/", "project_urls": { "Homepage": "https://github.com/cyclecycle/primal-grakn" }, "release_url": "https://pypi.org/project/primal-grakn/0.0.1/", "requires_dist": [ "grakn (==1.4.2)" ], "requires_python": "", "summary": "A convenience wrapper around the official grakn-python client", "version": "0.0.1" }, "last_serial": 4508511, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "444b764487daa9245d9d4d6eb81d8543", "sha256": "c00589897d5154fa2fd3513b1018b9345312094068ed101bf02f4f12b0e9e55a" }, "downloads": -1, "filename": "primal_grakn-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "444b764487daa9245d9d4d6eb81d8543", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6841, "upload_time": "2018-11-20T17:01:52", "url": "https://files.pythonhosted.org/packages/ea/22/b94f7ee586603da79783a262dd43e8c9eb9c011f8f751b468eec134ec89b/primal_grakn-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4a263aac40bd24da531421eb1f78867b", "sha256": "c7180741baa405df63e27c5a48ce8e0d833bfc6d6cba97943b63e46883500c11" }, "downloads": -1, "filename": "primal-grakn-0.0.1.tar.gz", "has_sig": false, "md5_digest": "4a263aac40bd24da531421eb1f78867b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5503, "upload_time": "2018-11-20T17:01:54", "url": "https://files.pythonhosted.org/packages/72/c4/00d953fa66d7cef28a2f3a956fb7d56fd9de4010ce516a3a677abd9b4e75/primal-grakn-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "444b764487daa9245d9d4d6eb81d8543", "sha256": "c00589897d5154fa2fd3513b1018b9345312094068ed101bf02f4f12b0e9e55a" }, "downloads": -1, "filename": "primal_grakn-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "444b764487daa9245d9d4d6eb81d8543", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6841, "upload_time": "2018-11-20T17:01:52", "url": "https://files.pythonhosted.org/packages/ea/22/b94f7ee586603da79783a262dd43e8c9eb9c011f8f751b468eec134ec89b/primal_grakn-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4a263aac40bd24da531421eb1f78867b", "sha256": "c7180741baa405df63e27c5a48ce8e0d833bfc6d6cba97943b63e46883500c11" }, "downloads": -1, "filename": "primal-grakn-0.0.1.tar.gz", "has_sig": false, "md5_digest": "4a263aac40bd24da531421eb1f78867b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5503, "upload_time": "2018-11-20T17:01:54", "url": "https://files.pythonhosted.org/packages/72/c4/00d953fa66d7cef28a2f3a956fb7d56fd9de4010ce516a3a677abd9b4e75/primal-grakn-0.0.1.tar.gz" } ] }