Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: 修复节点预览报错&&更新执行方案未正确刷新unique_id的值 #7027

Merged
merged 2 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions gcloud/tasktmpl3/domains/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions gcloud/template_base/apis/drf/viewsets/template_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading