{ "info": { "author": "Martina Kollarova", "author_email": "mkollaro@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# TaskRunner\n\nExecute a certain sequence of tasks and later their cleanups. It is useful for\nrunning tasks with many varying configurations. It doesn't have any\ndependencies, just the standard library.\n\n```python\n# file examples/simple.py\nimport taskrunner\nclass ExampleTask(taskrunner.Task):\n def __init__(self, msg, clean_msg, **kwargs):\n super(ExampleTask, self).__init__(**kwargs)\n self.msg = msg\n self.clean_msg = clean_msg\n\n def run(self, context):\n print self.msg\n\n def cleanup(self, context):\n print self.clean_msg\n\n\ntask1 = {'task': ExampleTask,\n 'name': 'task1',\n 'msg': 'hello world',\n 'clean_msg': 'goodbye'}\ntask2 = {'task': ExampleTask,\n 'name': 'task2',\n 'msg': 'hello again',\n 'clean_msg': ':)'}\n\npipeline = [task1, task2]\n```\n\n```\n$ bin/taskrunner -f examples/simple.py pipeline\n2013-12-02 19:46:37,952 - taskrunner - INFO - =========== run task1 ===========\nhello world\n2013-12-02 19:46:37,953 - taskrunner - INFO - =========== run task2 ===========\nhello again\n2013-12-02 19:46:37,953 - taskrunner - INFO - --------- cleanup task2 ---------\n:)\n2013-12-02 19:46:37,953 - taskrunner - INFO - --------- cleanup task1 ---------\ngoodbye\n```\n\n### How it works\n\nThe pipeline is a list of task configurations, which are normal Python\ndictionaries with the special item `'task':ExampleTask`. It goes trough the\nlist and for each task, it instantiates `ExampleTask` with the rest of the\ndictionary content as parameters. Then it executes `ExampleTask.run()` for all\nof the tasks. After it passes trough the whole list, it goes trough it in\nreverse order and executes `ExampleTask.cleanup()` for each item. The tasks can\nwrite into `context` and the content of it will be passed to the next task.\n\n### Usage\n\nYou can specify the pipeline directly as arguments:\n\n $ bin/taskrunner -f examples/simple.py task1 task2\n\nOr you can combine multiple pipelines, which will run all the tasks from each\npipeline:\n\n $ bin/taskrunner -f examples/simple.py pipeline another_task_pipeline\n\nOr even combine pipelines and tasks (this will run *task2* twice):\n\n $ bin/taskrunner -f examples/simple.py pipeline task2\n\nTo use the tool as a library, you can directly use `execute`:\n\n```python\ntaskrunner.execute([task1, task2])\n```\n\n#### Taking control of the cleanup execution\n\nSometimes you want to only execute the `run()` part of the tasks, debug\nsomething and only run the cleanups after you are done. To skip the cleanups,\nyou can do:\n\n $ bin/taskrunner -f examples/simple.py pipeline --cleanup=never\n\nTo run the cleanups only:\n\n $ bin/taskrunner -f examples/simple.py pipeline --cleanup=pronto\n\nYou can also use the options `--cleanup=on_success` or `--cleanup=on_failure`,\nwhich will get executed based on how the `run` turned out.\n\nDon't forget to make the cleanups independent of the runs, otherwise this won't\nwork.\n\n#### Exception and signal handling\n\nWhen an exception occurs in the task run, its traceback is logged and it jumps\nright into the cleanups. However, it doesn't clean up the tasks that didn't run\n(but it does clean up the task which failed and got only partially executed).\n\nIf you get an exception during some cleanup, the traceback is logged but\nexecution continues with the next task's cleanup.\n\nThe list of errors gets logged again after everything else finishes, in the\norder they happened.\n\nIf you terminate the run using `ctrl-c` (also known as *SIGINT*), it will go\nstraight to the cleanups. Sending the termination signal again will stop it\ncompletely. This works for the *SIGTERM* signal too.\n\n#### The name of a task\n\nBy default, the name of a task is the class name. To have more readable logs,\nyou can specify the keyword `name` in the task configuration. The task names\ncan be important for configuration redefinition from the command line.\n\n#### Redefining the task configuration trough CLI arguments\n\nSometimes you want to run a sequence of tasks with some changes in their\nconfiguration, but don't want to change the files. You can redefine it using\nthe parameter `-D`.\n\n $ bin/taskrunner -f examples/simple.py pipeline -D task1.msg=ping\n\nIt can't contain any spaces, has to be in the exact format of\n`taskname.key1.key2.key3...=newvalue`, where `taskname` is either the name of\nthe task specified in the configuration dictionary or the class name. If more\ntasks have the same name, it will get rewritten for all of them. For example,\n\n $ bin/taskrunner -f examples/simple.py pipeline -D ExampleTask.msg=ping\n\nwill change the message for both `task1` and `task2`, because they have the\nsame class name.\n\n#### Using multiple files for the task configurations\n\nYou probably don't want to have everything in a single file. You can load\nmultiple modules and reference the tasks normally.\n\n $ bin/taskrunner -f examples/advanced.py -f examples/simple.py \\\n mytask task1 task2\n\nIn case you have any name conflicts, you can specify the name of the module.\n\n $ bin/taskrunner -f examples/advanced.py -f examples/simple.py \\\n advanced.pipeline\n\n### Best practices for writing tasks and their configurations\n* don't make the `cleanup` method dependent on `run`, because with the\n option `--cleanup=pronto`, the `run` method won't get executed\n* don't assume that the `run` got executed completely\n* put the tasks into a separate file, which will be imported in the file with\n the task configurations\n* use the minimum of Python features in the task configuration files (which are\n just `.py` files), variable definitions and if conditions are usually\n sufficient. You will be later able to switch to some other configuration\n format.\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/taskrunner/", "keywords": null, "license": "Apache License, Version 2.0", "maintainer": null, "maintainer_email": null, "name": "taskrunner", "package_url": "https://pypi.org/project/taskrunner/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/taskrunner/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/taskrunner/" }, "release_url": "https://pypi.org/project/taskrunner/0.3.0/", "requires_dist": null, "requires_python": null, "summary": "Execute a certain sequence of tasks and later their cleanups in reverse order.", "version": "0.3.0" }, "last_serial": 2979421, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "d191318605e7e458a6a96c0db9e98e3f", "sha256": "90e59ba5e25b8af3fb1455f9deca0a616ffbfcec5de4bdaa021f61a07010d1ac" }, "downloads": -1, "filename": "taskrunner-0.1.tar.gz", "has_sig": false, "md5_digest": "d191318605e7e458a6a96c0db9e98e3f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11860, "upload_time": "2013-12-03T15:57:09", "url": "https://files.pythonhosted.org/packages/05/62/231e6e93222cec10f9ea6f46027ebb85bc2d4de50905f7c741ffc7dcb0a4/taskrunner-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "f2e6bfa1f156826b5868588a3063e983", "sha256": "d99595a1beca32f4869f104db0d0c7207b93be817de96de8bb9275e032cbb660" }, "downloads": -1, "filename": "taskrunner-0.1.1.tar.gz", "has_sig": false, "md5_digest": "f2e6bfa1f156826b5868588a3063e983", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11950, "upload_time": "2013-12-03T16:10:23", "url": "https://files.pythonhosted.org/packages/bb/48/b96fb07f51eed59603e9b501e25956a007a5800a9adc5609eb81bda141a7/taskrunner-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "1684af3e8d9ca7d56f8f6e80086b2187", "sha256": "4e36d854421edfa90c4ae80233fcebd3750540c7aa0f23ae79c1a0b99bbc9e60" }, "downloads": -1, "filename": "taskrunner-0.1.2.tar.gz", "has_sig": false, "md5_digest": "1684af3e8d9ca7d56f8f6e80086b2187", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14609, "upload_time": "2013-12-03T16:14:14", "url": "https://files.pythonhosted.org/packages/98/4b/656e06b90bfb0fe1fc8ef3060da95da671c28d3bf8e3b9a4b629025375a7/taskrunner-0.1.2.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "8d9d10514a038ddb0c85cbdf0a0a5967", "sha256": "0bd8007ff0b31c0763903784148c9fce4bc7c833b5d525f3e16d8f00c0954313" }, "downloads": -1, "filename": "taskrunner-0.2.tar.gz", "has_sig": false, "md5_digest": "8d9d10514a038ddb0c85cbdf0a0a5967", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13091, "upload_time": "2014-04-02T15:36:10", "url": "https://files.pythonhosted.org/packages/87/9c/3fcc71679e76348c51bc2450ba687d0ddfa56de8a76053d5eea472986ef4/taskrunner-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "041bb78d2707f3089dbef8e557126f62", "sha256": "7341b7a95d1194d1efe44867d3d66f763dade73b3dae31e60169c40eb8e9b126" }, "downloads": -1, "filename": "taskrunner-0.2.1.tar.gz", "has_sig": false, "md5_digest": "041bb78d2707f3089dbef8e557126f62", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13116, "upload_time": "2014-05-27T14:33:04", "url": "https://files.pythonhosted.org/packages/ba/e8/c0c52fafadfa974572e3e4ca9dc0696a8df077860c914e774d38bc466d3c/taskrunner-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "31982e4638a904356347ffca3ec4e5ff", "sha256": "1994ca37d2497ba3fc3da31fe35403bae28894530f4cae3ac1f929c49c54efaa" }, "downloads": -1, "filename": "taskrunner-0.3.0.tar.gz", "has_sig": false, "md5_digest": "31982e4638a904356347ffca3ec4e5ff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13165, "upload_time": "2017-06-26T12:54:09", "url": "https://files.pythonhosted.org/packages/fa/0a/e9f1a689819f5377d4348941e263c98f25b1b9693b7f904b5b5afbef7f1a/taskrunner-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "31982e4638a904356347ffca3ec4e5ff", "sha256": "1994ca37d2497ba3fc3da31fe35403bae28894530f4cae3ac1f929c49c54efaa" }, "downloads": -1, "filename": "taskrunner-0.3.0.tar.gz", "has_sig": false, "md5_digest": "31982e4638a904356347ffca3ec4e5ff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13165, "upload_time": "2017-06-26T12:54:09", "url": "https://files.pythonhosted.org/packages/fa/0a/e9f1a689819f5377d4348941e263c98f25b1b9693b7f904b5b5afbef7f1a/taskrunner-0.3.0.tar.gz" } ] }