some cleanup and refactoring w/ burnettk

This commit is contained in:
jasquat 2022-09-27 15:10:32 -04:00
parent 556c9f1353
commit d162f0d246
7 changed files with 104 additions and 93 deletions

10
poetry.lock generated
View File

@ -1853,7 +1853,7 @@ description = "A workflow framework and BPMN/DMN Processor"
category = "main" category = "main"
optional = false optional = false
python-versions = "*" python-versions = "*"
develop = false develop = true
[package.dependencies] [package.dependencies]
celery = "*" celery = "*"
@ -1863,10 +1863,8 @@ lxml = "*"
pytz = "*" pytz = "*"
[package.source] [package.source]
type = "git" type = "directory"
url = "https://github.com/sartography/SpiffWorkflow" url = "../SpiffWorkflow"
reference = "main"
resolved_reference = "dec9b4b942378d030ae73f1365dfbf108e6f7f8c"
[[package]] [[package]]
name = "sqlalchemy" name = "sqlalchemy"
@ -2176,7 +2174,7 @@ testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>=
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.9" python-versions = "^3.9"
content-hash = "7a3c07a2eef00685adbf44b6e26b740e20fc52bf85e916b6c171b13d4fcc6dc9" content-hash = "645cb811651af21330bcd61e27d293ff280f5fd68997b4f42e3237289ef14212"
[metadata.files] [metadata.files]
alabaster = [ alabaster = [

View File

@ -27,9 +27,9 @@ flask-marshmallow = "*"
flask-migrate = "*" flask-migrate = "*"
flask-restful = "*" flask-restful = "*"
werkzeug = "*" werkzeug = "*"
SpiffWorkflow = {git = "https://github.com/sartography/SpiffWorkflow", rev = "main"} # SpiffWorkflow = {git = "https://github.com/sartography/SpiffWorkflow", rev = "main"}
# SpiffWorkflow = {git = "https://github.com/sartography/SpiffWorkflow", rev = "feature/dependencies"} # SpiffWorkflow = {git = "https://github.com/sartography/SpiffWorkflow", rev = "feature/dependencies"}
# SpiffWorkflow = {develop = true, path = "/home/jason/projects/github/sartography/SpiffWorkflow"} SpiffWorkflow = {develop = true, path = "/home/jason/projects/github/sartography/SpiffWorkflow"}
sentry-sdk = "1.9.0" sentry-sdk = "1.9.0"
sphinx-autoapi = "^1.8.4" sphinx-autoapi = "^1.8.4"
# flask-bpmn = {develop = true, path = "/home/jason/projects/github/sartography/flask-bpmn"} # flask-bpmn = {develop = true, path = "/home/jason/projects/github/sartography/flask-bpmn"}

View File

@ -171,7 +171,7 @@ paths:
schema: schema:
type: array type: array
items: items:
$ref: "#/components/schemas/WorkflowSpecCategory" $ref: "#/components/schemas/ProcessModelCategory"
# process_group_add # process_group_add
post: post:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_group_add operationId: spiffworkflow_backend.routes.process_api_blueprint.process_group_add
@ -182,14 +182,14 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/WorkflowSpecCategory" $ref: "#/components/schemas/ProcessModelCategory"
responses: responses:
"201": "201":
description: Processs Group description: Processs Group
content: content:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/WorkflowSpecCategory" $ref: "#/components/schemas/ProcessModelCategory"
/process-groups/{process_group_id}: /process-groups/{process_group_id}:
parameters: parameters:
@ -211,7 +211,7 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/WorkflowSpecCategory" $ref: "#/components/schemas/ProcessModelCategory"
delete: delete:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_group_delete operationId: spiffworkflow_backend.routes.process_api_blueprint.process_group_delete
summary: Deletes a single process group summary: Deletes a single process group
@ -229,14 +229,14 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/WorkflowSpecCategory" $ref: "#/components/schemas/ProcessModelCategory"
responses: responses:
"200": "200":
description: Process group updated successfully description: Process group updated successfully
content: content:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/WorkflowSpecCategory" $ref: "#/components/schemas/ProcessModelCategory"
/process-models: /process-models:
parameters: parameters:
@ -272,25 +272,25 @@ paths:
schema: schema:
type: array type: array
items: items:
$ref: "#/components/schemas/WorkflowSpec" $ref: "#/components/schemas/ProcessModel"
# process_model_add # process_model_add
post: post:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_add operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_add
summary: Creates a new workflow specification with the given parameters. summary: Creates a new process model with the given parameters.
tags: tags:
- Process Models - Process Models
requestBody: requestBody:
content: content:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/WorkflowSpec" $ref: "#/components/schemas/ProcessModel"
responses: responses:
"201": "201":
description: Workflow specification created successfully. description: Process model created successfully.
content: content:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/WorkflowSpec" $ref: "#/components/schemas/ProcessModel"
/process-models/{process_group_id}/{process_model_id}/files: /process-models/{process_group_id}/{process_model_id}/files:
parameters: parameters:
@ -303,7 +303,7 @@ paths:
- name: process_model_id - name: process_model_id
in: path in: path
required: true required: true
description: The unique id of an existing workflow specification to validate. description: The unique id of an existing process model to validate.
schema: schema:
type: string type: string
# add_file # add_file
@ -369,7 +369,7 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/WorkflowSpec" $ref: "#/components/schemas/ProcessModel"
# process_model_delete # process_model_delete
delete: delete:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_delete operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_delete
@ -393,14 +393,14 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/WorkflowSpec" $ref: "#/components/schemas/ProcessModel"
responses: responses:
"200": "200":
description: Process model updated successfully. description: Process model updated successfully.
content: content:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/WorkflowSpec" $ref: "#/components/schemas/ProcessModel"
/process-instances: /process-instances:
parameters: parameters:
@ -413,7 +413,7 @@ paths:
- name: process_model_identifier - name: process_model_identifier
in: query in: query
required: false required: false
description: The unique id of an existing workflow specification. description: The unique id of an existing process model.
schema: schema:
type: string type: string
- name: page - name: page
@ -473,6 +473,34 @@ paths:
type: array type: array
items: items:
$ref: "#/components/schemas/Workflow" $ref: "#/components/schemas/Workflow"
# /process-models/{process_group_id}/{process_model_id}/script-unit-tests/run:
# parameters:
# - name: process_group_id
# in: path
# required: true
# description: The unique id of an existing process group
# schema:
# type: string
# - name: process_model_id
# in: path
# required: true
# description: The unique id of an existing process model.
# schema:
# type: string
# post:
# operationId: spiffworkflow_backend.routes.process_api_blueprint.script_unit_test_run
# summary: Run a given script unit test.
# tags:
# - Script Unit Test
# responses:
# "200":
# description: Script Unit Test Result
# content:
# application/json:
# schema:
# $ref: "#/components/schemas/Workflow"
/process-models/{process_group_id}/{process_model_id}/process-instances: /process-models/{process_group_id}/{process_model_id}/process-instances:
parameters: parameters:
- name: process_group_id - name: process_group_id
@ -484,7 +512,7 @@ paths:
- name: process_model_id - name: process_model_id
in: path in: path
required: true required: true
description: The unique id of an existing workflow specification. description: The unique id of an existing process model.
schema: schema:
type: string type: string
# process_instance_create # process_instance_create
@ -558,7 +586,7 @@ paths:
- name: process_model_id - name: process_model_id
in: path in: path
required: true required: true
description: The unique id of an existing workflow specification. description: The unique id of an existing process model.
schema: schema:
type: string type: string
- name: process_instance_id - name: process_instance_id
@ -598,7 +626,7 @@ paths:
- name: process_model_id - name: process_model_id
in: path in: path
required: true required: true
description: The unique id of an existing workflow specification. description: The unique id of an existing process model.
schema: schema:
type: string type: string
- name: process_instance_id - name: process_instance_id
@ -631,7 +659,7 @@ paths:
- name: process_model_id - name: process_model_id
in: path in: path
required: true required: true
description: The unique id of an existing workflow specification. description: The unique id of an existing process model.
schema: schema:
type: string type: string
- name: page - name: page
@ -684,7 +712,7 @@ paths:
- name: process_model_id - name: process_model_id
in: path in: path
required: true required: true
description: The unique id of an existing workflow specification. description: The unique id of an existing process model.
schema: schema:
type: string type: string
- name: report_identifier - name: report_identifier
@ -755,7 +783,7 @@ paths:
- name: process_model_id - name: process_model_id
in: path in: path
required: true required: true
description: The unique id of an existing workflow specification to validate. description: The unique id of an existing process model to validate.
schema: schema:
type: string type: string
- name: file_name - name: file_name
@ -928,7 +956,7 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/WorkflowSpecCategory" $ref: "#/components/schemas/ProcessModelCategory"
responses: responses:
"200": "200":
description: One task description: One task
@ -1203,7 +1231,7 @@ components:
properties: properties:
id: id:
type: string type: string
WorkflowSpecDiffList: ProcessModelDiffList:
properties: properties:
workflow_spec_id: workflow_spec_id:
type: string type: string
@ -1216,7 +1244,7 @@ components:
new: new:
type: boolean type: boolean
example: false example: false
WorkflowSpecFilesList: ProcessModelFilesList:
properties: properties:
file_model_id: file_model_id:
type: integer type: integer
@ -1245,7 +1273,7 @@ components:
type: string type: string
example: f12e2bbd-a20c-673b-ccb8-a8a1ea9c5b7b example: f12e2bbd-a20c-673b-ccb8-a8a1ea9c5b7b
WorkflowSpecFilesDiff: ProcessModelFilesDiff:
properties: properties:
filename: filename:
type: string type: string
@ -1273,7 +1301,7 @@ components:
new: new:
type: boolean type: boolean
example: false example: false
WorkflowSpecAll: ProcessModelAll:
properties: properties:
workflow_spec_id: workflow_spec_id:
type: string type: string
@ -1377,7 +1405,7 @@ components:
x-nullable: true x-nullable: true
example: Some Value example: Some Value
WorkflowSpec: ProcessModel:
properties: properties:
id: id:
type: string type: string
@ -1398,11 +1426,11 @@ components:
example: false example: false
default: false default: false
workflow_spec_category: workflow_spec_category:
$ref: "#/components/schemas/WorkflowSpecCategory" $ref: "#/components/schemas/ProcessModelCategory"
is_status: is_status:
type: boolean type: boolean
nullable: true nullable: true
WorkflowSpecCategory: ProcessModelCategory:
properties: properties:
id: id:
type: string type: string
@ -1622,7 +1650,7 @@ components:
study: study:
$ref: "#/components/schemas/Study" $ref: "#/components/schemas/Study"
workflow_sec: workflow_sec:
$ref: "#/components/schemas/WorkflowSpec" $ref: "#/components/schemas/ProcessModel"
spec_version: spec_version:
type: string type: string
action: action:

View File

@ -964,6 +964,22 @@ def task_submit(
return Response(json.dumps({"ok": True}), status=202, mimetype="application/json") return Response(json.dumps({"ok": True}), status=202, mimetype="application/json")
# def script_unit_test_run(
# process_group_id: str, process_model_id: str, body: Dict[str, Union[str, bool, int]]
# ) -> flask.wrappers.Response:
#
# process_model = get_process_model(process_model_id, process_group_id)
#
# # process_model_service = ProcessModelService()
# # process_group = ProcessGroupSchema().load(body)
# # process_model_service.add_process_group(process_group)
# # return Response(
# # json.dumps(ProcessGroupSchema().dump(process_group)),
# # status=201,
# # mimetype="application/json",
# # )
def get_file_from_request() -> Any: def get_file_from_request() -> Any:
"""Get_file_from_request.""" """Get_file_from_request."""
request_file = connexion.request.files.get("file") request_file = connexion.request.files.get("file")

View File

@ -40,6 +40,7 @@ from SpiffWorkflow.spiff.serializer import IntermediateThrowEventConverter
from SpiffWorkflow.spiff.serializer import ManualTaskConverter from SpiffWorkflow.spiff.serializer import ManualTaskConverter
from SpiffWorkflow.spiff.serializer import NoneTaskConverter from SpiffWorkflow.spiff.serializer import NoneTaskConverter
from SpiffWorkflow.spiff.serializer import ReceiveTaskConverter from SpiffWorkflow.spiff.serializer import ReceiveTaskConverter
from SpiffWorkflow.spiff.serializer import ScriptTaskConverter
from SpiffWorkflow.spiff.serializer import SendTaskConverter from SpiffWorkflow.spiff.serializer import SendTaskConverter
from SpiffWorkflow.spiff.serializer import ServiceTaskConverter from SpiffWorkflow.spiff.serializer import ServiceTaskConverter
from SpiffWorkflow.spiff.serializer import StartEventConverter from SpiffWorkflow.spiff.serializer import StartEventConverter
@ -159,6 +160,7 @@ class ProcessInstanceProcessor:
ManualTaskConverter, ManualTaskConverter,
NoneTaskConverter, NoneTaskConverter,
ReceiveTaskConverter, ReceiveTaskConverter,
ScriptTaskConverter,
SendTaskConverter, SendTaskConverter,
ServiceTaskConverter, ServiceTaskConverter,
StartEventConverter, StartEventConverter,
@ -172,6 +174,22 @@ class ProcessInstanceProcessor:
PROCESS_INSTANCE_ID_KEY = "process_instance_id" PROCESS_INSTANCE_ID_KEY = "process_instance_id"
VALIDATION_PROCESS_KEY = "validate_only" VALIDATION_PROCESS_KEY = "validate_only"
# def create_bpmn_process_instance_from_process_model():
# spec_info = self.process_model_service.get_process_model(
# process_instance_model.process_model_identifier, process_instance_model.process_group_identifier
# )
# if spec_info is None:
# raise (
# ApiError(
# "missing_spec",
# "The spec this process_instance references does not currently exist.",
# )
# )
# self.spec_files = SpecFileService.get_files(
# spec_info, include_libraries=True
# )
# (spec, subprocesses) = self.get_spec(self.spec_files, spec_info)
# __init__ calls these helpers: # __init__ calls these helpers:
# * get_spec, which returns a spec and any subprocesses (as IdToBpmnProcessSpecMapping dict) # * get_spec, which returns a spec and any subprocesses (as IdToBpmnProcessSpecMapping dict)
# * __get_bpmn_process_instance, which takes spec and subprocesses and instantiates and returns a BpmnWorkflow # * __get_bpmn_process_instance, which takes spec and subprocesses and instantiates and returns a BpmnWorkflow
@ -189,7 +207,8 @@ class ProcessInstanceProcessor:
subprocesses: Optional[IdToBpmnProcessSpecMapping] = None subprocesses: Optional[IdToBpmnProcessSpecMapping] = None
if process_instance_model.bpmn_json is None: if process_instance_model.bpmn_json is None:
spec_info = self.process_model_service.get_process_model( spec_info = self.process_model_service.get_process_model(
process_instance_model.process_model_identifier process_instance_model.process_model_identifier,
process_instance_model.process_group_identifier,
) )
if spec_info is None: if spec_info is None:
raise ( raise (

View File

@ -8,14 +8,6 @@ from typing import Optional
from flask import current_app from flask import current_app
from flask_bpmn.api.api_error import ApiError from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db from flask_bpmn.models.db import db
from SpiffWorkflow.bpmn.specs.events import EndEvent # type: ignore
from SpiffWorkflow.bpmn.specs.events import StartEvent
from SpiffWorkflow.bpmn.specs.ScriptTask import ScriptTask # type: ignore
from SpiffWorkflow.dmn.specs.BusinessRuleTask import BusinessRuleTask # type: ignore
from SpiffWorkflow.specs import CancelTask # type: ignore
from SpiffWorkflow.specs import StartTask
from SpiffWorkflow.spiff.specs.manual_task import ManualTask # type: ignore
from SpiffWorkflow.spiff.specs.user_task import UserTask # 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
@ -267,30 +259,6 @@ class ProcessInstanceService:
return lane_uids return lane_uids
# @staticmethod
# def get_task_type(spiff_task: SpiffTask):
# """Get_task_type."""
# task_type = spiff_task.task_spec.__class__.__name__
#
# task_types = [
# UserTask,
# ManualTask,
# BusinessRuleTask,
# CancelTask,
# ScriptTask,
# StartTask,
# EndEvent,
# StartEvent,
# ]
#
# for t in task_types:
# if isinstance(spiff_task.task_spec, t):
# task_type = t.__name__
# break
# else:
# task_type = "NoneTask"
# return task_type
@staticmethod @staticmethod
def complete_form_task( def complete_form_task(
processor: ProcessInstanceProcessor, processor: ProcessInstanceProcessor,
@ -412,25 +380,7 @@ class ProcessInstanceService:
spiff_task: SpiffTask, add_docs_and_forms: bool = False spiff_task: SpiffTask, add_docs_and_forms: bool = False
) -> Task: ) -> Task:
"""Spiff_task_to_api_task.""" """Spiff_task_to_api_task."""
task_type = spiff_task.task_spec.__class__.__name__ task_type = spiff_task.task_spec.spec_type
task_types = [
UserTask,
ManualTask,
BusinessRuleTask,
CancelTask,
ScriptTask,
StartTask,
EndEvent,
StartEvent,
]
for t in task_types:
if isinstance(spiff_task.task_spec, t):
task_type = t.__name__
break
else:
task_type = "NoneTask"
info = spiff_task.task_info() info = spiff_task.task_info()
if info["is_looping"]: if info["is_looping"]:

View File

@ -1300,7 +1300,7 @@ class TestProcessApi(BaseTest):
api_error = json.loads(response.get_data(as_text=True)) api_error = json.loads(response.get_data(as_text=True))
assert api_error["code"] == "task_error" assert api_error["code"] == "task_error"
assert ( assert (
'Activity_CauseError: TypeError:can only concatenate str (not "int") to str' 'Activity_CauseError: TypeError: can only concatenate str (not "int") to str'
in api_error["message"] in api_error["message"]
) )
@ -1382,7 +1382,7 @@ class TestProcessApi(BaseTest):
assert message.subject == "Unexpected error in app" assert message.subject == "Unexpected error in app"
assert ( assert (
message.body message.body
== 'Activity_CauseError: TypeError:can only concatenate str (not "int") to str' == 'Activity_CauseError: TypeError: can only concatenate str (not "int") to str'
) )
assert message.recipients == process_model.exception_notification_addresses assert message.recipients == process_model.exception_notification_addresses