Remove uuid from taskflow.flow.Flow

In a way our resumption works it may not correspond uuid from flow
details, and so it is hardly useful.

Change-Id: I090d017e2f0f8475594af94a2430a34e6ed1ce70
This commit is contained in:
Ivan A. Melnikov 2013-10-14 13:06:04 +04:00
parent ec620ef8a2
commit 568843f8ad
6 changed files with 20 additions and 35 deletions

View File

@ -17,19 +17,20 @@
# under the License.
import abc
import six
from taskflow.openstack.common import uuidutils
from taskflow.utils import reflection
class Flow(six.with_metaclass(abc.ABCMeta)):
"""The base abstract class of all flow implementations.
It provides a name and an identifier (uuid) to the flow so that it can be
uniquely identifed among many flows while executing or while referencing
the results (or other metadata) of this flow in storage.
A flow is a structure that defines relationships between tasks. You can
add tasks and other flows (as subflows) to the flow, and the flow provides
a way to implicitly or explicitly define how they are interdependent.
Exact structure of the relationships is defined by concrete
implementation, while this class defines common interface and adds
human-readable (not necessary unique) name.
NOTE(harlowja): if a flow is placed in another flow as a subflow, a desired
way to compose flows together, then it is valid and permissible that during
@ -39,44 +40,33 @@ class Flow(six.with_metaclass(abc.ABCMeta)):
worth mentioning here.
Flows are expected to provide the following methods/properties:
- add
- __len__
- requires
- provides
"""
def __init__(self, name, uuid=None):
def __init__(self, name):
self._name = str(name)
if uuid:
self._id = str(uuid)
else:
self._id = uuidutils.generate_uuid()
@property
def name(self):
"""A non-unique name for this flow (human readable)"""
return self._name
@property
def uuid(self):
"""A unique identifier for this flow"""
return self._id
@abc.abstractmethod
def __len__(self):
"""Returns how many items are in this flow."""
raise NotImplementedError()
def __str__(self):
lines = ["%s: %s" % (reflection.get_class_name(self), self.name)]
lines.append("%s" % (self.uuid))
lines.append("%s" % (len(self)))
return "; ".join(lines)
@abc.abstractmethod
def add(self, *items):
"""Adds a given item/items to this flow."""
raise NotImplementedError()
@abc.abstractproperty
def requires(self):

View File

@ -35,8 +35,8 @@ class Flow(flow.Flow):
Note: Cyclic dependencies are not allowed.
"""
def __init__(self, name, uuid=None):
super(Flow, self).__init__(name, uuid)
def __init__(self, name):
super(Flow, self).__init__(name)
self._graph = nx.freeze(nx.DiGraph())
def _validate(self, graph=None):

View File

@ -31,8 +31,8 @@ class Flow(flow.Flow):
depend on outputs (provided names/values) of tasks/flows that follow it.
"""
def __init__(self, name, uuid=None):
super(Flow, self).__init__(name, uuid)
def __init__(self, name):
super(Flow, self).__init__(name)
self._children = []
def add(self, *items):

View File

@ -31,8 +31,8 @@ class Flow(flow.Flow):
task/flow outputs (provided names/values).
"""
def __init__(self, name, uuid=None):
super(Flow, self).__init__(name, uuid)
def __init__(self, name):
super(Flow, self).__init__(name)
# NOTE(imelnikov): A unordered flow is unordered, so we use
# set instead of list to save children, children so that
# people using it don't depend on the ordering

View File

@ -38,7 +38,7 @@ FLATTEN_EDGE_DATA = {
def _graph_name(flow):
return "F:%s:%s" % (flow.name, flow.uuid)
return "F:%s" % flow.name
def _flatten_linear(flow, flattened):

View File

@ -64,16 +64,11 @@ def create_flow_detail(flow, book=None, backend=None, meta=None):
logbook (if provided) and then uses the given backend (if provided) to
save the logbook then returns the created flow detail.
"""
try:
flow_name = getattr(flow, 'name')
except AttributeError:
LOG.warn("Flow %s does not have a name attribute, creating one.", flow)
flow_name = uuidutils.generate_uuid()
try:
flow_id = getattr(flow, 'uuid')
except AttributeError:
LOG.warn("Flow %s does not have a uuid attribute, creating one.", flow)
flow_id = uuidutils.generate_uuid()
flow_id = uuidutils.generate_uuid()
flow_name = getattr(flow, 'name', None)
if flow_name is None:
LOG.warn("No name provided for flow %s (id %s)" % (flow, flow_id))
flow_name = flow_id
flow_detail = logbook.FlowDetail(name=flow_name, uuid=flow_id)
if meta is not None: