71 lines
2.0 KiB
Python
71 lines
2.0 KiB
Python
import logging
|
|
import pprint
|
|
from rich.progress import track
|
|
from rich.console import Console
|
|
|
|
from core.runtime.managefailure import manageFailure
|
|
from core.runtime.stopsignals import checkDependency
|
|
from core.execution.processregistry import registerProcess
|
|
from core.console import console
|
|
|
|
outputs = {}
|
|
|
|
def buildOperation(definition, outputs):
|
|
process_log = True
|
|
|
|
from core.execution.executioncontract import executeContract
|
|
|
|
actions = definition.actions
|
|
registerProcess(definition, outputs)
|
|
responses = []
|
|
|
|
if getattr(definition, "track", False):
|
|
actions = track(
|
|
actions,
|
|
description=f"[green]{definition.name}[/green]",
|
|
console=console
|
|
)
|
|
|
|
for action in actions:
|
|
|
|
stop = checkDependency(action, outputs, definition)
|
|
|
|
if stop:
|
|
continue
|
|
|
|
if action.kind == "action":
|
|
outputs["processes"][definition.name][action.name] = {}
|
|
|
|
outputs, response = executeContract(action, outputs, definition)
|
|
|
|
responses.append(response)
|
|
|
|
if action.kind == "action":
|
|
outputs["processes"][definition.name][action.name]["response"] = response
|
|
|
|
##Append completed process to process registry
|
|
outputs["processes"][definition.name]["completed"].append(action.alias)
|
|
|
|
#Temporarily disabled manageFailure functions
|
|
#except Exception as error:
|
|
#outputs = manageFailure(error, action, outputs)
|
|
|
|
#Print completion status after runtime processes
|
|
if process_log:
|
|
stopsignal_count = len(outputs["processes"][definition.name]["stopsignals"])
|
|
completed_count = len(outputs["processes"][definition.name]["completed"])
|
|
|
|
if completed_count == 1 and stopsignal_count == 1:
|
|
logging.info(f"{definition.name} bypassed")
|
|
else:
|
|
logging.info(f"{definition.name} completed")
|
|
|
|
#For debugging purposes only
|
|
process_registry_logs = False
|
|
if process_registry_logs:
|
|
pprint.pprint(outputs["processes"])
|
|
|
|
|
|
|
|
return responses
|