Skip to content

Commit

Permalink
minor: merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshuaikang committed Dec 5, 2023
2 parents 94efa96 + ec4a2a9 commit eb72afe
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 24 deletions.
12 changes: 11 additions & 1 deletion bamboo_engine/eri/models/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def __init__(
conditions: List[Condition],
converge_gateway_id: str,
default_condition: DefaultCondition = None,
extra_info: dict = None,
*args,
**kwargs
):
Expand All @@ -180,14 +181,22 @@ def __init__(
self.conditions = conditions
self.default_condition = default_condition
self.converge_gateway_id = converge_gateway_id
self.extra_info = extra_info or {}


class ExclusiveGateway(Node):
"""
分支网关
"""

def __init__(self, conditions: List[Condition], default_condition: DefaultCondition = None, *args, **kwargs):
def __init__(
self,
conditions: List[Condition],
default_condition: DefaultCondition = None,
extra_info: dict = None,
*args,
**kwargs
):
"""
:param conditions: 分支条件
Expand All @@ -198,6 +207,7 @@ def __init__(self, conditions: List[Condition], default_condition: DefaultCondit
super().__init__(*args, **kwargs)
self.conditions = conditions
self.default_condition = default_condition
self.extra_info = extra_info or {}


class ServiceActivity(Node):
Expand Down
2 changes: 1 addition & 1 deletion bamboo_engine/handlers/conditional_parallel_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def execute(

try:
expr_func = self.runtime.get_config(RuntimeSettings.PIPELINE_EXCLUSIVE_GATEWAY_EXPR_FUNC.value)
result = expr_func(resolved_evaluate, hydrated_context)
result = expr_func(resolved_evaluate, hydrated_context, extra_info=self.node.extra_info)
logger.info(
"root_pipeline[%s] node(%s) %s test result: %s",
root_pipeline_id,
Expand Down
9 changes: 7 additions & 2 deletions bamboo_engine/handlers/exclusive_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def execute(
)
try:
expr_func = self.runtime.get_config(RuntimeSettings.PIPELINE_EXCLUSIVE_GATEWAY_EXPR_FUNC.value)
result = expr_func(resolved_evaluate, hydrated_context)
result = expr_func(resolved_evaluate, hydrated_context, extra_info=self.node.extra_info)
logger.info(
"root_pipeline[%s] node(%s) %s test result: %s",
root_pipeline_id,
Expand All @@ -124,7 +124,12 @@ def execute(
result,
)

strategy = self.runtime.get_config(RuntimeSettings.PIPELINE_EXCLUSIVE_GATEWAY_STRATEGY.value)
if isinstance(self.node.extra_info, dict) and self.node.extra_info.get("strategy") in [
s.name for s in ExclusiveGatewayStrategy
]:
strategy = self.node.extra_info["strategy"]
else:
strategy = self.runtime.get_config(RuntimeSettings.PIPELINE_EXCLUSIVE_GATEWAY_STRATEGY.value)
# 如果策略是命中第一个,并且result为true, 则直接结束循环
if strategy == ExclusiveGatewayStrategy.FIRST.value and result:
meet_conditions.append(c.name)
Expand Down
2 changes: 1 addition & 1 deletion bamboo_engine/utils/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from bamboo_engine.utils.boolrule import BoolRule


def default_expr_func(expr: str, context: dict) -> bool:
def default_expr_func(expr: str, context: dict, extra_info: dict, *args, **kwargs) -> bool:
return BoolRule(expr).test()

This file was deleted.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@
<!DOCTYPE html>
<html>
<head>
<link rel="icon" href="/static/images/favicon.ico" type="image/x-icon" />
<meta charset="utf-8">
<title> bamboo-engine-admin-frontend </title>
<link href="{% static 'engine_admin/css/app.903f13e.css' %}" rel="stylesheet"></head>
<link href="{% static 'engine_admin/css/app.fb328ae.css' %}" rel="stylesheet"></head>
<body>
<div id="app"></div>
<script>
var SITE_URL = '{{SITE_URL}}'
var BK_STATIC_URL = '{{BK_STATIC_URL}}/'
var REMOTE_STATIC_URL = ''
var APP_CODE = '{{APP_CODE}}'
</script>
<script>
var pathname = window.location.pathname
var SITE_URL = pathname.endsWith('/') ? pathname : pathname + '/'
function getCookie(name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
return (arr = document.cookie.match(reg)) ? unescape(arr[2]) : null;
}
</script>
<script type="text/javascript" src="{% static 'engine_admin/js/runtime.114327c.js' %}"></script><script type="text/javascript" src="{% static 'engine_admin/js/vue-lib.ac90813.js' %}"></script><script type="text/javascript" src="{% static 'engine_admin/js/app.442a902.js' %}"></script></body>
<script type="text/javascript" src="{% static 'engine_admin/js/runtime.114327c.js' %}"></script><script type="text/javascript" src="{% static 'engine_admin/js/vue-lib.3bbf677.js' %}"></script><script type="text/javascript" src="{% static 'engine_admin/js/app.b8f6f33.js' %}"></script></body>
</html>
2 changes: 1 addition & 1 deletion runtime/bamboo-pipeline/pipeline/eri/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def ready(self):
pipeline_exclusive_gateway_expr_func_text = getattr(
settings, "PIPELINE_EXCLUSIVE_GATEWAY_EXPR_FUNC_TEXT", "1==1"
)
check_result = pipeline_exclusive_gateway_expr_func(pipeline_exclusive_gateway_expr_func_text, {})
check_result = pipeline_exclusive_gateway_expr_func(pipeline_exclusive_gateway_expr_func_text, {}, {})
if not check_result:
raise ConfigValidationError("config validate error, the expr func return False")

Expand Down
2 changes: 2 additions & 0 deletions runtime/bamboo-pipeline/pipeline/eri/imp/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def _get_node(self, node: DBNode):
type=NodeType.ExclusiveGateway,
conditions=[Condition(**c) for c in node_detail["conditions"]],
default_condition=DefaultCondition(**default_condition) if default_condition else None,
extra_info=node_detail.get("extra_info"),
**common_args
)

Expand All @@ -84,6 +85,7 @@ def _get_node(self, node: DBNode):
converge_gateway_id=node_detail["converge_gateway_id"],
conditions=[Condition(**c) for c in node_detail["conditions"]],
default_condition=DefaultCondition(**default_condition) if default_condition else None,
extra_info=node_detail.get("extra_info"),
**common_args
)

Expand Down
4 changes: 4 additions & 0 deletions runtime/bamboo-pipeline/pipeline/eri/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ def _gen_gateway_node(self, gateway: dict, pipeline: dict, root_id: str, parent_
if default_condition
else None
)
if gateway.get("extra_info"):
detail["extra_info"] = gateway["extra_info"]
elif gateway["type"] == NodeType.ParallelGateway.value:
detail["converge_gateway_id"] = gateway["converge_gateway_id"]

Expand All @@ -216,6 +218,8 @@ def _gen_gateway_node(self, gateway: dict, pipeline: dict, root_id: str, parent_
if default_condition
else None
)
if gateway.get("extra_info"):
detail["extra_info"] = gateway["extra_info"]
detail["converge_gateway_id"] = gateway["converge_gateway_id"]
elif gateway["type"] == NodeType.ConvergeGateway.value:
pass
Expand Down

0 comments on commit eb72afe

Please sign in to comment.