{ "info": { "author": "Ousama Esbel", "author_email": "esbel@compredict.de", "bugtrack_url": null, "classifiers": [], "description": "COMPREDICT's AI CORE API Client\n===============================\n\nPython client for connecting to the COMPREDICT V1 REST API.\n\nTo find out more, visit the official documentation website:\nhttps://compredict.de\n\nRequirements\n------------\n\n- Python >= 3.4\n- Requests >= 2.1.0\n- pycrypto >= 1.4.0\n\n**To connect to the API with basic auth you need the following:**\n\n- API Key taken from COMPREDICT's User Dashboard\n- Username of the account.\n- (Optional) Callback url to send the results\n- (Optional) Private key for decrypting the messages.\n\nInstallation\n------------\n\nYou can use `pip` or `easy-install` to install the package:\n\n~~~shell\n $ pip install COMPREDICT-AI-SDK\n~~~\n\nor\n\n~~~shell\n $ easy-install COMPREDICT-AI-SDK\n~~~\n\nConfiguration\n-------------\n\n### Basic Auth\n~~~python\nimport compredict\n\ncompredict_client = compredict.client.api.get_instance(token=token, callback_url=None, ppk=None, passphrase=\"\")\n~~~\n\nWe highly advice that the SDK information are stored as environment variables and called used `environ`.\n\nAccessing Algorithms (GET)\n--------------------------\n\nTo list all the algorithms in a collection:\n\n~~~python\nalgorithms = compredict_client.getAlgorithms()\n\nfor algorithm in algorithms:\n print(algorithm.name)\n print(algorithm.version)\n~~~\n\nTo access a single algorithm:\n\n~~~python\nalgorithm = compredict_client.getAlgorithm('ecolife')\n\nprint(algorithm.name)\nprint(algorithm.description)\n~~~\n\nAlgorithm Prediction (POST)\n-----------------------------\n\nSome resources support creation of new items by posting to the collection. This\ncan be done by passing an array or stdClass object representing the new\nresource to the global create method:\n\n~~~python\nX_test = dict(\n feature_1=[1, 2, 3, 4],\n feature_2=[2, 3, 4, 5]\n)\n\nalgorithm = compredict_client.getAlgorithm('algorithm_id')\nresult = algorithm.run(X_test)\n~~~\n\nDepending on the algorithm's computation requirement, the result can be:\n\n- **Task**: holds a job id of the task that the user can query later to get the results.\n- **Result**: contains the result of the algorithm + evaluation\n\nYou can identify when the algorithm dispatches the processing to queue\nor send the results instantly by:\n\n~~~python\nprint(algorithm.results)\n~~~\n\nor dynamically:\n\n~~~python\nresults = algorithm.predict(X_test, evaluate=True)\n\nif isinstance(results, resources.Task):\n print(results.job_id)\n\n while results.status != results.STATUS_FINISHED:\n print(\"task is not done yet.. waiting...\")\n sleep(15)\n results.update()\n\n if results.success is True:\n print(results.predictions)\n else:\n print(results.error)\n\nelse: # not a Task, it is a Result Instance\n print(results.predictions)\n~~~\n\nIf you set up ``callback_url`` then the results will be POSTed automatically to you once the\ncalculation is finished.\n\n\nData Privacy\n------------\n\nWhen the calculation is queued in COMPREDICT, the result of the calculations will be stored temporarily for three days. If the data is private and there are organizational issues in keeping this data stored in COMPREDICT, then you can encrypt the data using RSA. COMPREDICT allow user's to add RSA public key in the Dashboard. Then, COMPREDICT will use the public key to encrypt the stored results. In return, The SDK will use the provided private key to decrypt the returned results.\n\nCOMPREDICT will only encrypt the results when:\n\n- The user provide a public key in the dashboard.\n- Specify **encrypt** parameter in the predict function as True.\n\nHere is an example:\n~~~python\n# First, you should provide public key in COMPREDICT's dashboard.\n\n# Second, Call predict and set encrypt as True\nresults = algorithm.predict(X_test, evaluate=True, encrypt=True)\n\nif isinstance(results, resources.Task):\n if results.status is results.STATUS_FINISHED:\n print(results.is_encrypted)\n~~~\n\n\nHandling Errors And Timeouts\n----------------------------\n\nFor whatever reason, the HTTP requests at the heart of the API may not always\nsucceed.\n\nEvery method will return false if an error occurred, and you should always\ncheck for this before acting on the results of the method call.\n\nIn some cases, you may also need to check the reason why the request failed.\nThis would most often be when you tried to save some data that did not validate\ncorrectly.\n\n~~~python\nalgorithms = compredict_client.getAlgorithms()\n\nif not algorithms:\n error = compredict_client.last_error\n~~~\n\nReturning false on errors, and using error objects to provide context is good\nfor writing quick scripts but is not the most robust solution for larger and\nmore long-term applications.\n\nAn alternative approach to error handling is to configure the API client to\nthrow exceptions when errors occur. Bear in mind, that if you do this, you will\nneed to catch and handle the exception in code yourself. The exception throwing\nbehavior of the client is controlled using the failOnError method:\n\n~~~python\ncompredict_client.failOnError()\n\ntry:\n orders = compredict_client.getAlgorithms()\nraise compredict.exceptions.CompredictError as e:\n ...\n~~~\n\nThe exceptions thrown are subclasses of Error, representing\nclient errors and server errors. The API documentation for response codes\ncontains a list of all the possible error conditions the client may encounter.\n\n\nVerifying SSL certificates\n--------------------------\n\nBy default, the client will attempt to verify the SSL certificate used by the\nCOMPREDICT AI Core. In cases where this is undesirable, or where an unsigned\ncertificate is being used, you can turn off this behavior using the verifyPeer\nswitch, which will disable certificate checking on all subsequent requests:\n\n~~~python\ncompredict_client.verifyPeer(false)\n~~~\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/compredict/ai-sdk-python", "keywords": "COMPREDICT,AI,SDK,API,rest", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "COMPREDICT-AI-SDK", "package_url": "https://pypi.org/project/COMPREDICT-AI-SDK/", "platform": "", "project_url": "https://pypi.org/project/COMPREDICT-AI-SDK/", "project_urls": { "Homepage": "https://github.com/compredict/ai-sdk-python" }, "release_url": "https://pypi.org/project/COMPREDICT-AI-SDK/0.0.1/", "requires_dist": [ "pycrypto (>=1.4.0)", "requests (>=2.1.0)" ], "requires_python": "", "summary": "Connect Python applications with COMPREDICT AI Core.", "version": "0.0.1" }, "last_serial": 4511624, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "f47d5f7ab3840a92940fb10944d63bed", "sha256": "4aeae87e51ca01c1706594a1f421256618b9b1f4fa26fefb17fd193d55032527" }, "downloads": -1, "filename": "COMPREDICT_AI_SDK-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "f47d5f7ab3840a92940fb10944d63bed", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10663, "upload_time": "2018-11-21T10:03:17", "url": "https://files.pythonhosted.org/packages/9f/fa/79836ad59bdc47be63acee45e40c9e43147195f7e4336303eacf5eca93cc/COMPREDICT_AI_SDK-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ca54be242fbc405f0646120d01f67771", "sha256": "6c00605e87ffee1de1dad954680c787068259c603bc2d336856b91ade217d1e9" }, "downloads": -1, "filename": "COMPREDICT-AI-SDK-0.0.1.tar.gz", "has_sig": false, "md5_digest": "ca54be242fbc405f0646120d01f67771", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10136, "upload_time": "2018-11-21T10:03:19", "url": "https://files.pythonhosted.org/packages/f5/6c/c0e3c01d53a5cdf8c53e65b23b899b9ec7ca9fa30361d1d551e542a91c7a/COMPREDICT-AI-SDK-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f47d5f7ab3840a92940fb10944d63bed", "sha256": "4aeae87e51ca01c1706594a1f421256618b9b1f4fa26fefb17fd193d55032527" }, "downloads": -1, "filename": "COMPREDICT_AI_SDK-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "f47d5f7ab3840a92940fb10944d63bed", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10663, "upload_time": "2018-11-21T10:03:17", "url": "https://files.pythonhosted.org/packages/9f/fa/79836ad59bdc47be63acee45e40c9e43147195f7e4336303eacf5eca93cc/COMPREDICT_AI_SDK-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ca54be242fbc405f0646120d01f67771", "sha256": "6c00605e87ffee1de1dad954680c787068259c603bc2d336856b91ade217d1e9" }, "downloads": -1, "filename": "COMPREDICT-AI-SDK-0.0.1.tar.gz", "has_sig": false, "md5_digest": "ca54be242fbc405f0646120d01f67771", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10136, "upload_time": "2018-11-21T10:03:19", "url": "https://files.pythonhosted.org/packages/f5/6c/c0e3c01d53a5cdf8c53e65b23b899b9ec7ca9fa30361d1d551e542a91c7a/COMPREDICT-AI-SDK-0.0.1.tar.gz" } ] }