fix serialization issue with custom service task, w/ essweine (#605)

Co-authored-by: burnettk <burnettk@users.noreply.github.com>
This commit is contained in:
Kevin Burnett 2023-11-03 15:00:30 -07:00 committed by GitHub
parent 207f9475a0
commit 6014f2940d
2 changed files with 12 additions and 2 deletions

View File

@ -7,7 +7,7 @@ def main() -> None:
app = create_app() app = create_app()
with app.app_context(): with app.app_context():
execution_strategy_name = app.config["SPIFFWORKFLOW_BACKEND_ENGINE_STEP_DEFAULT_STRATEGY_BACKGROUND"] execution_strategy_name = app.config["SPIFFWORKFLOW_BACKEND_ENGINE_STEP_DEFAULT_STRATEGY_BACKGROUND"]
process_instance = ProcessInstanceModel.query.filter_by(id=29).first() process_instance = ProcessInstanceModel.query.filter_by(id=2).first()
ProcessInstanceService.run_process_instance_with_processor( ProcessInstanceService.run_process_instance_with_processor(
process_instance, execution_strategy_name=execution_strategy_name process_instance, execution_strategy_name=execution_strategy_name
) )

View File

@ -41,6 +41,7 @@ from SpiffWorkflow.serializer.exceptions import MissingSpecError # type: ignore
from SpiffWorkflow.spiff.parser.process import SpiffBpmnParser # type: ignore from SpiffWorkflow.spiff.parser.process import SpiffBpmnParser # type: ignore
from SpiffWorkflow.spiff.serializer.config import SPIFF_CONFIG # type: ignore from SpiffWorkflow.spiff.serializer.config import SPIFF_CONFIG # type: ignore
from SpiffWorkflow.spiff.serializer.task_spec import ServiceTaskConverter # type: ignore from SpiffWorkflow.spiff.serializer.task_spec import ServiceTaskConverter # type: ignore
from SpiffWorkflow.spiff.specs.defaults import ServiceTask # type: ignore
from SpiffWorkflow.task import Task as SpiffTask # type: ignore from SpiffWorkflow.task import Task as SpiffTask # type: ignore
from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore
from SpiffWorkflow.util.task import TaskIterator # type: ignore from SpiffWorkflow.util.task import TaskIterator # type: ignore
@ -99,12 +100,21 @@ from spiffworkflow_backend.services.workflow_execution_service import execution_
from spiffworkflow_backend.specs.start_event import StartEvent from spiffworkflow_backend.specs.start_event import StartEvent
from sqlalchemy import and_ from sqlalchemy import and_
# this custom converter is just so we use 'ServiceTask' as the typename in the serialization
# rather than 'CustomServiceTask'
class CustomServiceTaskConverter(ServiceTaskConverter): # type: ignore
def __init__(self, target_class, registry, typename: str = "ServiceTask"): # type: ignore
super().__init__(target_class, registry, typename)
SPIFF_CONFIG[StartEvent] = EventConverter SPIFF_CONFIG[StartEvent] = EventConverter
SPIFF_CONFIG[JSONDataStore] = JSONDataStoreConverter SPIFF_CONFIG[JSONDataStore] = JSONDataStoreConverter
SPIFF_CONFIG[JSONFileDataStore] = JSONFileDataStoreConverter SPIFF_CONFIG[JSONFileDataStore] = JSONFileDataStoreConverter
SPIFF_CONFIG[KKVDataStore] = KKVDataStoreConverter SPIFF_CONFIG[KKVDataStore] = KKVDataStoreConverter
SPIFF_CONFIG[TypeaheadDataStore] = TypeaheadDataStoreConverter SPIFF_CONFIG[TypeaheadDataStore] = TypeaheadDataStoreConverter
SPIFF_CONFIG[CustomServiceTask] = ServiceTaskConverter SPIFF_CONFIG[CustomServiceTask] = CustomServiceTaskConverter
del SPIFF_CONFIG[ServiceTask]
# Sorry about all this crap. I wanted to move this thing to another file, but # Sorry about all this crap. I wanted to move this thing to another file, but
# importing a bunch of types causes circular imports. # importing a bunch of types causes circular imports.