-
Notifications
You must be signed in to change notification settings - Fork 18
feat: 添加constant协议转换 #184 #216
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
Open
guohelu
wants to merge
7
commits into
TencentBlueKing:feat_new_pipeline_tree_converters_develop
Choose a base branch
from
guohelu:feat_new_pipeline_tree_converters_develop_20250508
base: feat_new_pipeline_tree_converters_develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b8d445a
feat: 添加constant协议转换 #184
guohelu ccf3408
feat: 添加数据检验 #184
guohelu e809369
fix: 删除extra_info参数 #184
guohelu 9deeb00
fix: 修复代码逻辑问题 #184
guohelu b2d6771
fix: 补充自定义变量类型校验 #184
guohelu f4204ca
fix: 模型字段结构优化 #184
guohelu d7c549f
fix: 字段拼写错误修复 #184
guohelu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
bkflow/pipeline_converter/converters/data_model_to_web_pipeline/constant.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,85 @@ | ||
| # -*- coding: utf-8 -*- | ||
| from bkflow.pipeline_converter.constants import ConstantTypes | ||
| from bkflow.pipeline_converter.converters.base import DataModelToPipelineTreeConverter | ||
| from bkflow.pipeline_converter.validators.constant import ( | ||
| ComponentInputValidator, | ||
| ConstantValidator, | ||
| ) | ||
| from bkflow.pipeline_converter.validators.node import NodeTypeValidator | ||
|
|
||
|
|
||
| class SourceInfoConverter(DataModelToPipelineTreeConverter): | ||
| def convert(self): | ||
| self.target_data = {} | ||
| for info in self.source_data: | ||
| self.target_data[info.key] = [info.value] | ||
| return self.target_data | ||
|
|
||
|
|
||
| class CustomConstantConverter(DataModelToPipelineTreeConverter): | ||
| validators = [NodeTypeValidator(ConstantTypes.CUSTOM_CONSTANT.value), ConstantValidator()] | ||
|
|
||
| def convert(self): | ||
| converter_data = self.source_data | ||
| self.target_data = { | ||
| "name": converter_data.name, | ||
| "key": f"${{{converter_data.key}}}", | ||
| "desc": converter_data.desc, | ||
| "value": converter_data.value, | ||
| "custom_type": converter_data.custom_type, | ||
| "show_type": converter_data.show_type, | ||
| "source_tag": converter_data.source_tag, | ||
| "source_type": ConstantTypes.CUSTOM_CONSTANT.value, | ||
| "source_info": SourceInfoConverter(converter_data.source_info).convert(), | ||
| "validation": converter_data.validation, | ||
| "version": converter_data.version, | ||
| "pre_render_make": False, | ||
guohelu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "is_meta": converter_data.is_meta, | ||
| } | ||
|
|
||
| return self.target_data | ||
|
|
||
|
|
||
| class ComponentInputConverter(DataModelToPipelineTreeConverter): | ||
| validators = [NodeTypeValidator(ConstantTypes.COMPONENT_INPUTS_CONSTANT.value), ComponentInputValidator()] | ||
|
|
||
| def convert(self): | ||
| converter_data = self.source_data | ||
| self.target_data = { | ||
| "name": converter_data.name, | ||
| "key": f"${{{converter_data.key}}}", | ||
| "desc": converter_data.desc, | ||
| "value": [converter_data.value], | ||
| "custom_type": converter_data.custom_type, | ||
| "show_type": converter_data.show_type, | ||
| "source_tag": converter_data.source_tag, | ||
| "source_type": ConstantTypes.COMPONENT_INPUTS_CONSTANT.value, | ||
| "source_info": SourceInfoConverter(converter_data.source_info).convert(), | ||
| "validation": converter_data.validation, | ||
| "version": converter_data.version, | ||
| "plugin_code": converter_data.plugin_code, | ||
| "extra_info": converter_data.extra_info, | ||
| } | ||
| return self.target_data | ||
|
|
||
|
|
||
| class ComponentOutputConverter(DataModelToPipelineTreeConverter): | ||
| validators = [NodeTypeValidator(ConstantTypes.COMPONENT_OUTPUTS_CONSTANT.value)] | ||
|
|
||
| def convert(self): | ||
| converter_data = self.source_data | ||
| self.target_data = { | ||
| "name": converter_data.name, | ||
| "key": f"${{{converter_data.key}}}", | ||
| "desc": converter_data.desc, | ||
| "value": converter_data.value, | ||
| "custom_type": converter_data.custom_type, | ||
| "show_type": converter_data.show_type, | ||
| "source_tag": converter_data.source_tag, | ||
| "source_type": ConstantTypes.COMPONENT_OUTPUTS_CONSTANT.value, | ||
| "source_info": SourceInfoConverter(converter_data.source_info).convert(), | ||
| "validation": converter_data.validation, | ||
| "plugin_code": converter_data.plugin_code, | ||
| "extra_info": converter_data.extra_info, | ||
| } | ||
| return self.target_data | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
bkflow/pipeline_converter/converters/json_to_data_model/constant.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,93 @@ | ||
| # -*- coding: utf-8 -*- | ||
| from bkflow.pipeline_converter.constants import ConstantTypes | ||
| from bkflow.pipeline_converter.converters.base import JsonToDataModelConverter | ||
| from bkflow.pipeline_converter.data_models import ( | ||
| ComponentInputConstant, | ||
| ComponentOutConstant, | ||
| CustomConstant, | ||
| SourceInfo, | ||
| ) | ||
| from bkflow.pipeline_converter.validators.constant import ( | ||
| JsonComponentInputValidator, | ||
| JsonConstantValidator, | ||
| ) | ||
| from bkflow.pipeline_converter.validators.node import JsonNodeTypeValidator | ||
|
|
||
|
|
||
| class SourceInfoConverter(JsonToDataModelConverter): | ||
| def convert(self): | ||
| self.target_data = [] | ||
| for info in self.source_data: | ||
| info_data = SourceInfo(key=info["key"], value=info["value"]) | ||
| self.target_data.append(info_data) | ||
| return self.target_data | ||
|
|
||
|
|
||
| class CustomConstantConverter(JsonToDataModelConverter): | ||
| validators = [JsonNodeTypeValidator(ConstantTypes.CUSTOM_CONSTANT.value), JsonConstantValidator()] | ||
|
|
||
| def convert(self): | ||
| self.target_data = CustomConstant( | ||
| name=self.source_data["name"], | ||
| type=ConstantTypes.CUSTOM_CONSTANT.value, | ||
| key=self.source_data["key"], | ||
| value=self.source_data["value"], | ||
| custom_type=self.source_data["custom_type"], | ||
| source_tag=self.source_data["source_tag"], | ||
| pre_render_make=False, | ||
| source_info=SourceInfoConverter(self.source_data["source_info"]).convert(), | ||
| ) | ||
| default_optional_field = ["desc", "source_info", "validation", "is_meta", "version", "show_type"] | ||
| for field in default_optional_field: | ||
| if field not in self.source_data: | ||
| continue | ||
| setattr(self.target_data, field, self.source_data[field]) | ||
|
|
||
| return self.target_data | ||
|
|
||
|
|
||
| class ComponentInputConverter(JsonToDataModelConverter): | ||
| validators = [JsonNodeTypeValidator(ConstantTypes.COMPONENT_INPUTS_CONSTANT.value), JsonComponentInputValidator()] | ||
|
|
||
| def convert(self): | ||
| self.target_data = ComponentInputConstant( | ||
| name=self.source_data["name"], | ||
| key=self.source_data["key"], | ||
| value=self.source_data["value"], | ||
| custom_type=self.source_data["custom_type"], | ||
| source_tag=self.source_data["source_tag"], | ||
| type=ConstantTypes.COMPONENT_INPUTS_CONSTANT.value, | ||
| source_info=SourceInfoConverter(self.source_data["source_info"]).convert(), | ||
| version=self.source_data["version"], | ||
| extra_info=self.source_data["extra_info"], | ||
| ) | ||
| default_optional_field = ["desc", "validation", "version", "show_type", "plugin_code"] | ||
| for field in default_optional_field: | ||
| if field not in self.source_data: | ||
| continue | ||
| setattr(self.target_data, field, self.source_data[field]) | ||
|
|
||
| return self.target_data | ||
|
|
||
|
|
||
| class ComponentOutputConverter(JsonToDataModelConverter): | ||
| validators = [JsonNodeTypeValidator(ConstantTypes.COMPONENT_OUTPUTS_CONSTANT.value)] | ||
|
|
||
| def convert(self): | ||
| self.target_data = ComponentOutConstant( | ||
| name=self.source_data["name"], | ||
| key=self.source_data["key"], | ||
| value=self.source_data["value"], | ||
| custom_type=self.source_data["custom_type"], | ||
| source_tag=self.source_data["source_tag"], | ||
| type=ConstantTypes.COMPONENT_OUTPUTS_CONSTANT.value, | ||
| source_info=SourceInfoConverter(self.source_data["source_info"]).convert(), | ||
| extra_info=self.source_data["extra_info"], | ||
| ) | ||
| default_optional_field = ["desc", "validation", "show_type", "plugin_code"] | ||
| for field in default_optional_field: | ||
| if field not in self.source_data: | ||
| continue | ||
| setattr(self.target_data, field, self.source_data[field]) | ||
|
|
||
| return self.target_data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.