def merge(self, other, deep_copy=False): """Merges the current task detail with the given one. NOTE(harlowja): This merge does **not** copy and replace the ``results`` or ``revert_results`` if it differs. Instead the current objects ``results`` and ``revert_results`` attributes directly becomes (via assignment) the other objects attributes. Also note that if the provided object is this object itself then **no** merging is done. See: https://bugs.launchpad.net/taskflow/+bug/1452978 for what happens if this is copied at a deeper level (for example by using ``copy.deepcopy`` or by using ``copy.copy``). :returns: this task detail (freshly merged with the incoming object) :rtype: :py:class:`.TaskDetail` """ if not isinstance(other, TaskDetail): raise exc.NotImplementedError("Can only merge with other" " task details") if other is self: return self super(TaskDetail, self).merge(other, deep_copy=deep_copy) self.results = other.results self.revert_results = other.revert_results return self
def register_entity(self, entity): entity_type = entity.kind if entity_type == c_base.Conductor.ENTITY_KIND: entity_path = k_paths.join(self.entity_path, entity_type) try: self._client.ensure_path(entity_path) self._client.create(k_paths.join(entity_path, entity.name), value=misc.binary_encode( jsonutils.dumps(entity.to_dict())), ephemeral=True) except k_exceptions.NodeExistsError: pass except self._client.handler.timeout_exception: excp.raise_with_cause( excp.JobFailure, "Can not register entity %s under %s, operation" " timed out" % (entity.name, entity_path)) except k_exceptions.SessionExpiredError: excp.raise_with_cause( excp.JobFailure, "Can not register entity %s under %s, session" " expired" % (entity.name, entity_path)) except k_exceptions.KazooException: excp.raise_with_cause( excp.JobFailure, "Can not register entity %s under %s, internal" " error" % (entity.name, entity_path)) else: raise excp.NotImplementedError( "Not implemented for other entity type '%s'" % entity_type)
def merge(self, other, deep_copy=False): if not isinstance(other, TaskDetail): raise exc.NotImplementedError("Can only merge with other" " task details") if other is self: return self super(TaskDetail, self).merge(other, deep_copy=deep_copy) copy_fn = _copy_function(deep_copy) if self.results != other.results: self.results = copy_fn(other.results) return self
def register_entity(self, entity): entity_type = entity.kind if entity_type == 'conductor': entity_path = k_paths.join(self.entity_path, entity_type) self._client.ensure_path(entity_path) conductor_name = entity.name self._client.create(k_paths.join(entity_path, conductor_name), value=misc.binary_encode( jsonutils.dumps(entity.to_dict())), ephemeral=True) else: raise excp.NotImplementedError( "Not implemented for other entity type '%s'" % entity_type)
def merge(self, other, deep_copy=False): """Merges the current retry detail with the given one. NOTE(harlowja): This merge does **not** deep copy the incoming objects ``results`` attribute (if it differs). Instead the incoming objects ``results`` attribute list is **always** iterated over and a new list is constructed with each ``(data, failures)`` element in that list having its ``failures`` (a dictionary of each named :py:class:`~taskflow.types.failure.Failure` objects that occurred) copied but its ``data`` is left untouched. After this is done that new list becomes (via assignment) this objects ``results`` attribute. Also note that if the provided object is this object itself then **no** merging is done. See: https://bugs.launchpad.net/taskflow/+bug/1452978 for what happens if the ``data`` in ``results`` is copied at a deeper level (for example by using ``copy.deepcopy`` or by using ``copy.copy``). :returns: this retry detail (freshly merged with the incoming object) :rtype: :py:class:`.RetryDetail` """ if not isinstance(other, RetryDetail): raise exc.NotImplementedError("Can only merge with other" " retry details") if other is self: return self super(RetryDetail, self).merge(other, deep_copy=deep_copy) results = [] # NOTE(imelnikov): we can't just deep copy Failures, as they # contain tracebacks, which are not copyable. for (data, failures) in other.results: copied_failures = {} for (key, failure) in six.iteritems(failures): if deep_copy: copied_failures[key] = failure.copy() else: copied_failures[key] = failure results.append((data, copied_failures)) self.results = results return self
def merge(self, other, deep_copy=False): if not isinstance(other, RetryDetail): raise exc.NotImplementedError("Can only merge with other" " retry details") if other is self: return self super(RetryDetail, self).merge(other, deep_copy=deep_copy) results = [] # NOTE(imelnikov): we can't just deep copy Failures, as they # contain tracebacks, which are not copyable. for (data, failures) in other.results: copied_failures = {} for (key, failure) in six.iteritems(failures): if deep_copy: copied_failures[key] = failure.copy() else: copied_failures[key] = failure results.append((data, copied_failures)) self.results = results return self
def _executor_factory(self): """Creates an executor to be used during dispatching.""" raise excp.NotImplementedError("This method must be implemented but" " it has not been")
def _make_engine(self, flow, **kwargs): raise exceptions.NotImplementedError("_make_engine() must be" " overridden if an engine is" " desired")