72 lines
1.8 KiB
Python
72 lines
1.8 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 import processregistry
|
|
from core.console import console
|
|
|
|
#outputs = {}
|
|
|
|
def buildOperation(definition, outputs):
|
|
process_log = True
|
|
|
|
from core.execution.executioncontract import executeContract
|
|
|
|
actions = definition.actions
|
|
currentOp = processregistry.registerProcess(definition)
|
|
|
|
responses = []
|
|
|
|
if getattr(definition, "track", False):
|
|
actions = track(
|
|
actions,
|
|
description=f"[green]{definition.name}[/green]",
|
|
console=console
|
|
)
|
|
|
|
for action in actions:
|
|
processregistry.registeredOp = currentOp
|
|
|
|
stop = checkDependency(action)
|
|
|
|
if stop:
|
|
continue
|
|
|
|
if action.kind == "action":
|
|
currentOp[action.name] = {}
|
|
|
|
response = executeContract(action, outputs)
|
|
|
|
responses.append(response)
|
|
|
|
if action.kind == "action":
|
|
currentOp[action.name]["response"] = response
|
|
|
|
if action.alias in currentOp["stopsignals"]:
|
|
continue
|
|
currentOp["completed"].append(action.alias)
|
|
|
|
#Temporarily disabled manageFailure functions
|
|
#except Exception as error:
|
|
#outputs = manageFailure(error, action, outputs)
|
|
|
|
if process_log:
|
|
completed_count = len(currentOp["completed"])
|
|
|
|
if completed_count == 0:
|
|
logging.info(f"{definition.name} bypassed")
|
|
else:
|
|
logging.info(f"{definition.name} completed")
|
|
|
|
|
|
process_registry_logs = False
|
|
|
|
if process_registry_logs:
|
|
import pprint
|
|
pprint.pprint(processregistry.processes)
|
|
|
|
return responses
|