From c94c968b87370ba2d3ae96d1ec08035a9171e4c0 Mon Sep 17 00:00:00 2001 From: hanshuaikang <1758504262@qq.com> Date: Thu, 31 Aug 2023 21:39:26 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E5=8F=AA=E4=BC=98=E5=8C=96=E6=99=AE?= =?UTF-8?q?=E9=80=9A=E8=8A=82=E7=82=B9=E7=9A=84=E5=8A=A0=E8=BD=BD=E9=80=9F?= =?UTF-8?q?=E5=BA=A6&=E6=94=AF=E6=8C=81=E7=8B=AC=E7=AB=8B=E5=AD=90?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=8F=82=E6=95=B0=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gcloud/tasktmpl3/domains/constants.py | 51 ++++++++++++--------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/gcloud/tasktmpl3/domains/constants.py b/gcloud/tasktmpl3/domains/constants.py index 4b73d75a13..3913770074 100644 --- a/gcloud/tasktmpl3/domains/constants.py +++ b/gcloud/tasktmpl3/domains/constants.py @@ -85,35 +85,23 @@ def preview_node_inputs( def get_need_render_context_keys(): keys = set() # 如果遇到子流程,到最后一层才会实际去解析需要渲染的变量 - if subprocess_stack: - subprocess = subprocess_stack[0] - param_data = {key: info["value"] for key, info in pipeline["activities"][subprocess]["params"].items()} - for value in param_data.values(): - if isinstance(value, str): - for value in var_pattern.findall(value): - keys.add("${" + value + "}") - return keys - node_info = pipeline["activities"][node_id] + inputs_values = node_info.get("component", {}).get("inputs", {}).values() + for item in inputs_values: + if not item["need_render"]: + continue + if isinstance(item["value"], str): + for value in var_pattern.findall(item["value"]): + keys.add("${" + value + "}") + return keys - if node_info["type"] == "SubProcess": - inputs_values = node_info.get("pipeline", {}).get("data", {}).get("inputs").values() - for item in inputs_values: - if isinstance(item["value"], str): - for value in var_pattern.findall(item["value"]): - keys.add("${" + value + "}") - return keys - else: - inputs_values = node_info.get("component", {}).get("inputs", {}).values() - for item in inputs_values: - if not item["need_render"]: - continue - if isinstance(item["value"], str): - for value in var_pattern.findall(item["value"]): - keys.add("${" + value + "}") - return keys - - need_render_context_keys = get_need_render_context_keys() + node_type = pipeline["activities"][node_id]["type"] + node_code = pipeline["activities"][node_id].get("component", {}).get("code") + # 只优化普通节点的渲染过程 + if node_type == NodeType.ServiceActivity.value and node_code != "subprocess_plugin": + need_render_context_keys = get_need_render_context_keys() + else: + need_render_context_keys = list(pipeline["data"].get("inputs", {}).keys()) + list(parent_params.keys()) context_values = [ ContextValue(key=key, type=VAR_CONTEXT_MAPPING[info["type"]], value=info["value"], code=info.get("custom_type")) @@ -143,9 +131,14 @@ def get_need_render_context_keys(): parent_params=formatted_param_data, ) - node_type = pipeline["activities"][node_id]["type"] if node_type == NodeType.ServiceActivity.value: - raw_inputs = pipeline["activities"][node_id]["component"]["inputs"] + # 如果是独立子流程 + if node_code == "subprocess_plugin": + raw_inputs = pipeline["activities"][node_id]["component"]["inputs"]["subprocess"]["value"]["pipeline"][ + "constants" + ] + else: + raw_inputs = pipeline["activities"][node_id]["component"]["inputs"] elif node_type == NodeType.SubProcess.value: raw_inputs = pipeline["activities"][node_id]["params"] else: