Skip to content

Commit

Permalink
optimization: 独立子任务创建是添加由父任务触发的操作记录
Browse files Browse the repository at this point in the history
  • Loading branch information
normal-wls committed Sep 1, 2023
1 parent 4dde792 commit f073625
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions gcloud/contrib/operate_record/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class OperateSource(Enum):

app = _("app 页面")
api = _("api 接口")
parent = _("父任务")

# 模版来源
project = _("项目流程")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@

from gcloud.common_template.models import CommonTemplate
from gcloud.constants import NON_COMMON_TEMPLATE_TYPES, PROJECT
from gcloud.contrib.operate_record.constants import OperateSource, OperateType, RecordType
from gcloud.contrib.operate_record.signal import operate_record_signal
from gcloud.contrib.operate_record.utils import extract_extra_info
from gcloud.core.models import EngineConfig, Project
from gcloud.taskflow3.domains.auto_retry import AutoRetryNodeStrategyCreator
from gcloud.taskflow3.models import TaskCallBackRecord, TaskFlowInstance, TaskFlowRelation, TimeoutNodeConfig
Expand Down Expand Up @@ -192,10 +195,33 @@ def execute(self, data, parent_data):
pipeline_tree=task.pipeline_instance.execution_data,
)

# 记录操作流水
pipeline_constants = pipeline_instance.execution_data.get("constants")
extra_info = extract_extra_info(pipeline_constants)
operate_record_signal.send(
sender=RecordType.task.name,
operator="system",
operate_type=OperateType.create.name,
operate_source=OperateSource.parent.name,
instance_id=task.id,
project_id=task.project_id,
extra_info=extra_info,
)

task.task_action("start", parent_task.executor)
data.set_outputs("task_id", task.id)
data.set_outputs("task_url", task.url)
data.set_outputs("task_name", task.name)

# 记录操作流水
operate_record_signal.send(
sender=RecordType.task.name,
operator="system",
operate_type=OperateType.start.name,
operate_source=OperateSource.parent.name,
instance_id=task.id,
project_id=task.project_id,
)
return True

def schedule(self, data, parent_data, callback_data=None):
Expand Down

0 comments on commit f073625

Please sign in to comment.