{ "info": { "author": "yszkst", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "restful-functions\n=================\n\nA Server Module to Build RESTful APIs for Python Fnctions.\n\nThis framework forks a new process to run the specified function on each api request.\n\nYou can specify a maximum concurrency of the function. The api request is denied if the nubmer of running processes for the function is already reaches the concurrency limitation.\n\nHow to Use\n----------\n\nExample Code::\n\n import concurrent.futures\n import math\n\n from restful_functions import ArgDefinition, ArgType, FunctionServer\n\n\n def addition(x: int, y: int):\n \"\"\"Simple Funciton.\"\"\"\n return x+y\n\n\n def is_prime(n):\n if n % 2 == 0:\n return False\n\n sqrt_n = int(math.floor(math.sqrt(n)))\n for i in range(3, sqrt_n + 1, 2):\n if n % i == 0:\n return False\n return True\n\n\n def multi():\n \"\"\"Heavy Function with MultiProcessing.\"\"\"\n PRIMES = [\n 112272535095293,\n 112582705942171,\n 112272535095293,\n 115280095190773,\n 115797848077099,\n 1099726899285419]\n\n with concurrent.futures.ProcessPoolExecutor() as executor:\n for number, prime in zip(PRIMES, executor.map(is_prime, PRIMES)):\n print('%d is prime: %s' % (number, prime))\n\n return True\n\n\n if __name__ == '__main__':\n server = FunctionServer()\n server.add_function(\n addition, # Function\n [\n ArgDefinition('x', ArgType.INTEGER, True, 'A value of X'),\n ArgDefinition('y', ArgType.INTEGER, True, 'A value of Y'),\n ], # Args\n 1, # Max Concurrency\n 'Simple Awesome Addition' # Description\n )\n server.add_function(\n multi,\n [],\n 2,\n 'Heavy Function'\n )\n server.start()\n\nExample Usage::\n\n $ curl localhost:8888/\n /function/list/data\n /function/list/text\n /function/definition/{function_name}\n /function/running-count/{function_name}\n /task/info/{task_id}\n /task/done/{task_id}\n /task/result/{task_id}\n /task/list/{function_name}\n /terminate/function/{function_name}\n /terminate/task/{task_id}\n\n $ curl localhost:8888/function/list/text\n addition\n URL:\n async api: /addition\n block api: /addition/keep-connection\n Max Concurrency: 1\n Description:\n Simple Awesome Addition\n Args\n x INTEGER Requiered\n A value of X\n y INTEGER Requiered\n A value of Y\n\n\n multi\n URL:\n async api: /multi\n block api: /multi/keep-connection\n Max Concurrency: 2\n Description:\n Heavy Function\n No Args\n\n\n # Call Asynchronous\n # Obtain task_id\n $ curl -X POST -H \"Content-Type: applicaiton/json\" -d '{\"x\":3, \"y\":6}' http://localhost:8888/addition\n {\"success\": true, \"message\": \"\", \"task_id\": \"c3a6a0ef-b19e-4e6f-bce3-8d0e5a9046aa\"}\n\n # Obtain the result by task_id\n $ curl http://localhost:8888/task/info/3a6a0ef-b19e-4e6f-bce3-8d0e5a9046aa\n {\"task_id\": \"c3a6a0ef-b19e-4e6f-bce3-8d0e5a9046aa\", \"function_name\": \"addition\", \"status\": \"DONE\", \"result\": 9}\n\n $ curl http://localhost:8888/task/result/c3a6a0ef-b19e-4e6f-bce3-8d0e5a9046aa\n 9\n\n # Call synchronous\n # Keeping the connection until the process ends.\n $ curl -X POST -H \"Content-Type: applicaiton/json\" -d '{\"x\":3, \"y\":6}' http://localhost:8888/addition/keep-connection\n 9\n\n # Over Max Concurrency\n $ curl -X POST http://localhost:8888/multi\n {\"success\": true, \"message\": \"\", \"task_id\": \"5bbbc1a0-74c2-4828-a843-fa2e2363e341\"}\n\n $ curl -X POST http://localhost:8888/multi\n {\"success\": true, \"message\": \"\", \"task_id\": \"7729af1f-c766-456e-a516-a75ab5f3a24c\"}\n\n $ curl -X POST http://localhost:8888/multi\n {\"success\": false, \"message\": \"Over Max Concurrency 2\", \"task_id\": \"\"}\n\n\nLICENSE\n-------\nMIT\n\nTODO\n----\n[ ] Write Documents\n\n[ ] Write CONTRIBUTING.md\n\n[ ] Show Test Coverage\n\n[ ] Deploy with CI Service\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/insight-technology/restful-functions", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "restful-functions", "package_url": "https://pypi.org/project/restful-functions/", "platform": "", "project_url": "https://pypi.org/project/restful-functions/", "project_urls": { "Homepage": "https://github.com/insight-technology/restful-functions" }, "release_url": "https://pypi.org/project/restful-functions/2.0.1/", "requires_dist": [ "aiohttp (>=3.5.4)", "docutils ; extra == 'dev'", "flake8 ; extra == 'dev'", "pygments ; extra == 'dev'", "wheel ; extra == 'dev'", "flake8 ; extra == 'test'", "mypy ; extra == 'test'", "pydocstyle ; extra == 'test'", "pytest ; extra == 'test'", "pytest-cov ; extra == 'test'", "pytest-runner ; extra == 'test'", "pytest-aiohttp ; extra == 'test'", "requests ; extra == 'test'" ], "requires_python": ">=3.6", "summary": "A Server Module to Build RESTful APIs for Python Functions", "version": "2.0.1" }, "last_serial": 5526438, "releases": { "0.0.0.post2": [ { "comment_text": "", "digests": { "md5": "d22ec0e6b2c34ebeed623b68ab372274", "sha256": "0eb39175ba3ea97afcae66ca5e84bb6194d4f877eb9cf2b635cf25a5b769bb89" }, "downloads": -1, "filename": "restful_functions-0.0.0.post2-py3-none-any.whl", "has_sig": false, "md5_digest": "d22ec0e6b2c34ebeed623b68ab372274", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 10119, "upload_time": "2019-02-21T09:59:34", "url": "https://files.pythonhosted.org/packages/af/08/2cc421bc4d188136a6b91457dd037b84f5c16a4f78eb34ab3593ec84cda2/restful_functions-0.0.0.post2-py3-none-any.whl" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "1d462536e34f09d181432a88444b2877", "sha256": "4f6ef897b302fdb0b902348c2df1fe20a075d286f38396aa296d163cd0487b5e" }, "downloads": -1, "filename": "restful_functions-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "1d462536e34f09d181432a88444b2877", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 10657, "upload_time": "2019-03-04T12:13:58", "url": "https://files.pythonhosted.org/packages/94/c5/e373c7927b145bfcc52deef93b31063a5e2a1ca4cecdc3f08e25500afd52/restful_functions-0.1.0-py3-none-any.whl" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "2edb5cc608d3d33c5c3b88e3994b2eb0", "sha256": "ea1431040459fe8fdffa48379ed6895213379f08da3d0722a3f645b1b08395cc" }, "downloads": -1, "filename": "restful_functions-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "2edb5cc608d3d33c5c3b88e3994b2eb0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 14242, "upload_time": "2019-04-12T02:33:45", "url": "https://files.pythonhosted.org/packages/2f/e6/9fd61298d2fd7fb0b1a74430c65a35d4f5a5619ae65ee779c2972750ccf5/restful_functions-1.0.0-py3-none-any.whl" } ], "1.0.0rc1": [ { "comment_text": "", "digests": { "md5": "20dd5634c50172b3463288191d1a626e", "sha256": "da2405ccb68103269a08a360f5867ae124f82ff7bcbf0353d2df687cd4e4f69d" }, "downloads": -1, "filename": "restful_functions-1.0.0rc1-py3-none-any.whl", "has_sig": false, "md5_digest": "20dd5634c50172b3463288191d1a626e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 14275, "upload_time": "2019-04-11T08:52:57", "url": "https://files.pythonhosted.org/packages/a9/74/51f446649e75497eb0bea7be39e9a45f9c67c8408aae57f7bbab1370a39f/restful_functions-1.0.0rc1-py3-none-any.whl" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "5d3b95657a1495fc5d139a29e4422cc3", "sha256": "071636ad0e5da45929849de62cff55f9608b6e583f6def3bf349c7786979f98c" }, "downloads": -1, "filename": "restful_functions-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "5d3b95657a1495fc5d139a29e4422cc3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 14242, "upload_time": "2019-06-28T09:06:43", "url": "https://files.pythonhosted.org/packages/3c/d7/0aab78576442a2dea268999549b84e648e97965c4b9c1aae9c5b9ec56a88/restful_functions-1.1.0-py3-none-any.whl" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "55ae41b2d1c206adb1397def17d7cf23", "sha256": "5792cdd1e6ded4f281af8be715d38ddac8903ce9efb92926e03e5751a3dff290" }, "downloads": -1, "filename": "restful_functions-2.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "55ae41b2d1c206adb1397def17d7cf23", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 14779, "upload_time": "2019-07-11T06:54:53", "url": "https://files.pythonhosted.org/packages/b2/82/752ca5986dc2bc7ba604ea35327feef62a1ccf4f0a71f9529389f44c9295/restful_functions-2.0.0-py3-none-any.whl" } ], "2.0.0.post1": [ { "comment_text": "", "digests": { "md5": "f357856e0195dfcc73432061dee3f1c7", "sha256": "7e580c6c6f3ca89368323b1b8b13ac974905223844da8a2a2ebfad59d168c43a" }, "downloads": -1, "filename": "restful_functions-2.0.0.post1-py3-none-any.whl", "has_sig": false, "md5_digest": "f357856e0195dfcc73432061dee3f1c7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 14841, "upload_time": "2019-07-13T08:31:47", "url": "https://files.pythonhosted.org/packages/ea/54/5c10efd9966cefec972dbd92706098aef46cbc36b83dc28addd88fd5105d/restful_functions-2.0.0.post1-py3-none-any.whl" } ], "2.0.0b1": [ { "comment_text": "", "digests": { "md5": "4fe6770bd4782b75ff5ce555b3545d2c", "sha256": "418bde410b189ff05227923b72a46ba8c0acdb0d14ab04307248aa813dce3d20" }, "downloads": -1, "filename": "restful_functions-2.0.0b1-py3-none-any.whl", "has_sig": false, "md5_digest": "4fe6770bd4782b75ff5ce555b3545d2c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 14680, "upload_time": "2019-07-10T15:42:50", "url": "https://files.pythonhosted.org/packages/d6/c8/dd850330abf83891208203e78403033fae1705f41486058a9f6fbc17b018/restful_functions-2.0.0b1-py3-none-any.whl" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "c34d17faa1b739220275e3a817139805", "sha256": "a55c37ffbf4d6b447ceb8dca3e086437e0031692ca66a42b9c69f300c0f736c1" }, "downloads": -1, "filename": "restful_functions-2.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c34d17faa1b739220275e3a817139805", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 14845, "upload_time": "2019-07-13T08:59:05", "url": "https://files.pythonhosted.org/packages/c0/0c/271103356d91ad8da708691f468cff2b3293956a0f9adb7fe9252565ba7a/restful_functions-2.0.1-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c34d17faa1b739220275e3a817139805", "sha256": "a55c37ffbf4d6b447ceb8dca3e086437e0031692ca66a42b9c69f300c0f736c1" }, "downloads": -1, "filename": "restful_functions-2.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c34d17faa1b739220275e3a817139805", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 14845, "upload_time": "2019-07-13T08:59:05", "url": "https://files.pythonhosted.org/packages/c0/0c/271103356d91ad8da708691f468cff2b3293956a0f9adb7fe9252565ba7a/restful_functions-2.0.1-py3-none-any.whl" } ] }