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

View File

@ -27,9 +27,9 @@ flask-marshmallow = "*"
flask-migrate = "*"
flask-restful = "*"
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 = {develop = true, path = "/home/jason/projects/github/sartography/SpiffWorkflow"}
SpiffWorkflow = {develop = true, path = "/home/jason/projects/github/sartography/SpiffWorkflow"}
sentry-sdk = "1.9.0"
sphinx-autoapi = "^1.8.4"
# flask-bpmn = {develop = true, path = "/home/jason/projects/github/sartography/flask-bpmn"}

View File

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

View File

@ -964,6 +964,22 @@ def task_submit(
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:
"""Get_file_from_request."""
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 NoneTaskConverter
from SpiffWorkflow.spiff.serializer import ReceiveTaskConverter
from SpiffWorkflow.spiff.serializer import ScriptTaskConverter
from SpiffWorkflow.spiff.serializer import SendTaskConverter
from SpiffWorkflow.spiff.serializer import ServiceTaskConverter
from SpiffWorkflow.spiff.serializer import StartEventConverter
@ -159,6 +160,7 @@ class ProcessInstanceProcessor:
ManualTaskConverter,
NoneTaskConverter,
ReceiveTaskConverter,
ScriptTaskConverter,
SendTaskConverter,
ServiceTaskConverter,
StartEventConverter,
@ -172,6 +174,22 @@ class ProcessInstanceProcessor:
PROCESS_INSTANCE_ID_KEY = "process_instance_id"
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:
# * 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
@ -189,7 +207,8 @@ class ProcessInstanceProcessor:
subprocesses: Optional[IdToBpmnProcessSpecMapping] = None
if process_instance_model.bpmn_json is None:
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:
raise (

View File

@ -8,14 +8,6 @@ from typing import Optional
from flask import current_app
from flask_bpmn.api.api_error import ApiError
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.util.deep_merge import DeepMerge # type: ignore
@ -267,30 +259,6 @@ class ProcessInstanceService:
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
def complete_form_task(
processor: ProcessInstanceProcessor,
@ -412,25 +380,7 @@ class ProcessInstanceService:
spiff_task: SpiffTask, add_docs_and_forms: bool = False
) -> Task:
"""Spiff_task_to_api_task."""
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"
task_type = spiff_task.task_spec.spec_type
info = spiff_task.task_info()
if info["is_looping"]:

View File

@ -1300,7 +1300,7 @@ class TestProcessApi(BaseTest):
api_error = json.loads(response.get_data(as_text=True))
assert api_error["code"] == "task_error"
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"]
)
@ -1382,7 +1382,7 @@ class TestProcessApi(BaseTest):
assert message.subject == "Unexpected error in app"
assert (
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