diff --git a/gcloud/tasktmpl3/domains/constants.py b/gcloud/tasktmpl3/domains/constants.py index ea70952d2f..4b73d75a13 100644 --- a/gcloud/tasktmpl3/domains/constants.py +++ b/gcloud/tasktmpl3/domains/constants.py @@ -114,6 +114,7 @@ def get_need_render_context_keys(): return keys need_render_context_keys = get_need_render_context_keys() + context_values = [ ContextValue(key=key, type=VAR_CONTEXT_MAPPING[info["type"]], value=info["value"], code=info.get("custom_type")) for key, info in list(pipeline["data"].get("inputs", {}).items()) + list(parent_params.items()) @@ -131,24 +132,7 @@ def get_need_render_context_keys(): param_data = {key: info["value"] for key, info in pipeline["activities"][subprocess]["params"].items()} # 获取子流程的参数 hydrated_param_data = Template(param_data).render(parent_hydrated_context) - child_inputs = child_pipeline.get("data").get("inputs") - # 需要提前渲染好子流程参数的值 - subprocess_context_values = [ - ContextValue( - key=key, - type=VAR_CONTEXT_MAPPING[child_inputs.get(key)["type"]], - value=value, - code=child_inputs.get(key).get("custom_type"), - ) - for key, value in hydrated_param_data.items() - ] - - subprocess_context = Context(runtime, subprocess_context_values, root_pipeline_data) - subprocess_hydrated_context = subprocess_context.hydrate(deformat=True) - # 此时已经准备好了子流程所有的输出,到下一层递归时,由于parent_params在inputs之后被处理,所以parent_params会更新最终的值 - formatted_param_data = { - "${" + key + "}": {"value": value, "type": "plain"} for key, value in subprocess_hydrated_context.items() - } + formatted_param_data = {key: {"value": value, "type": "plain"} for key, value in hydrated_param_data.items()} return preview_node_inputs( runtime=runtime, diff --git a/gcloud/template_base/apis/drf/viewsets/template_scheme.py b/gcloud/template_base/apis/drf/viewsets/template_scheme.py index ef16b5ff2e..cdeb8b3dea 100644 --- a/gcloud/template_base/apis/drf/viewsets/template_scheme.py +++ b/gcloud/template_base/apis/drf/viewsets/template_scheme.py @@ -267,6 +267,17 @@ def create(self, request, *args, **kwargs): return Response(serializer.data, status=status.HTTP_201_CREATED) + def update(self, request, *args, **kwargs): + partial = kwargs.pop("partial", False) + instance = self.get_object() + template_id = instance.unique_id.split("-")[0] + serializer = self.get_serializer(instance, data=request.data, partial=partial) + serializer.is_valid(raise_exception=True) + # 防止用户不传name + instance.unique_id = "{}-{}".format(template_id, serializer.validated_data.get("name") or instance.name) + self.perform_update(serializer) + return Response(serializer.data) + def destroy(self, request, *args, **kwargs): scheme = self.get_object()