Dan 35fd8ffc0f Squashed 'SpiffWorkflow/' changes from 11e4b4f96..b439f69f2
b439f69f2 Merge pull request #296 from sartography/bugfix/subprocess-access-to-data-objects
6d2a2031e update spiff subworkflow tasks too
992c38671 make data objects referenceable within subprocesses
6c8ff5cdf allow subprocesses & call activities to have different data copy policies
2b14f3a48 initialize subprocesses in _update_hook instead of _on_ready_before
791f335d5 Merge pull request #295 from sartography/improvement/remove-camunda-from-base-and-misc-cleanup
28b579beb remove a few unused, duplicative, and debugging methods
8f14d1098 remove some other unused diagrams and tests
408bc6734 rely on top level camunda parser for almost all namespace references
895b2cc9b remove camunda namespace from base bpmn parser
76ecbf7cc Merge pull request #294 from sartography/bugfix/reactivate-boundary-event
82b6c8ad4 hack to ensure timers (and other events) are reset if returned to via loop reset
590903f47 Merge pull request #292 from sartography/feature/multiinstance-refactor
537490043 fix bug & typo
f31726db1 raise error on attempting to migrate workflows with MI
44e6d08d8 create spiff multiinstance task
2168c022b create camunda MI that approximates what it used to do
9894cea59 some improvements and bugfixes
f857ad5d4 remove some now unused functionality & tests, create a few more tests
6fead9d04 updated serializer & fixes for most tests
ec662ecdd add parallel multiinstance
bd19b2a8a working sequential multiinstance
2f9c192b6 further cleanup around _update_hook
947792bf6 fix bug in exclusive gateway migration
d3d87b28d add io spec to all tasks
f1586e275 add support for standard loop tasks

git-subtree-dir: SpiffWorkflow
git-subtree-split: b439f69f23b547df4de1e8e0c636997f2fd4e33b
2023-02-18 10:32:56 -05:00

74 lines
2.6 KiB
Python

# -*- coding: utf-8 -*-
# Copyright (C) 2007 Samuel Abels
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import logging
from .base import TaskSpec
logger = logging.getLogger('spiff')
class Transform(TaskSpec):
"""
This class implements a task that transforms input/output data.
"""
def __init__(self, wf_spec, name, transforms=None, **kwargs):
"""
Constructor.
:type wf_spec: WorkflowSpec
:param wf_spec: A reference to the workflow specification.
:type name: str
:param name: The name of the task spec.
:type transforms: list
:param transforms: The commands that this task will execute to
transform data. The commands will be executed using the
python 'exec' function. Accessing inputs and outputs is
achieved by referencing the my_task.* and self.*
variables'
:type kwargs: dict
:param kwargs: See :class:`SpiffWorkflow.specs.TaskSpec`.
"""
assert wf_spec is not None
assert name is not None
TaskSpec.__init__(self, wf_spec, name, **kwargs)
self.transforms = transforms
def _update_hook(self, my_task):
super()._update_hook(my_task)
if self.transforms:
for transform in self.transforms:
logger.debug(f'Execute transform', extra=my_task.log_info({'transform': transform}))
exec(transform)
return True
def serialize(self, serializer):
s_state = serializer.serialize_simple(self)
s_state['transforms'] = self.transforms
return s_state
@classmethod
def deserialize(cls, serializer, wf_spec, s_state):
spec = Transform(wf_spec, s_state['name'])
serializer.deserialize_task_spec(wf_spec, s_state, spec=spec)
spec.transforms = s_state['transforms']
return spec