fixed some precommit
This commit is contained in:
parent
5cfe999d34
commit
65da9ccbaa
|
@ -1,23 +1,27 @@
|
|||
"""Grabs tickets from csv and makes process instances."""
|
||||
import csv
|
||||
import os
|
||||
|
||||
from flask import current_app
|
||||
from flask_bpmn.models.db import db
|
||||
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
||||
|
||||
import csv
|
||||
|
||||
from spiffworkflow_backend import create_app
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
||||
from spiffworkflow_backend.models.user import UserModel
|
||||
from spiffworkflow_backend.services.process_instance_processor import ProcessInstanceProcessor
|
||||
from spiffworkflow_backend.services.process_instance_service import ProcessInstanceService
|
||||
from flask import current_app
|
||||
|
||||
from spiffworkflow_backend.services.process_instance_processor import (
|
||||
ProcessInstanceProcessor,
|
||||
)
|
||||
from spiffworkflow_backend.services.process_instance_service import (
|
||||
ProcessInstanceService,
|
||||
)
|
||||
from spiffworkflow_backend.services.process_model_service import ProcessModelService
|
||||
|
||||
|
||||
def print_process_instance_count(process_model_identifier_ticket: str) -> None:
|
||||
"""Print process instance count."""
|
||||
process_instances = ProcessInstanceModel.query.filter_by(process_model_identifier=process_model_identifier_ticket).all()
|
||||
process_instances = ProcessInstanceModel.query.filter_by(
|
||||
process_model_identifier=process_model_identifier_ticket
|
||||
).all()
|
||||
process_instance_count = len(process_instances)
|
||||
print(f"process_instance_count: {process_instance_count}")
|
||||
|
||||
|
@ -30,19 +34,31 @@ def main():
|
|||
with app.app_context():
|
||||
|
||||
process_model_identifier_ticket = "ticket"
|
||||
db.session.query(ProcessInstanceModel).filter(ProcessInstanceModel.process_model_identifier == process_model_identifier_ticket).delete()
|
||||
db.session.query(ProcessInstanceModel).filter(
|
||||
ProcessInstanceModel.process_model_identifier
|
||||
== process_model_identifier_ticket
|
||||
).delete()
|
||||
db.session.commit()
|
||||
|
||||
"""Print process instance count."""
|
||||
process_instances = ProcessInstanceModel.query.filter_by(process_model_identifier=process_model_identifier_ticket).all()
|
||||
process_instances = ProcessInstanceModel.query.filter_by(
|
||||
process_model_identifier=process_model_identifier_ticket
|
||||
).all()
|
||||
process_instance_count = len(process_instances)
|
||||
print(f"process_instance_count: {process_instance_count}")
|
||||
|
||||
# process_model = ProcessModelService().get_process_model(process_model_identifier_ticket)
|
||||
columns_to_data_key_mappings = {"Month": "month", "MS": "milestone", "ID": "req_id", "Dev Days": "dev_days", "Feature": "feature", "Priority": "priority"}
|
||||
columns_to_data_key_mappings = {
|
||||
"Month": "month",
|
||||
"MS": "milestone",
|
||||
"ID": "req_id",
|
||||
"Dev Days": "dev_days",
|
||||
"Feature": "feature",
|
||||
"Priority": "priority",
|
||||
}
|
||||
columns_to_header_index_mappings = {}
|
||||
|
||||
user = UserModel.query.filter_by(username='test_user1').first()
|
||||
user = UserModel.query.filter_by(username="test_user1").first()
|
||||
|
||||
with open("tests/files/tickets.csv") as infile:
|
||||
reader = csv.reader(infile, delimiter=",")
|
||||
|
@ -52,7 +68,9 @@ def main():
|
|||
|
||||
header = next(reader)
|
||||
for column_name in columns_to_data_key_mappings:
|
||||
columns_to_header_index_mappings[column_name] = header.index(column_name)
|
||||
columns_to_header_index_mappings[column_name] = header.index(
|
||||
column_name
|
||||
)
|
||||
id_index = header.index("ID")
|
||||
priority_index = header.index("Priority")
|
||||
print(f"header: {header}")
|
||||
|
@ -70,9 +88,14 @@ def main():
|
|||
processor.do_engine_steps()
|
||||
# processor.save()
|
||||
|
||||
for column_name, desired_data_key in columns_to_data_key_mappings.items():
|
||||
for (
|
||||
column_name,
|
||||
desired_data_key,
|
||||
) in columns_to_data_key_mappings.items():
|
||||
appropriate_index = columns_to_header_index_mappings[column_name]
|
||||
processor.bpmn_process_instance.data[desired_data_key] = row[appropriate_index]
|
||||
processor.bpmn_process_instance.data[desired_data_key] = row[
|
||||
appropriate_index
|
||||
]
|
||||
|
||||
print(f"datas: {processor.bpmn_process_instance.data}")
|
||||
if processor.bpmn_process_instance.data["month"] == "":
|
||||
|
@ -85,6 +108,5 @@ def main():
|
|||
processor.save()
|
||||
|
||||
|
||||
|
||||
# if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -1,33 +1,46 @@
|
|||
import csv
|
||||
import os
|
||||
|
||||
from flask import current_app
|
||||
from flask_bpmn.models.db import db
|
||||
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
||||
|
||||
import csv
|
||||
|
||||
from spiffworkflow_backend import create_app
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
||||
from spiffworkflow_backend.models.user import UserModel
|
||||
from spiffworkflow_backend.services.process_instance_processor import ProcessInstanceProcessor
|
||||
from spiffworkflow_backend.services.process_instance_service import ProcessInstanceService
|
||||
from flask import current_app
|
||||
|
||||
from spiffworkflow_backend.services.process_instance_processor import (
|
||||
ProcessInstanceProcessor,
|
||||
)
|
||||
from spiffworkflow_backend.services.process_instance_service import (
|
||||
ProcessInstanceService,
|
||||
)
|
||||
from spiffworkflow_backend.services.process_model_service import ProcessModelService
|
||||
|
||||
|
||||
process_model_identifier_ticket = "ticket"
|
||||
db.session.query(ProcessInstanceModel).filter(ProcessInstanceModel.process_model_identifier == process_model_identifier_ticket).delete()
|
||||
db.session.query(ProcessInstanceModel).filter(
|
||||
ProcessInstanceModel.process_model_identifier == process_model_identifier_ticket
|
||||
).delete()
|
||||
db.session.commit()
|
||||
|
||||
"""Print process instance count."""
|
||||
process_instances = ProcessInstanceModel.query.filter_by(process_model_identifier=process_model_identifier_ticket).all()
|
||||
process_instances = ProcessInstanceModel.query.filter_by(
|
||||
process_model_identifier=process_model_identifier_ticket
|
||||
).all()
|
||||
process_instance_count = len(process_instances)
|
||||
print(f"process_instance_count: {process_instance_count}")
|
||||
|
||||
process_model = ProcessModelService().get_process_model(process_model_identifier_ticket)
|
||||
columns_to_data_key_mappings = {"Month": "month", "MS": "milestone", "ID": "req_id", "Dev Days": "dev_days", "Feature": "feature", "Priority": "priority"}
|
||||
columns_to_data_key_mappings = {
|
||||
"Month": "month",
|
||||
"MS": "milestone",
|
||||
"ID": "req_id",
|
||||
"Dev Days": "dev_days",
|
||||
"Feature": "feature",
|
||||
"Priority": "priority",
|
||||
}
|
||||
columns_to_header_index_mappings = {}
|
||||
|
||||
user = UserModel.query.filter_by(username='test_user1').first()
|
||||
user = UserModel.query.filter_by(username="test_user1").first()
|
||||
|
||||
with open("tests/files/tickets.csv") as infile:
|
||||
reader = csv.reader(infile, delimiter=",")
|
||||
|
@ -58,7 +71,9 @@ with open("tests/files/tickets.csv") as infile:
|
|||
for column_name, desired_data_key in columns_to_data_key_mappings.items():
|
||||
appropriate_index = columns_to_header_index_mappings[column_name]
|
||||
print(f"appropriate_index: {appropriate_index}")
|
||||
processor.bpmn_process_instance.data[desired_data_key] = row[appropriate_index]
|
||||
processor.bpmn_process_instance.data[desired_data_key] = row[
|
||||
appropriate_index
|
||||
]
|
||||
|
||||
# you at least need a month, or else this row in the csv is considered garbage
|
||||
month_value = processor.bpmn_process_instance.data["month"]
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import with_statement
|
||||
|
||||
import logging
|
||||
from logging.config import fileConfig
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
"""Process_group."""
|
||||
import marshmallow
|
||||
from marshmallow import post_load
|
||||
from marshmallow import Schema
|
||||
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import field
|
||||
from typing import Optional
|
||||
|
||||
import marshmallow
|
||||
from marshmallow import post_load
|
||||
from marshmallow import Schema
|
||||
|
||||
from spiffworkflow_backend.models.process_model import ProcessModelInfo
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Process_instance."""
|
||||
|
||||
from flask_bpmn.models.db import db
|
||||
from sqlalchemy import ForeignKey
|
||||
from sqlalchemy import func
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
"""Process_model."""
|
||||
import marshmallow
|
||||
from marshmallow import post_load
|
||||
from marshmallow import Schema
|
||||
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import field
|
||||
from typing import Optional
|
||||
|
||||
import marshmallow
|
||||
from marshmallow import post_load
|
||||
from marshmallow import Schema
|
||||
|
||||
|
||||
@dataclass(order=True)
|
||||
class ProcessModelInfo:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"""User."""
|
||||
from typing import Optional
|
||||
|
||||
import jwt
|
||||
import marshmallow
|
||||
from flask import current_app
|
||||
|
@ -66,9 +67,7 @@ class UserModel(db.Model): # type: ignore
|
|||
raise KeyError("we need current_app.config to have a SECRET_KEY")
|
||||
|
||||
try:
|
||||
payload = jwt.decode(
|
||||
auth_token, secret_key, algorithms=["HS256"]
|
||||
)
|
||||
payload = jwt.decode(auth_token, secret_key, algorithms=["HS256"])
|
||||
return payload
|
||||
except jwt.ExpiredSignatureError as exception:
|
||||
raise ApiError(
|
||||
|
|
|
@ -160,7 +160,9 @@ def process_model_list(process_group_id, page=1, per_page=100):
|
|||
|
||||
def get_file(process_group_id, process_model_id, file_name):
|
||||
"""Get_file."""
|
||||
process_model = ProcessModelService().get_process_model(process_model_id, group_id=process_group_id)
|
||||
process_model = ProcessModelService().get_process_model(
|
||||
process_model_id, group_id=process_group_id
|
||||
)
|
||||
files = SpecFileService.get_files(process_model, file_name)
|
||||
if len(files) == 0:
|
||||
raise ApiError(
|
||||
|
@ -180,7 +182,9 @@ def get_file(process_group_id, process_model_id, file_name):
|
|||
|
||||
def process_model_file_update(process_group_id, process_model_id, file_name):
|
||||
"""Process_model_file_save."""
|
||||
process_model = ProcessModelService().get_process_model(process_model_id, group_id=process_group_id)
|
||||
process_model = ProcessModelService().get_process_model(
|
||||
process_model_id, group_id=process_group_id
|
||||
)
|
||||
|
||||
request_file = get_file_from_request()
|
||||
request_file_contents = request_file.stream.read()
|
||||
|
@ -198,7 +202,9 @@ def process_model_file_update(process_group_id, process_model_id, file_name):
|
|||
def add_file(process_group_id, process_model_id):
|
||||
"""Add_file."""
|
||||
process_model_service = ProcessModelService()
|
||||
process_model = process_model_service.get_process_model(process_model_id, group_id=process_group_id)
|
||||
process_model = process_model_service.get_process_model(
|
||||
process_model_id, group_id=process_group_id
|
||||
)
|
||||
request_file = get_file_from_request()
|
||||
file = SpecFileService.add_file(
|
||||
process_model, request_file.filename, request_file.stream.read()
|
||||
|
@ -239,7 +245,9 @@ def process_instance_create(process_group_id, process_model_id):
|
|||
|
||||
def process_instance_list(process_group_id, process_model_id, page=1, per_page=100):
|
||||
"""Process_instance_list."""
|
||||
process_model = ProcessModelService().get_process_model(process_model_id, group_id=process_group_id)
|
||||
process_model = ProcessModelService().get_process_model(
|
||||
process_model_id, group_id=process_group_id
|
||||
)
|
||||
if process_model is None:
|
||||
raise (
|
||||
ApiError(
|
||||
|
@ -276,7 +284,9 @@ def process_instance_list(process_group_id, process_model_id, page=1, per_page=1
|
|||
|
||||
def process_instance_report(process_group_id, process_model_id, page=1, per_page=100):
|
||||
"""Process_instance_list."""
|
||||
process_model = ProcessModelService().get_process_model(process_model_id, group_id=process_group_id)
|
||||
process_model = ProcessModelService().get_process_model(
|
||||
process_model_id, group_id=process_group_id
|
||||
)
|
||||
if process_model is None:
|
||||
raise (
|
||||
ApiError(
|
||||
|
|
|
@ -49,6 +49,7 @@ class Script:
|
|||
We may be able to remove the task for each of these calls if we are not using it other than potentially
|
||||
updating the task data.
|
||||
"""
|
||||
|
||||
def make_closure(subclass, task, workflow_id):
|
||||
"""Yes - this is black magic.
|
||||
|
||||
|
@ -84,6 +85,7 @@ class Script:
|
|||
We may be able to remove the task for each of these calls if we are not using it other than potentially
|
||||
updating the task data.
|
||||
"""
|
||||
|
||||
def make_closure_validate(subclass, task, workflow_id):
|
||||
"""Make_closure_validate."""
|
||||
instance = subclass()
|
||||
|
|
|
@ -28,7 +28,9 @@ class ProcessInstanceService:
|
|||
TASK_STATE_LOCKED = "locked"
|
||||
|
||||
@staticmethod
|
||||
def create_process_instance(process_model_identifier, user, process_group_identifier=None):
|
||||
def create_process_instance(
|
||||
process_model_identifier, user, process_group_identifier=None
|
||||
):
|
||||
"""Get_process_instance_from_spec."""
|
||||
process_instance_model = ProcessInstanceModel(
|
||||
status=ProcessInstanceStatus.not_started,
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
import os
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
from typing import List, Union
|
||||
from typing import List
|
||||
from typing import Union
|
||||
|
||||
from flask_bpmn.api.api_error import ApiError
|
||||
from lxml import etree # type: ignore
|
||||
|
@ -126,7 +127,9 @@ class SpecFileService(FileSystemService):
|
|||
|
||||
@staticmethod
|
||||
def set_primary_bpmn(
|
||||
workflow_spec: ProcessModelInfo, file_name: str, binary_data: Union[bytes, None] = None
|
||||
workflow_spec: ProcessModelInfo,
|
||||
file_name: str,
|
||||
binary_data: Union[bytes, None] = None,
|
||||
) -> None:
|
||||
"""Set_primary_bpmn."""
|
||||
# If this is a BPMN, extract the process id, and determine if it is contains swim lanes.
|
||||
|
|
|
@ -4,7 +4,7 @@ TRUE,1,1,15.1.3,API,Code bases established using Flask Blueprints,A,Generate a n
|
|||
TRUE,1,1,7.1.1,API,Deploy Process ,A,The engine offers an API that deploys a set of BPMN process models. It must be possible to include BPMN files in the API request.,,,XS(P),0.4,0.8,1,,0.5,0.5,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,ADM-D001,1,A
|
||||
TRUE,1,1,7.2,API,Deploy Process ,C,"Each business process model is assigned to a process group configured in the model itself, which is a logical identifier.",,,XS,0.5,1.0,1,,0.5,0.5,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,ADM-D002,1,C
|
||||
TRUE,1,1,7.3,API,Deploy Process ,A,"When deploying a new process model version, old process instances are still executed with the old process model version(s).",,,XS,0.5,1.0,1,A BPMN Process Model is deployed and process instances using that model are instantiated. later a new version is deployed. The old instances are still running correctly and with the old process model version.,0.5,0.5,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,ADM-D003,1,A
|
||||
TRUE,1,1,6.1,API,Instantiate Process ,A,"Process Models can be instantiated by API calls to a model-defined endpoint, e.g., the BPMN model defines BudgetApproval as an endpoint which is then exposed via https://localhost:8080/processes/BudgetApproval. Calling this API (no parameters required) will instantiate a process instance of the most current version of this process model.
|
||||
TRUE,1,1,6.1,API,Instantiate Process ,A,"Process Models can be instantiated by API calls to a model-defined endpoint, e.g., the BPMN model defines BudgetApproval as an endpoint which is then exposed via https://localhost:8080/processes/BudgetApproval. Calling this API (no parameters required) will instantiate a process instance of the most current version of this process model.
|
||||
If the request is authenticated, the processInitiator metadata attribute of the process instance is set to the authenticated user.",,,S,1.0,3.0,3,Renaming of endpoints required - but otherwise complete.,1.5,1.5,,,,3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,ADM-E001,1,A
|
||||
TRUE,1,1,15.3.1,BPMN.IO,Data Refactor-Architect,A,,,,XL(P),3.0,6.0,6,This covers the modifications to the BPMN.io open source tooling to allow us valid Data Input and Data Output models with which to work.,,,6,,,6,,,,,,1.8,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,
|
||||
TRUE,1,1,16.1,,,A,Ability to create a BPMN workflow editing tool that allows workflows to be designed visually using functionality similar to drag and drop.,,,S,1.0,3.0,3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
|
@ -26,17 +26,17 @@ TRUE,2,1,7.9.2,API,Process Instance Pagination ,,,,,,,1,1,,,,,,1,1,,,,,,,,,,,,,,
|
|||
TRUE,2,1,7.9.3,API,Process Model Pagination ,,,,,,,1,1,,0.5,0.5,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
TRUE,2,1,7.9.4,UI,Process Model & Group UI,,,,,,,1,1,,,,,,1,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,
|
||||
TRUE,2,1,7.9.5,UI,Support editing DMN,,,,,,,1,1,,0.5,0.5,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
FALSE,2,1,6.2,API,"Process Instance, Model and Model Group instantiation to API.",A,"Process Models can be instantiated by API calls to a model-defined endpoint, e.g., the BPMN model defines BudgetApproval as an endpoint which is then exposed via https://localhost:8080/processes/BudgetApproval. Calling this API with respective parameters, which will mapped to the incoming message of the message start event, will instantiate a process instance of the most current version of this process model.
|
||||
FALSE,2,1,6.2,API,"Process Instance, Model and Model Group instantiation to API.",A,"Process Models can be instantiated by API calls to a model-defined endpoint, e.g., the BPMN model defines BudgetApproval as an endpoint which is then exposed via https://localhost:8080/processes/BudgetApproval. Calling this API with respective parameters, which will mapped to the incoming message of the message start event, will instantiate a process instance of the most current version of this process model.
|
||||
If the request is authenticated, the processInitiator metadata attribute of the process instance is set to the authenticated user.
|
||||
",,,S,1.0,3.0,3,"We have this endpoint, we need to ability to fire the message rather than start the default process.",,,,3.0,,3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,ADM-E002,2,A
|
||||
FALSE,2,1,7.6.1,API,Error Handling and Resolution,A,"Allow for configuring uncaught error-behavior, i.e., if a task fails or any expression could not be evaluated, and no matching error event is found. Options are:
|
||||
- fault (BPMN standard compliant),
|
||||
FALSE,2,1,7.6.1,API,Error Handling and Resolution,A,"Allow for configuring uncaught error-behavior, i.e., if a task fails or any expression could not be evaluated, and no matching error event is found. Options are:
|
||||
- fault (BPMN standard compliant),
|
||||
- fault+notify
|
||||
Notifications are done via sending emails to configurable email addresses.",,,S,1.0,3.0,2,"Depoy a BPMN model without process instance fault behavior configuration and a script task that throws an exception. Instantiate the model and verify that its end state is faulted.
|
||||
Depoy a BPMN model with process instance fault behavior set to fault and a script task that throws an exception. Instantiate the model and verify that its end state is faulted.
|
||||
Depoy a BPMN model with process instance fault+notify behavior set to fault and a script task that throws an exception. Instantiate the model and verify that its end state is faulted, and a notification email is sent.",0.5,0.5,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,ADM-D005a,2,A
|
||||
FALSE,2,1,7.6.2,API,Error Handling and Resolution,C,"Allow for configuring uncaught error-behavior, i.e., if a task fails or any expression could not be evaluated, and no matching error event is found. Options are:
|
||||
- suspend,
|
||||
FALSE,2,1,7.6.2,API,Error Handling and Resolution,C,"Allow for configuring uncaught error-behavior, i.e., if a task fails or any expression could not be evaluated, and no matching error event is found. Options are:
|
||||
- suspend,
|
||||
- suspend+notify
|
||||
Notifications are done via sending emails to configurable email addresses.",,,S,1.0,3.0,2,"Depoy a BPMN model with process instance fault behavior set to suspend and a script task that throws an exception. Instantiate the model and verify that its state is suspended.
|
||||
Depoy a BPMN model with process instance suspend+notify behavior set to fault and a script task that throws an exception. Instantiate the model and verify that it is suspended, and a notification email is sent.",0.5,0.5,,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,ADM-D005b,2,C
|
||||
|
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Test Api Blueprint."""
|
||||
|
||||
# TODO: possibly get this test working again
|
||||
# import json
|
||||
# from typing import Union
|
||||
|
|
|
@ -689,7 +689,7 @@ def test_process_instance_report_with_default_list(
|
|||
<= process_instance_dict["end_in_seconds"]
|
||||
)
|
||||
assert process_instance_dict["status"] == "complete"
|
||||
assert process_instance_dict["data"]['Mike'] == "Awesome"
|
||||
assert process_instance_dict["data"]["Mike"] == "Awesome"
|
||||
|
||||
|
||||
def create_process_instance(
|
||||
|
|
|
@ -4,7 +4,9 @@ from spiffworkflow_backend.models.process_model import ProcessModelInfo
|
|||
|
||||
def test_initializes_files_as_empty_array() -> None:
|
||||
"""Test_initializes_files_as_empty_array."""
|
||||
process_model_one = create_test_process_model(id="model_one", display_name="Model One")
|
||||
process_model_one = create_test_process_model(
|
||||
id="model_one", display_name="Model One"
|
||||
)
|
||||
assert process_model_one.files == []
|
||||
assert process_model_one.libraries == []
|
||||
|
||||
|
|
Loading…
Reference in New Issue