pyl passes

This commit is contained in:
jasquat 2022-12-08 13:47:30 -05:00
parent 829eacc40d
commit cee726e8b0
60 changed files with 152 additions and 152 deletions

View File

@ -8,8 +8,8 @@ from typing import Any
from flask_migrate import Migrate # type: ignore
from flask_sqlalchemy import SQLAlchemy # type: ignore
from sqlalchemy import event # type: ignore
from sqlalchemy.engine.base import Connection
from sqlalchemy.orm.mapper import Mapper
from sqlalchemy.engine.base import Connection # type: ignore
from sqlalchemy.orm.mapper import Mapper # type: ignore
db = SQLAlchemy()
migrate = Migrate()

View File

@ -1,5 +1,6 @@
"""Grabs tickets from csv and makes process instances."""
import csv
from flask_bpmn.models.db import db
from spiffworkflow_backend import get_hacked_up_app_for_script

View File

@ -2868,4 +2868,4 @@
"clientPolicies" : {
"policies" : [ ]
}
}
}

View File

@ -1,12 +1,12 @@
"""Conftest."""
import os
import shutil
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
import pytest
from flask.app import Flask
from flask.testing import FlaskClient
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from spiffworkflow_backend.models.active_task_user import ActiveTaskUserModel

View File

@ -1,8 +1,5 @@
"""__init__."""
import os
from flask_bpmn.api.api_error import api_error_blueprint
from flask_bpmn.models.db import db
from flask_bpmn.models.db import migrate
from typing import Any
import connexion # type: ignore
@ -12,6 +9,9 @@ import sqlalchemy
from apscheduler.schedulers.background import BackgroundScheduler # type: ignore
from apscheduler.schedulers.base import BaseScheduler # type: ignore
from flask.json.provider import DefaultJSONProvider
from flask_bpmn.api.api_error import api_error_blueprint
from flask_bpmn.models.db import db
from flask_bpmn.models.db import migrate
from flask_cors import CORS # type: ignore
from flask_mail import Mail # type: ignore
from werkzeug.exceptions import NotFound

View File

@ -8,7 +8,8 @@ GIT_COMMIT_ON_SAVE = True
GIT_COMMIT_USERNAME = environment_identifier_for_this_config_file_only
GIT_COMMIT_EMAIL = f"{environment_identifier_for_this_config_file_only}@example.com"
SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = environ.get(
"SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME", default="terraform_deployed_environment.yml"
"SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME",
default="terraform_deployed_environment.yml",
)
RUN_BACKGROUND_SCHEDULER = (
@ -16,6 +17,10 @@ RUN_BACKGROUND_SCHEDULER = (
)
OPEN_ID_SERVER_URL = f"https://keycloak.{environment_identifier_for_this_config_file_only}.spiffworkflow.org/realms/spiffworkflow"
SPIFFWORKFLOW_FRONTEND_URL = f"https://{environment_identifier_for_this_config_file_only}.spiffworkflow.org"
SPIFFWORKFLOW_BACKEND_URL = f"https://api.{environment_identifier_for_this_config_file_only}.spiffworkflow.org"
SPIFFWORKFLOW_FRONTEND_URL = (
f"https://{environment_identifier_for_this_config_file_only}.spiffworkflow.org"
)
SPIFFWORKFLOW_BACKEND_URL = (
f"https://api.{environment_identifier_for_this_config_file_only}.spiffworkflow.org"
)
CONNECTOR_PROXY_URL = f"https://connector-proxy.{environment_identifier_for_this_config_file_only}.spiffworkflow.org"

View File

@ -1,8 +1,8 @@
"""Db_helper."""
import time
from flask_bpmn.models.db import db
import sqlalchemy
from flask_bpmn.models.db import db
def try_to_connect(start_time: float) -> None:

View File

@ -2,10 +2,10 @@
from __future__ import annotations
from dataclasses import dataclass
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from typing import TYPE_CHECKING
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy import ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.orm import RelationshipProperty

View File

@ -2,9 +2,9 @@
from __future__ import annotations
from dataclasses import dataclass
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy import ForeignKey
from spiffworkflow_backend.models.active_task import ActiveTaskModel

View File

@ -1,10 +1,10 @@
"""Group."""
from __future__ import annotations
from flask_bpmn.models.db import db
from flask_bpmn.models.group import FlaskBpmnGroupModel
from typing import TYPE_CHECKING
from flask_bpmn.models.db import db
from flask_bpmn.models.group import FlaskBpmnGroupModel
from sqlalchemy.orm import relationship
if TYPE_CHECKING:

View File

@ -1,9 +1,9 @@
"""Message_correlation."""
from dataclasses import dataclass
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from typing import TYPE_CHECKING
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy import ForeignKey
from sqlalchemy.orm import relationship

View File

@ -1,8 +1,8 @@
"""Message_correlation_message_instance."""
from dataclasses import dataclass
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy import ForeignKey
from spiffworkflow_backend.models.message_correlation import MessageCorrelationModel

View File

@ -1,7 +1,6 @@
"""Message_correlation_property."""
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy import ForeignKey
from spiffworkflow_backend.models.message_model import MessageModel

View File

@ -1,12 +1,12 @@
"""Message_instance."""
import enum
from dataclasses import dataclass
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from typing import Any
from typing import Optional
from typing import TYPE_CHECKING
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy import ForeignKey
from sqlalchemy.event import listens_for
from sqlalchemy.orm import relationship

View File

@ -1,7 +1,6 @@
"""Message_correlation_property."""
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy import ForeignKey
from spiffworkflow_backend.models.message_model import MessageModel

View File

@ -1,9 +1,9 @@
"""PermissionAssignment."""
import enum
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from typing import Any
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy import ForeignKey
from sqlalchemy.orm import validates

View File

@ -1,10 +1,10 @@
"""PermissionTarget."""
import re
from dataclasses import dataclass
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from typing import Optional
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy.orm import validates

View File

@ -1,8 +1,8 @@
"""Principal."""
from dataclasses import dataclass
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy import ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.schema import CheckConstraint

View File

@ -1,12 +1,12 @@
"""Process_instance."""
from __future__ import annotations
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from typing import Any
from typing import cast
import marshmallow
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from marshmallow import INCLUDE
from marshmallow import Schema
from marshmallow_enum import EnumField # type: ignore

View File

@ -1,8 +1,8 @@
"""Spiff_step_details."""
from dataclasses import dataclass
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy import ForeignKey
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel

View File

@ -2,13 +2,13 @@
from __future__ import annotations
from dataclasses import dataclass
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from typing import Any
from typing import cast
from typing import Optional
from typing import TypedDict
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy import ForeignKey
from sqlalchemy.orm import deferred
from sqlalchemy.orm import relationship

View File

@ -1,8 +1,8 @@
"""Refresh_token."""
from dataclasses import dataclass
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy import ForeignKey
# from sqlalchemy.orm import relationship

View File

@ -1,8 +1,8 @@
"""Secret_model."""
from dataclasses import dataclass
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from marshmallow import Schema
from sqlalchemy import ForeignKey

View File

@ -1,8 +1,8 @@
"""Message_model."""
from dataclasses import dataclass
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from flask_marshmallow import Schema # type: ignore
from marshmallow import INCLUDE
from sqlalchemy import UniqueConstraint

View File

@ -1,8 +1,9 @@
"""Spiff_logging."""
from dataclasses import dataclass
from typing import Optional
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from typing import Optional
@dataclass

View File

@ -1,9 +1,9 @@
"""Spiff_step_details."""
from dataclasses import dataclass
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from typing import Optional
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy import ForeignKey
from sqlalchemy.orm import deferred

View File

@ -1,14 +1,14 @@
"""User."""
from __future__ import annotations
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from typing import Any
import jwt
import marshmallow
from flask import current_app
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from marshmallow import Schema
from sqlalchemy.orm import relationship
from sqlalchemy.orm import validates

View File

@ -1,7 +1,6 @@
"""UserGroupAssignment."""
from flask_bpmn.models.db import db
from flask_bpmn.models.db import SpiffworkflowBaseDBModel
from sqlalchemy import ForeignKey
from sqlalchemy.orm import relationship

View File

@ -4,8 +4,6 @@ import random
import re
import string
import uuid
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from typing import Any
from typing import Dict
from typing import Optional
@ -24,6 +22,8 @@ from flask import make_response
from flask import redirect
from flask import request
from flask.wrappers import Response
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from lxml import etree # type: ignore
from lxml.builder import ElementMaker # type: ignore
from SpiffWorkflow.task import Task as SpiffTask # type: ignore
@ -33,7 +33,6 @@ from sqlalchemy import asc
from sqlalchemy import desc
from sqlalchemy import func
from sqlalchemy.orm import aliased
from sqlalchemy.orm import joinedload
from sqlalchemy.orm import selectinload
from spiffworkflow_backend.exceptions.process_entity_not_found_error import (

View File

@ -2,7 +2,6 @@
import ast
import base64
import json
from flask_bpmn.api.api_error import ApiError
from typing import Any
from typing import Dict
from typing import Optional
@ -13,6 +12,7 @@ from flask import current_app
from flask import g
from flask import redirect
from flask import request
from flask_bpmn.api.api_error import ApiError
from werkzeug.wrappers import Response
from spiffworkflow_backend.models.user import UserModel

View File

@ -1,7 +1,5 @@
"""Main."""
import json
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from typing import Any
from typing import Final
@ -9,6 +7,8 @@ import flask.wrappers
from flask import Blueprint
from flask import request
from flask import Response
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from sqlalchemy.exc import IntegrityError
from spiffworkflow_backend.models.group import GroupModel

View File

@ -1,9 +1,9 @@
"""Get_localtime."""
from datetime import datetime
from flask_bpmn.api.api_error import ApiError
from typing import Any
import pytz
from flask_bpmn.api.api_error import ApiError
from spiffworkflow_backend.models.script_attributes_context import (
ScriptAttributesContext,

View File

@ -2,7 +2,6 @@
from typing import Any
from flask_bpmn.models.db import db
from typing import Any
from spiffworkflow_backend.models.process_instance_metadata import (
ProcessInstanceMetadataModel,

View File

@ -5,10 +5,11 @@ import importlib
import os
import pkgutil
from abc import abstractmethod
from flask_bpmn.api.api_error import ApiError
from typing import Any
from typing import Callable
from flask_bpmn.api.api_error import ApiError
from spiffworkflow_backend.models.script_attributes_context import (
ScriptAttributesContext,
)

View File

@ -1,8 +1,8 @@
"""Acceptance_test_fixtures."""
import time
from flask_bpmn.models.db import db
from flask import current_app
from flask_bpmn.models.db import db
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel

View File

@ -3,14 +3,14 @@ import base64
import enum
import json
import time
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from typing import Optional
import jwt
import requests
from flask import current_app
from flask import redirect
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from werkzeug.wrappers import Response
from spiffworkflow_backend.models.refresh_token import RefreshTokenModel

View File

@ -1,8 +1,6 @@
"""Authorization_service."""
import inspect
import re
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from typing import Optional
from typing import Union
@ -12,6 +10,8 @@ from flask import current_app
from flask import g
from flask import request
from flask import scaffold
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from SpiffWorkflow.task import Task as SpiffTask # type: ignore
from sqlalchemy import or_
from sqlalchemy import text

View File

@ -1,7 +1,6 @@
"""Data_setup_service."""
from flask_bpmn.models.db import db
from flask import current_app
from flask_bpmn.models.db import db
from spiffworkflow_backend.services.process_model_service import ProcessModelService
from spiffworkflow_backend.services.spec_file_service import SpecFileService

View File

@ -1,10 +1,11 @@
"""Error_handling_service."""
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from typing import Any
from typing import List
from typing import Union
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus
from spiffworkflow_backend.services.email_service import EmailService

View File

@ -1,12 +1,12 @@
"""File_system_service."""
import os
from datetime import datetime
from flask_bpmn.api.api_error import ApiError
from typing import List
from typing import Optional
import pytz
from flask import current_app
from flask_bpmn.api.api_error import ApiError
from spiffworkflow_backend.models.file import CONTENT_TYPES
from spiffworkflow_backend.models.file import File

View File

@ -1,7 +1,8 @@
"""Group_service."""
from flask_bpmn.models.db import db
from typing import Optional
from flask_bpmn.models.db import db
from spiffworkflow_backend.models.group import GroupModel
from spiffworkflow_backend.services.user_service import UserService

View File

@ -2,12 +2,12 @@
import json
import logging
import re
from flask_bpmn.models.db import db
from typing import Any
from typing import Optional
from flask import g
from flask.app import Flask
from flask_bpmn.models.db import db
from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel

View File

@ -1,8 +1,8 @@
"""Message_service."""
from flask_bpmn.models.db import db
from typing import Any
from typing import Optional
from flask_bpmn.models.db import db
from sqlalchemy import and_
from sqlalchemy import or_
from sqlalchemy import select

View File

@ -8,8 +8,6 @@ import re
import time
from datetime import datetime
from datetime import timedelta
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from typing import Any
from typing import Callable
from typing import Dict
@ -23,6 +21,8 @@ from typing import Union
import dateparser
import pytz
from flask import current_app
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from lxml import etree # type: ignore
from RestrictedPython import safe_globals # type: ignore
from SpiffWorkflow.bpmn.exceptions import WorkflowTaskExecException # type: ignore
@ -192,11 +192,11 @@ class CustomBpmnScriptEngine(PythonScriptEngine): # type: ignore
return self._evaluate(expression, task.data, task, external_methods)
def _evaluate(
self,
expression: str,
context: Dict[str, Union[Box, str]],
task: Optional[SpiffTask] = None,
external_methods: Optional[Dict[str, Any]] = None,
self,
expression: str,
context: Dict[str, Union[Box, str]],
task: Optional[SpiffTask] = None,
external_methods: Optional[Dict[str, Any]] = None,
) -> Any:
"""_evaluate."""
methods = self.__get_augment_methods(task)
@ -220,7 +220,7 @@ class CustomBpmnScriptEngine(PythonScriptEngine): # type: ignore
) from exception
def execute(
self, task: SpiffTask, script: str, external_methods: Any = None
self, task: SpiffTask, script: str, external_methods: Any = None
) -> None:
"""Execute."""
try:
@ -234,10 +234,10 @@ class CustomBpmnScriptEngine(PythonScriptEngine): # type: ignore
raise WorkflowTaskExecException(task, f" {script}, {e}", e) from e
def call_service(
self,
operation_name: str,
operation_params: Dict[str, Any],
task_data: Dict[str, Any],
self,
operation_name: str,
operation_params: Dict[str, Any],
task_data: Dict[str, Any],
) -> Any:
"""CallService."""
return ServiceTaskDelegate.call_connector(
@ -284,7 +284,7 @@ class ProcessInstanceProcessor:
# * 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
def __init__(
self, process_instance_model: ProcessInstanceModel, validate_only: bool = False
self, process_instance_model: ProcessInstanceModel, validate_only: bool = False
) -> None:
"""Create a Workflow Processor based on the serialized information available in the process_instance model."""
tld = current_app.config["THREAD_LOCAL_DATA"]
@ -311,7 +311,7 @@ class ProcessInstanceProcessor:
)
else:
bpmn_json_length = len(process_instance_model.bpmn_json.encode("utf-8"))
megabyte = float(1024 ** 2)
megabyte = float(1024**2)
json_size = bpmn_json_length / megabyte
if json_size > 1:
wf_json = json.loads(process_instance_model.bpmn_json)
@ -325,22 +325,22 @@ class ProcessInstanceProcessor:
len(json.dumps(test_spec).encode("utf-8")) / megabyte
)
message = (
"Workflow "
+ process_instance_model.process_model_identifier
+ f" JSON Size is over 1MB:{json_size:.2f} MB"
"Workflow "
+ process_instance_model.process_model_identifier
+ f" JSON Size is over 1MB:{json_size:.2f} MB"
)
message += f"\n Task Size: {task_size}"
message += f"\n Spec Size: {spec_size}"
current_app.logger.warning(message)
def check_sub_specs(
test_spec: dict, indent: int = 0, show_all: bool = False
test_spec: dict, indent: int = 0, show_all: bool = False
) -> None:
"""Check_sub_specs."""
for my_spec_name in test_spec["task_specs"]:
my_spec = test_spec["task_specs"][my_spec_name]
my_spec_size = (
len(json.dumps(my_spec).encode("utf-8")) / megabyte
len(json.dumps(my_spec).encode("utf-8")) / megabyte
)
if my_spec_size > 0.1 or show_all:
current_app.logger.warning(
@ -376,13 +376,13 @@ class ProcessInstanceProcessor:
raise ApiError(
error_code="unexpected_process_instance_structure",
message="Failed to deserialize process_instance"
" '%s' due to a mis-placed or missing task '%s'"
% (self.process_model_identifier, str(ke)),
" '%s' due to a mis-placed or missing task '%s'"
% (self.process_model_identifier, str(ke)),
) from ke
@classmethod
def get_process_model_and_subprocesses(
cls, process_model_identifier: str
cls, process_model_identifier: str
) -> Tuple[BpmnProcessSpec, IdToBpmnProcessSpecMapping]:
"""Get_process_model_and_subprocesses."""
process_model_info = ProcessModelService.get_process_model(
@ -400,7 +400,7 @@ class ProcessInstanceProcessor:
@classmethod
def get_bpmn_process_instance_from_process_model(
cls, process_model_identifier: str
cls, process_model_identifier: str
) -> BpmnWorkflow:
"""Get_all_bpmn_process_identifiers_for_process_model."""
(bpmn_process_spec, subprocesses) = cls.get_process_model_and_subprocesses(
@ -425,7 +425,7 @@ class ProcessInstanceProcessor:
return current_user
def add_user_info_to_process_instance(
self, bpmn_process_instance: BpmnWorkflow
self, bpmn_process_instance: BpmnWorkflow
) -> None:
"""Add_user_info_to_process_instance."""
current_user = self.current_user()
@ -438,8 +438,8 @@ class ProcessInstanceProcessor:
@staticmethod
def get_bpmn_process_instance_from_workflow_spec(
spec: BpmnProcessSpec,
subprocesses: Optional[IdToBpmnProcessSpecMapping] = None,
spec: BpmnProcessSpec,
subprocesses: Optional[IdToBpmnProcessSpecMapping] = None,
) -> BpmnWorkflow:
"""Get_bpmn_process_instance_from_workflow_spec."""
return BpmnWorkflow(
@ -450,10 +450,10 @@ class ProcessInstanceProcessor:
@staticmethod
def __get_bpmn_process_instance(
process_instance_model: ProcessInstanceModel,
spec: Optional[BpmnProcessSpec] = None,
validate_only: bool = False,
subprocesses: Optional[IdToBpmnProcessSpecMapping] = None,
process_instance_model: ProcessInstanceModel,
spec: Optional[BpmnProcessSpec] = None,
validate_only: bool = False,
subprocesses: Optional[IdToBpmnProcessSpecMapping] = None,
) -> BpmnWorkflow:
"""__get_bpmn_process_instance."""
if process_instance_model.bpmn_json:
@ -496,14 +496,14 @@ class ProcessInstanceProcessor:
self.save()
def raise_if_no_potential_owners(
self, potential_owner_ids: list[int], message: str
self, potential_owner_ids: list[int], message: str
) -> None:
"""Raise_if_no_potential_owners."""
if not potential_owner_ids:
raise (NoPotentialOwnersForTaskError(message))
def get_potential_owner_ids_from_task(
self, task: SpiffTask
self, task: SpiffTask
) -> PotentialOwnerIdList:
"""Get_potential_owner_ids_from_task."""
task_spec = task.task_spec
@ -598,7 +598,7 @@ class ProcessInstanceProcessor:
if path_segment in data_for_key:
data_for_key = data_for_key[path_segment]
else:
data_for_key = None
data_for_key = None # type: ignore
break
if data_for_key is not None:
@ -712,7 +712,7 @@ class ProcessInstanceProcessor:
@staticmethod
def backfill_missing_spec_reference_records(
bpmn_process_identifier: str,
bpmn_process_identifier: str,
) -> Optional[str]:
"""Backfill_missing_spec_reference_records."""
process_models = ProcessModelService.get_process_models(recursive=True)
@ -733,7 +733,7 @@ class ProcessInstanceProcessor:
@staticmethod
def bpmn_file_full_path_from_bpmn_process_identifier(
bpmn_process_identifier: str,
bpmn_process_identifier: str,
) -> str:
"""Bpmn_file_full_path_from_bpmn_process_identifier."""
if bpmn_process_identifier is None:
@ -743,8 +743,8 @@ class ProcessInstanceProcessor:
spec_reference = (
SpecReferenceCache.query.filter_by(identifier=bpmn_process_identifier)
.filter_by(type="process")
.first()
.filter_by(type="process")
.first()
)
bpmn_file_full_path = None
if spec_reference is None:
@ -763,15 +763,15 @@ class ProcessInstanceProcessor:
ApiError(
error_code="could_not_find_bpmn_process_identifier",
message="Could not find the the given bpmn process identifier from any sources: %s"
% bpmn_process_identifier,
% bpmn_process_identifier,
)
)
return os.path.abspath(bpmn_file_full_path)
@staticmethod
def update_spiff_parser_with_all_process_dependency_files(
parser: BpmnDmnParser,
processed_identifiers: Optional[set[str]] = None,
parser: BpmnDmnParser,
processed_identifiers: Optional[set[str]] = None,
) -> None:
"""Update_spiff_parser_with_all_process_dependency_files."""
if processed_identifiers is None:
@ -809,7 +809,7 @@ class ProcessInstanceProcessor:
@staticmethod
def get_spec(
files: List[File], process_model_info: ProcessModelInfo
files: List[File], process_model_info: ProcessModelInfo
) -> Tuple[BpmnProcessSpec, IdToBpmnProcessSpecMapping]:
"""Returns a SpiffWorkflow specification for the given process_instance spec, using the files provided."""
parser = ProcessInstanceProcessor.get_parser()
@ -823,14 +823,14 @@ class ProcessInstanceProcessor:
dmn: etree.Element = etree.fromstring(data)
parser.add_dmn_xml(dmn, filename=file.name)
if (
process_model_info.primary_process_id is None
or process_model_info.primary_process_id == ""
process_model_info.primary_process_id is None
or process_model_info.primary_process_id == ""
):
raise (
ApiError(
error_code="no_primary_bpmn_error",
message="There is no primary BPMN process id defined for process_model %s"
% process_model_info.id,
% process_model_info.id,
)
)
ProcessInstanceProcessor.update_spiff_parser_with_all_process_dependency_files(
@ -848,7 +848,7 @@ class ProcessInstanceProcessor:
raise ApiError(
error_code="process_instance_validation_error",
message="Failed to parse the Workflow Specification. "
+ "Error is '%s.'" % str(ve),
+ "Error is '%s.'" % str(ve),
file_name=ve.filename,
task_id=ve.id,
tag=ve.tag,
@ -895,12 +895,12 @@ class ProcessInstanceProcessor:
message_correlations = []
for (
message_correlation_key,
message_correlation_properties,
message_correlation_key,
message_correlation_properties,
) in bpmn_message.correlations.items():
for (
message_correlation_property_identifier,
message_correlation_property_value,
message_correlation_property_identifier,
message_correlation_property_value,
) in message_correlation_properties.items():
message_correlation_property = (
MessageCorrelationPropertyModel.query.filter_by(
@ -992,7 +992,7 @@ class ProcessInstanceProcessor:
db.session.add(message_instance)
for (
spiff_correlation_property
spiff_correlation_property
) in waiting_task.task_spec.event_definition.correlation_properties:
# NOTE: we may have to cycle through keys here
# not sure yet if it's valid for a property to be associated with multiple keys
@ -1002,9 +1002,9 @@ class ProcessInstanceProcessor:
process_instance_id=self.process_instance_model.id,
name=correlation_key_name,
)
.join(MessageCorrelationPropertyModel)
.filter_by(identifier=spiff_correlation_property.name)
.first()
.join(MessageCorrelationPropertyModel)
.filter_by(identifier=spiff_correlation_property.name)
.first()
)
message_correlation_message_instance = (
MessageCorrelationMessageInstanceModel(
@ -1108,12 +1108,12 @@ class ProcessInstanceProcessor:
endtasks = []
if self.bpmn_process_instance.is_completed():
for task in SpiffTask.Iterator(
self.bpmn_process_instance.task_tree, TaskState.ANY_MASK
self.bpmn_process_instance.task_tree, TaskState.ANY_MASK
):
# Assure that we find the end event for this process_instance, and not for any sub-process_instances.
if (
isinstance(task.task_spec, EndEvent)
and task.workflow == self.bpmn_process_instance
isinstance(task.task_spec, EndEvent)
and task.workflow == self.bpmn_process_instance
):
endtasks.append(task)
if len(endtasks) > 0:
@ -1149,8 +1149,8 @@ class ProcessInstanceProcessor:
return task
for task in ready_tasks:
if (
self.bpmn_process_instance.last_task
and task.parent == last_user_task.parent
self.bpmn_process_instance.last_task
and task.parent == last_user_task.parent
):
return task
@ -1160,7 +1160,7 @@ class ProcessInstanceProcessor:
# and return that
next_task = None
for task in SpiffTask.Iterator(
self.bpmn_process_instance.task_tree, TaskState.NOT_FINISHED_MASK
self.bpmn_process_instance.task_tree, TaskState.NOT_FINISHED_MASK
):
next_task = task
return next_task
@ -1244,7 +1244,7 @@ class ProcessInstanceProcessor:
t
for t in all_tasks
if not self.bpmn_process_instance._is_engine_task(t.task_spec)
and t.state in [TaskState.COMPLETED, TaskState.CANCELLED]
and t.state in [TaskState.COMPLETED, TaskState.CANCELLED]
]
def get_all_waiting_tasks(self) -> list[SpiffTask]:
@ -1259,7 +1259,7 @@ class ProcessInstanceProcessor:
@classmethod
def get_task_by_bpmn_identifier(
cls, bpmn_task_identifier: str, bpmn_process_instance: BpmnWorkflow
cls, bpmn_task_identifier: str, bpmn_process_instance: BpmnWorkflow
) -> Optional[SpiffTask]:
"""Get_task_by_id."""
all_tasks = bpmn_process_instance.get_tasks(TaskState.ANY_MASK)

View File

@ -1,11 +1,11 @@
"""Process_instance_service."""
import time
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from typing import Any
from typing import List
from flask import current_app
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from SpiffWorkflow.task import Task as SpiffTask # type: ignore
from spiffworkflow_backend.models.active_task import ActiveTaskModel

View File

@ -2,13 +2,14 @@
import json
import os
import shutil
from flask_bpmn.api.api_error import ApiError
from glob import glob
from typing import Any
from typing import List
from typing import Optional
from typing import TypeVar
from flask_bpmn.api.api_error import ApiError
from spiffworkflow_backend.exceptions.process_entity_not_found_error import (
ProcessEntityNotFoundError,
)

View File

@ -1,7 +1,8 @@
"""Secret_service."""
from typing import Optional
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from typing import Optional
from spiffworkflow_backend.models.secret_model import SecretModel

View File

@ -2,10 +2,10 @@
import os
import shutil
from datetime import datetime
from flask_bpmn.models.db import db
from typing import List
from typing import Optional
from flask_bpmn.models.db import db
from SpiffWorkflow.bpmn.parser.ValidationException import ValidationException # type: ignore
from spiffworkflow_backend.models.file import File

View File

@ -1,11 +1,11 @@
"""User_service."""
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from typing import Any
from typing import Optional
from flask import current_app
from flask import g
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from spiffworkflow_backend.models.active_task import ActiveTaskModel
from spiffworkflow_backend.models.active_task_user import ActiveTaskUserModel

View File

@ -3,14 +3,14 @@ import io
import json
import os
import time
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from typing import Any
from typing import Dict
from typing import Optional
from flask import current_app
from flask.testing import FlaskClient
from flask_bpmn.api.api_error import ApiError
from flask_bpmn.models.db import db
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
from werkzeug.test import TestResponse # type: ignore

View File

@ -3,12 +3,12 @@ import io
import json
import os
import time
from flask_bpmn.models.db import db
from typing import Any
import pytest
from flask.app import Flask
from flask.testing import FlaskClient
from flask_bpmn.models.db import db
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec

View File

@ -1,11 +1,11 @@
"""Test_secret_service."""
import json
from flask_bpmn.api.api_error import ApiError
from typing import Optional
import pytest
from flask.app import Flask
from flask.testing import FlaskClient
from flask_bpmn.api.api_error import ApiError
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from werkzeug.test import TestResponse # type: ignore

View File

@ -1,8 +1,7 @@
"""Test_get_localtime."""
from flask_bpmn.models.db import db
from flask.app import Flask
from flask.testing import FlaskClient
from flask_bpmn.models.db import db
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec

View File

@ -1,9 +1,8 @@
"""Test_message_instance."""
from flask_bpmn.models.db import db
import pytest
from flask import Flask
from flask.testing import FlaskClient
from flask_bpmn.models.db import db
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from spiffworkflow_backend.models.message_instance import MessageInstanceModel

View File

@ -1,8 +1,7 @@
"""Process Model."""
from flask_bpmn.models.db import db
import pytest
from flask.app import Flask
from flask_bpmn.models.db import db
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from spiffworkflow_backend.models.permission_target import (

View File

@ -1,8 +1,7 @@
"""Test Permissions."""
from flask_bpmn.models.db import db
from flask.app import Flask
from flask.testing import FlaskClient
from flask_bpmn.models.db import db
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec

View File

@ -1,8 +1,7 @@
"""Process Model."""
from flask_bpmn.models.db import db
from flask.app import Flask
from flask.testing import FlaskClient
from flask_bpmn.models.db import db
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec

View File

@ -1,9 +1,8 @@
"""Test_various_bpmn_constructs."""
from flask_bpmn.api.api_error import ApiError
import pytest
from flask.app import Flask
from flask.testing import FlaskClient
from flask_bpmn.api.api_error import ApiError
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec

View File

@ -1,10 +1,10 @@
"""Test_message_service."""
import os
from flask_bpmn.models.db import db
import pytest
from flask import Flask
from flask.testing import FlaskClient
from flask_bpmn.models.db import db
from SpiffWorkflow.bpmn.parser.ValidationException import ValidationException # type: ignore
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec

View File

@ -1,8 +1,8 @@
"""Process Model."""
from decimal import Decimal
from flask_bpmn.models.db import db
from flask.app import Flask
from flask_bpmn.models.db import db
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec