diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2015-02-13 12:58:03 -0800 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2015-02-13 21:03:19 +0000 |
commit | 101a47fe92389982b0fc5ff7d4f46880fbe75bff (patch) | |
tree | 9c1838b443cfed91fd36069f5fc5f2ded713b650 | |
parent | 72a9c00625606341fc89b66736a53d67760a88b9 (diff) | |
download | taskflow-101a47fe92389982b0fc5ff7d4f46880fbe75bff.tar.gz |
Make the atom class an abstract class
To enforce the already existing behavior that atoms
have execute and revert methods (this is already the
de-facto behavior with its subclasses) we might as
well have the atom class be abstract and have methods
execute() and revert() that need to be implemented
in subclasses (which they already are).
Change-Id: Idfc25a7c2b01f674a065e3f467607eba4ab89a26
-rw-r--r-- | taskflow/atom.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/taskflow/atom.py b/taskflow/atom.py index 3ece83f..1c5e61e 100644 --- a/taskflow/atom.py +++ b/taskflow/atom.py @@ -15,6 +15,8 @@ # License for the specific language governing permissions and limitations # under the License. +import abc + from oslo_utils import reflection import six @@ -128,6 +130,7 @@ def _build_arg_mapping(atom_name, reqs, rebind_args, function, do_infer, return required, optional +@six.add_metaclass(abc.ABCMeta) class Atom(object): """An abstract flow atom that causes a flow to progress (in some manner). @@ -205,6 +208,14 @@ class Atom(object): "by this atom" % dict(item=self.name, oo=sorted(out_of_order))) + @abc.abstractmethod + def execute(self, *args, **kwargs): + """Executes this atom.""" + + @abc.abstractmethod + def revert(self, *args, **kwargs): + """Reverts this atom (undoing any :meth:`execute` side-effects).""" + @property def name(self): """A non-unique name for this atom (human readable).""" |