{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "===============================\nScorekeeper\n===============================\n\n\n.. image:: https://img.shields.io/pypi/v/scorekeeper.svg\n :target: https://pypi.python.org/pypi/scorekeeper\n\n.. image:: https://img.shields.io/travis/dhosterman/scorekeeper.svg\n :target: https://travis-ci.org/dhosterman/scorekeeper\n\n.. image:: https://readthedocs.org/projects/scorekeeper/badge/?version=latest\n :target: https://scorekeeper.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n.. image:: https://pyup.io/repos/github/dhosterman/scorekeeper/shield.svg\n :target: https://pyup.io/repos/github/dhosterman/scorekeeper/\n :alt: Updates\n\n\nKeep score of the results of functions over time and take action based on a generated score.\n\nSometimes, you have a problem that requires you to look at a set of circumstances over time and weigh them\nbefore taking action like intermittent failures in a system or calls to external APIs that may or may not respond.\n\nFor example, maybe you have an API endpoint you're monitoring and you want to do some self-healing, but only if\nthere are at least 5 failures in 5 minutes. You don't want to have a long-running process keeping state over 5 minutes,\nso you need something that will maintain state between calls. That might look something like this:\n\n .. code-block:: python\n\n @score(ShadyAPIScorekeeper, 20, threshold=100, decay=10, callback=restart_shady_api)\n def check_shady_api():\n if shady_api_test().successful:\n return True\n else:\n return False\n \nEvery time check_shady_api() is called and returns False, the ShadyAPIScorekeeper will accumulate 20 points. Once the\nthreshold of 100 points is reached, the callback will be executed. Because you might execute this script from a cron\njob or in some other intermittent fashion, the accumulated score for ShadyAPIScorekeeper is persisted on the local file\nsystem. Finally, the (optional) decay parameter lets you set the number of seconds it takes for the accumulated score to\ntick down by 1 point.\n\nIn this example, ShadyAPIScorekeeper is just a subclass of Scorekeeper and can have its own defaults set for things like\nthreshold, decay, and callback. This allows the decorator invocation to be much leaner. In addition, all instances of \na given subclass of Scorekeeper use the same persisted score, so you could decorate multiple functions all with different\npoints based on their severity in order to generate your final score and decide whether or not to take action.\n\nIn addition to using Scorekeeper as a decorator, you can also just directly interface with the objects you've described.\nFor example:\n\n .. code-block:: python\n \n >>> score_keeper = ShadyApiScorekeeper()\n >>> score_keeper.score\n 0\n >>> score_keeper(10)\n >>> score_keeper.score\n 10\n >>> score_keeper(100)\n Shady API restarted!\n\n\n* Free software: MIT license\n* Documentation: https://scorekeeper.readthedocs.io.\n\n\nFeatures\n--------\n\n* TODO\n\nCredits\n---------\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "scorekeeper", "package_url": "https://pypi.org/project/scorekeeper/", "platform": "", "project_url": "https://pypi.org/project/scorekeeper/", "project_urls": null, "release_url": "https://pypi.org/project/scorekeeper/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "", "version": "0.1.0" }, "last_serial": 2368802, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "437c5a64103ff55e10011d3369a8e477", "sha256": "fe010fc15ffb298fd8960fd0dd095eb9e13ea0bda93eecd90e582ea2033cdd84" }, "downloads": -1, "filename": "scorekeeper-0.1.0.tar.gz", "has_sig": false, "md5_digest": "437c5a64103ff55e10011d3369a8e477", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14680, "upload_time": "2016-09-28T15:14:35", "url": "https://files.pythonhosted.org/packages/cb/27/799f928d97e388a9afa89a5311649becc0f346f9627f544ad80088f228c3/scorekeeper-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "437c5a64103ff55e10011d3369a8e477", "sha256": "fe010fc15ffb298fd8960fd0dd095eb9e13ea0bda93eecd90e582ea2033cdd84" }, "downloads": -1, "filename": "scorekeeper-0.1.0.tar.gz", "has_sig": false, "md5_digest": "437c5a64103ff55e10011d3369a8e477", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14680, "upload_time": "2016-09-28T15:14:35", "url": "https://files.pythonhosted.org/packages/cb/27/799f928d97e388a9afa89a5311649becc0f346f9627f544ad80088f228c3/scorekeeper-0.1.0.tar.gz" } ] }