run_pyl (part 2)

This commit is contained in:
Dan 2023-02-23 15:09:22 -05:00
parent 8466d823c2
commit 0d468a825a
6 changed files with 889 additions and 1014 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
"""__init__.""" """__init__."""
import faulthandler import faulthandler
import sys
import os import os
import sys
from typing import Any from typing import Any
import connexion # type: ignore import connexion # type: ignore

View File

@ -105,7 +105,7 @@ class MessageInstanceModel(SpiffworkflowBaseDBModel):
return False return False
return True return True
elif other_message_instance.message_type == MessageTypes.receive.value: elif other_message_instance.message_type == MessageTypes.receive.value:
return other_message_instance.correlates(self, expression_engine) return other_message_instance.correlates(self, expression_engine) # type: ignore
return False return False

View File

@ -30,7 +30,7 @@ class MessageInstanceCorrelationModel(SpiffworkflowBaseDBModel):
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
message_instance_id = db.Column( message_instance_id = db.Column(
ForeignKey(MessageInstanceModel.id), nullable=False, index=True ForeignKey(MessageInstanceModel.id), nullable=False, index=True # type: ignore
) )
name: str = db.Column(db.String(50), nullable=False) name: str = db.Column(db.String(50), nullable=False)
expected_value: str = db.Column(db.String(255), nullable=True, index=True) expected_value: str = db.Column(db.String(255), nullable=True, index=True)

View File

@ -44,7 +44,7 @@ class MessageService:
available_receive_messages = MessageInstanceModel.query.filter_by( available_receive_messages = MessageInstanceModel.query.filter_by(
name=message_instance_send.name, status=MessageStatuses.ready.value name=message_instance_send.name, status=MessageStatuses.ready.value
).all() ).all()
message_instance_receive = None message_instance_receive: MessageInstanceModel | None = None
try: try:
for message_instance in available_receive_messages: for message_instance in available_receive_messages:
if message_instance.correlates( if message_instance.correlates(
@ -84,7 +84,7 @@ class MessageService:
message_instance_send.status = "ready" message_instance_send.status = "ready"
db.session.add(message_instance_send) db.session.add(message_instance_send)
db.session.commit() db.session.commit()
return return None
# Set the receiving message to running, so it is not altered elswhere ... # Set the receiving message to running, so it is not altered elswhere ...
message_instance_receive.status = "running" message_instance_receive.status = "running"
@ -145,9 +145,11 @@ class MessageService:
message_instance_receive: MessageInstanceModel, message_instance_receive: MessageInstanceModel,
) -> ProcessInstanceModel: ) -> ProcessInstanceModel:
"""Process_message_receive.""" """Process_message_receive."""
process_instance_receive = ProcessInstanceModel.query.filter_by( process_instance_receive: ProcessInstanceModel = (
ProcessInstanceModel.query.filter_by(
id=message_instance_receive.process_instance_id id=message_instance_receive.process_instance_id
).first() ).first()
)
if process_instance_receive is None: if process_instance_receive is None:
raise MessageServiceError( raise MessageServiceError(
( (

View File

@ -771,7 +771,7 @@ class ProcessInstanceProcessor:
Rerturns: {process_name: [task_1, task_2, ...], ...} Rerturns: {process_name: [task_1, task_2, ...], ...}
""" """
bpmn_json = json.loads(self.process_instance_model.bpmn_json or '{}') bpmn_json = json.loads(self.process_instance_model.bpmn_json or "{}")
processes: dict[str, list[str]] = {bpmn_json["spec"]["name"]: []} processes: dict[str, list[str]] = {bpmn_json["spec"]["name"]: []}
for task_name, _task_spec in bpmn_json["spec"]["task_specs"].items(): for task_name, _task_spec in bpmn_json["spec"]["task_specs"].items():
processes[bpmn_json["spec"]["name"]].append(task_name) processes[bpmn_json["spec"]["name"]].append(task_name)
@ -843,7 +843,7 @@ class ProcessInstanceProcessor:
Also note that subprocess_task_id might in fact be a call activity, because spiff treats Also note that subprocess_task_id might in fact be a call activity, because spiff treats
call activities like subprocesses in terms of the serialization. call activities like subprocesses in terms of the serialization.
""" """
bpmn_json = json.loads(self.process_instance_model.bpmn_json or '{}') bpmn_json = json.loads(self.process_instance_model.bpmn_json or "{}")
spiff_task_json = self.get_all_task_specs(bpmn_json) spiff_task_json = self.get_all_task_specs(bpmn_json)
subprocesses_by_child_task_ids = {} subprocesses_by_child_task_ids = {}
@ -1480,7 +1480,7 @@ class ProcessInstanceProcessor:
spiff_logger = logging.getLogger("spiff") spiff_logger = logging.getLogger("spiff")
for handler in spiff_logger.handlers: for handler in spiff_logger.handlers:
if hasattr(handler, "bulk_insert_logs"): if hasattr(handler, "bulk_insert_logs"):
handler.bulk_insert_logs() handler.bulk_insert_logs() # type: ignore
db.session.commit() db.session.commit()
if save: if save: