From 9c1d759c3682549d12fb853dcfd7a544f281fb83 Mon Sep 17 00:00:00 2001 From: hanshuaikang <1758504262@qq.com> Date: Tue, 29 Aug 2023 17:11:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?bugfix:=20=E4=BF=AE=E5=A4=8D=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E9=A2=84=E8=A7=88=E6=8A=A5=E9=94=99&&=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=89=A7=E8=A1=8C=E6=96=B9=E6=A1=88=E6=9C=AA=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E5=88=B7=E6=96=B0unique=5Fid=E7=9A=84=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gcloud/tasktmpl3/domains/constants.py | 20 ++----------------- .../apis/drf/viewsets/template_scheme.py | 11 ++++++++++ 2 files changed, 13 insertions(+), 18 deletions(-) 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..b50c2508ed 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("data") or instance.name) + self.perform_update(serializer) + return Response(serializer.data) + def destroy(self, request, *args, **kwargs): scheme = self.get_object() From 4cfc5a79e9a95123d204b72dc863ef16d25ef946 Mon Sep 17 00:00:00 2001 From: hanshuaikang <1758504262@qq.com> Date: Tue, 29 Aug 2023 17:23:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?bugfix:=20=E4=BF=AE=E5=A4=8D=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gcloud/template_base/apis/drf/viewsets/template_scheme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcloud/template_base/apis/drf/viewsets/template_scheme.py b/gcloud/template_base/apis/drf/viewsets/template_scheme.py index b50c2508ed..cdeb8b3dea 100644 --- a/gcloud/template_base/apis/drf/viewsets/template_scheme.py +++ b/gcloud/template_base/apis/drf/viewsets/template_scheme.py @@ -274,7 +274,7 @@ def update(self, request, *args, **kwargs): 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("data") or instance.name) + instance.unique_id = "{}-{}".format(template_id, serializer.validated_data.get("name") or instance.name) self.perform_update(serializer) return Response(serializer.data)