summaryrefslogtreecommitdiff
path: root/taskflow/tests/unit/test_task.py
Commit message (Collapse)AuthorAgeFilesLines
* Quote string representationsMichael Johnson2022-06-101-2/+2
| | | | | | | | networkx 2.8.3 will raise errors if certain characters, such as a colon, in the node names and the string is not quoted. This patch double quotes flow, node, and task string representations to make sure there are not issues with these characters occuring in the names. Story: 2010083 Change-Id: Ib0941cddf14dde5d6b9f97fe0224d6e6f3975226
* Replace assertRaisesRegexp with assertRaisesRegexVu Cong Tuan2017-06-031-11/+11
| | | | | | | | | | assertRaisesRegexp was renamed to assertRaisesRegex in Py3.2 For more details, please check: https://docs.python.org/3/library/ unittest.html#unittest.TestCase.assertRaisesRegex Change-Id: I89cce19e80b04074aab9f49a76c7652acace78b3 Closes-Bug: #1436957
* python3.0 has deprecated LOG.warnxhzhf2017-03-071-9/+9
| | | | | | | | python3.0 has deprecated LOG.warn https://docs.python.org/3/library/logging.html#logging.warning Closes-Bug: #1650843 Change-Id: Ib8473cbdb84547f385e619fe08ed723b1ee7bcdb
* Add tests to verify kwargs behavior on revert validationGreg Hill2016-06-091-23/+41
| | | | | | | | | | | A bug was reported where a task's revert method was throwing an 'extra args' exception even though it had a **kwargs to slurp up any extra args. I added some tests to duplicate the behavior but the tests all pass. I'm hoping pushing this up will cause CI to reproduce the bug so I can diagnose it further. Change-Id: I9f4d0f065f11370f7981e93349f473df2bb1015d Closes-Bug: #1589848
* Allow for revert to have a different argument list from executeGreg Hill2016-02-261-0/+36
| | | | | | | | | Also allows for people to create Atom's with a different rebind or requires structure for the revert method, if desired. Implements blueprint: seperate-revert-args Change-Id: Ie7d13c8000ef08ff303481d486d1ba1cfbdeea44
* Fix mock callsDoug Hellmann2015-07-101-1/+1
| | | | | | Use the proper assertion methods of the mocks. Change-Id: I7b02f3b52012976a3ed0b8d5fc445653c0546547
* Added a map and a reduce taskMin Pae2015-03-121-0/+45
| | | | | | | - Added a MapFunctorTask and ReduceFunctorTask to mimic the python builtin functions map and reduce, respectively Change-Id: I29cd1249e1671aedfd2d25460d746b8d2154df2b
* Use ordered[set/dict] to retain orderingJoshua Harlow2015-03-111-59/+82
| | | | | | | | | | | | | | Instead of using always using a set/dict which do not retain use a ordered set and a ordered dict for requires, optional, and provides and rebind mappings types so that the ordering of these containers is maintained later when they are used. These ordering can be useful depending on the atom type (such as in a map and reduce tasks). Partial-Bug: 1357117 Change-Id: I365d11bbba4aa221bc36ca15441acecf199b4d56
* Map optional arguments as well as required argumentsMin Pae2015-02-101-0/+9
| | | | | | | | | Optional arguments that are not explicitly required are being ignored when arguments are being mapped based on inference from atoms' execute method signatures. This patch adds support for mapping optional arguments in addition to required arguments. Change-Id: I440c02dcd901a563df512e33754b13e3c05d4155
* Make all/most usage of type errors follow a similar patternJoshua Harlow2015-01-231-1/+1
| | | | | | | | | | | | | | | To make it easy to add new type errors and to make the existing ones have a common string pattern adjust the current type errors to contain at least the following string format: '%s' (%s) where these two places will be filled in with the object of the wrong type and the type of that object. This information is useful when analyzing the exception (by the user) to know exactly what they passed in and what type it was. This convention is not maintained where it would interpolate large text blobs (such as in binary encoding/decoding and json decoding). Change-Id: Id84b0e7ce684a543cc407b15016e77804e6f03ed
* Use the notifier type in the task class/module directlyJoshua Harlow2014-12-131-57/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of having code that is some what like the notifier code we already have, but is duplicated and is slightly different in the task class just move the code that was in the task class (and doing similar actions) to instead now use a notifier that is directly contained in the task base class for internal task triggering of internal task events. Breaking change: alters the capabilities of the task to process notifications itself, most actions now must go through the task notifier property and instead use that (update_progress still exists as a common utility method, since it's likely the most common type of notification that will be used). Removes the following methods from task base class (as they are no longer needed with a notifier attribute): - trigger (replaced with notifier.notify) - autobind (removed, not replaced, can be created by the user of taskflow in a simple manner, without requiring functionality in taskflow) - bind (replaced with notifier.register) - unbind (replaced with notifier.unregister) - listeners_iter (replaced with notifier.listeners_iter) Due to this change we can now also correctly proxy back events from remote tasks to the engine for correct proxying back to the original task. Fixes bug 1370766 Change-Id: Ic9dfef516d72e6e32e71dda30a1cb3522c9e0be6
* Have tasks be able to provide copy() methodsJoshua Harlow2014-12-061-0/+23
| | | | | | | | | | | | | | | When a engine needs to copy a task and possibly adjust its listeners to execute it elsewhere it needs to be able to clone that object and have the clone retain different properties than the initial object; so in order to support this at a top-level we require a new copy() method which a task can override (or it can just use the default implementation if it chooses to). Part of blueprint process-executor Change-Id: Ib29a0afdc01973eb94d41af18a9b04601cd2f152
* Rework pieces of the task callback capabilityJoshua Harlow2014-12-061-41/+31
| | | | | | | | | | | | | | | | | | | Unifies the bind, unbind, autobind parameters. Also to make it easier to introspect what are a tasks associated callbacks and events are provide a listeners_iter() method that can be used to introspect the registered (event, callbacks) pairs that are registered with a task. Also adds more useful docstrings to the various callback associated binding, unbinding functions to make it more understandable how they are used and what they are provided. Also makes the currently only default provided event 'update_progress' a constant that can be referenced from the task module, which allows others to easily find it and use it. Change-Id: I14181a150b74fbd97f6ea976723f37c0ba4cec36
* Raise value errors instead of assertsJoshua Harlow2014-12-021-0/+11
| | | | | | | | Since asserts can be silenced using -0 and/or compiled out we want to be more strict here and raise value errors when the expected callable objects/functions are not actually callable. Change-Id: Ib14e2e7329dbfcce50660f144ad4780d99f36854
* Use oslotest to provide our base test case classJoshua Harlow2014-09-271-2/+1
| | | | | | | | | | | | | | | | The oslotest library has a nice openstack testing integrated base class that can ensure we setup our base test case using the right logging fixtures, test timeouts, and output fixtures that better operate in the openstack ecosystem. This will also allow us to remove some of the functionality that we currently have in our base test case and replace it with the equivalent (or better) functionality that oslotest now provides. Part of blueprint use-oslo-test Change-Id: I1602d5180ec8649a1899185972750ddddf65990f
* Rename to atom from taskJoshua Harlow2014-05-311-1/+1
| | | | | | | | | | The variables, exception messages and other variable namings in the atom file should reflect atoms, not tasks (which is a leftover change from when these were in a different file). Change-Id: Ie7870c8240409f7c53d4f2806eafa912bcc620b9
* Add __repr__ method to AtomIvan A. Melnikov2014-03-241-0/+8
| | | | | | | Having atom name in its representation helps a lot when debugging. Change-Id: I8cb7054b95a8810a7fe3893ba579e9f9e9facd8e
* Adjust logging levels and usage to follow standardsJoshua Harlow2014-03-141-8/+8
| | | | | | | | | | A few of our logging levels and messages should be updated to better reflect the oslo logging standards created at https://wiki.openstack.org/LoggingStandards so update some of them to not report error when its really warning level and not report warning when debug is better. Change-Id: I8abdb1bcfa2893c6b97eda7e85ac779e456966b8
* Remove extraneous vim configuration commentsyangxurong2014-02-141-2/+0
| | | | | | | | | Remove line containing comment - # vim: tabstop=4 shiftwidth=4 softtabstop=4 Change-Id: I7581cc88b8de433d5609ed06c6570b0b45c13573 Closes-Bug:#1229324
* Added more unit tests for Task and FunctorTaskskudriashev2014-01-271-1/+105
| | | | | | | * More tests were added for task.Task and task.FunctorTask to enhance code coverage. Change-Id: Idacf0ee3fcb84d71cdb57d4f6d986f7e983597f0
* Fix up python 3.3 incompatabilitiesJoshua Harlow2013-11-211-10/+11
| | | | | | | | | | | | Make the python 3.3 testing work by selectively disabling & including eventlet, switch to testtools and testrepository which has 2.6, 2.7, 3.2+ unified testing support so that we can correctly run our tests in all supported python versions. Closes-Bug: #1251660 Co-authored-by: Alexander Gorodnev <agorodnev@griddynamics.com> Change-Id: I23b6f04387cfd3bf6b5a044edffa446ca897ce3a
* Update code to comply with hacking 0.8.0Ivan A. Melnikov2013-11-081-22/+22
| | | | | | | Replace assertEquals and assertNotEquals with assertEqual and assertNotEqual (new rule, H234), and fix indentation. Change-Id: I86177325dee3aa00af5df8b3085acd478994ee34
* Support for optional task argumentsIvan A. Melnikov2013-10-221-0/+13
| | | | | | | | | We used to ignore optional task arguments (arguments of 'execute' method with default value). With this change flow author can pass such arguments to task by mentioning them in 'requires' and/or 'rebind' task constructor parameters. Change-Id: Ib92f87eb05623d30db6f1691d75c11376d45c87a
* Allow to specify default provides at task definitionIvan A. Melnikov2013-09-191-0/+17
| | | | | | | | | It is now possible to specify what task provides when task class (deriving from taskflow.task.Task) is defined, using 'default_provides' class attribute or property. This specification may still be overridden when task instance is created via 'provides' constructor parameter. Change-Id: If300c3a35807422d06c0196e84891faebde83c02
* Add provides and requires properties to FlowAnastasia Karpinska2013-09-111-13/+13
| | | | | | | | | | | Provides and requires properties are used to browse all required and provided values for the whole Flow. The same properties were added to the Task. Appropriate Task properties were renamed to rebind and save_as. Change-Id: I02eb02303a9701a13f1a54f06f20bbf9aebd1d04
* Engine, task, linear_flow unificationJoshua Harlow2013-09-051-5/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to move away from the existing flows having their own implementation of running, start moving the existing flows to be patterns that only structure tasks (and impose constraints about how the group of tasks can run) in useful ways. Let the concept of running those patterns be handled by an engine instead of being handled by the flow itself. This will allow for varying engines to be able to run flows in whichever way the engine chooses (as long as the constraints set up by the flow are observed). Currently threaded flow and graph flow are broken by this commit, since they have not been converted to being a structure of tasks + constraints. The existing engine has not yet been modified to run those structures either, work is underway to remediate this. Part of: blueprint patterns-and-engines Followup bugs that must be addressed: Bug: 1221448 Bug: 1221505 Change-Id: I3a8b96179f336d1defe269728ebae0caa3d832d7
* Rename Task.__call__ to Task.executeIvan A. Melnikov2013-09-031-1/+1
| | | | | | | | | We'd like library interface to be nice and simple, which implies that it does not involve too many underscores. Also 'execute' matches with 'revert' nicely. Suggested-by: Anastasia Karpinska <akarpinska@griddynamics.com> Change-Id: Iea72e6230a32665b4236a1e7d1dcc41bd56d0418
* Add features to task.TaskIvan A. Melnikov2013-08-271-0/+46
Old Task class renamed to BaseTask, and new Task class deriving from it added in place of it. This new class adds following features: - if no name is passed to task, name is autogenerated from task type - all __call__ argument names (except 'context') are added to task requirements. Change-Id: Ied69857932088b6e25d4817d2a8afeddccad36d8