88 lines
2.2 KiB
Python
88 lines
2.2 KiB
Python
import logging
|
|
import os
|
|
|
|
from core.runtime.stopsignals import checkDependency
|
|
from core.execution import processregistry
|
|
from rich.progress import track
|
|
from core.console import console
|
|
|
|
def buildRecursive(definition, outputs):
|
|
process_log = True
|
|
recursive_log = os.environ.get("LOGS_RECURSIVE", "false").lower() == "true"
|
|
|
|
source = outputs.get(definition.recursiveset["source"])
|
|
|
|
if source is None or source == []:
|
|
if recursive_log:
|
|
logging.debug(f"No items available in {source} for {definition.name}")
|
|
return outputs, []
|
|
|
|
currentOp = processregistry.registerProcess(definition)
|
|
|
|
responses = []
|
|
|
|
recursiveset = definition.recursiveset["actions"]
|
|
|
|
source = definition.recursiveset["source"]
|
|
|
|
items = outputs.get(source)
|
|
|
|
reverse = definition.recursiveset.get("reverse", False)
|
|
|
|
if reverse:
|
|
items = reversed(items)
|
|
|
|
for item in track(
|
|
items,
|
|
description=f"[green]{definition.name}[/green]",
|
|
console=console
|
|
):
|
|
|
|
#for item in items:
|
|
outputs[definition.recursiveset["outputlabel"]] = item
|
|
|
|
outputs["stopsignals"] = []
|
|
for job in recursiveset:
|
|
processregistry.registeredOp = currentOp
|
|
|
|
stop = checkDependency(job)
|
|
|
|
if stop:
|
|
continue
|
|
|
|
if job.kind == "action":
|
|
currentOp[job.name] = {}
|
|
|
|
from core.execution.executioncontract import executeContract
|
|
|
|
response = executeContract(job)
|
|
responses.append(response)
|
|
|
|
if job.kind == "action":
|
|
currentOp[job.name]["response"] = response
|
|
|
|
currentOp["completed"].append(job.alias)
|
|
|
|
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")
|
|
|
|
retain = definition.recursiveset.get("retain", True)
|
|
|
|
if not retain:
|
|
outputs.pop(source, None)
|
|
|
|
outputs.pop("stopsignals", None)
|
|
|
|
process_registry_logs = False
|
|
|
|
if process_registry_logs:
|
|
import pprint
|
|
pprint.pprint(processregistry.processes)
|
|
|
|
return responses
|