From 101a47fe92389982b0fc5ff7d4f46880fbe75bff Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Fri, 13 Feb 2015 12:58:03 -0800 Subject: [PATCH] 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 --- taskflow/atom.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/taskflow/atom.py b/taskflow/atom.py index 3ece83fc..1c5e61ef 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)."""