Workflow execution method and device based on directed acyclic graph, and electronic device

By dynamically planning the target execution path between task nodes in the workflow execution of a directed acyclic graph (DAG) and pruning unnecessary task nodes, the problem of fixed paths in the DAG model is solved, thus improving execution efficiency.

CN123157358APending Publication Date: 2026-11-24GUANGZHOU SANQI DREAM NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611229052.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-13
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

Existing directed acyclic graph (DAG) models have low execution efficiency because the fixed paths in workflow execution cannot adapt to the differences in intermediate results.

Method used

By generating workflow job instances based on directed acyclic graphs, the target execution path between task nodes is dynamically planned using relay execution results, unnecessary task nodes are pruned, and the execution path is dynamically adjusted to adapt to the differences in the running results of different job instances.

Benefits of technology

It improves the efficiency of workflow execution, enabling the execution paths of different job instances to adapt to differences in intermediate running results, thereby enhancing execution efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123157358A_ABST
    Figure CN123157358A_ABST
Patent Text Reader

Abstract

This application discloses a workflow execution method, apparatus, and electronic device based on a directed acyclic graph (DAG). The method includes: generating a workflow job instance based on a DAG; the DAG pre-configured with a predecessor task node and at least two successor task nodes associated with the predecessor task node; executing the predecessor task node through the workflow job instance to obtain a relay execution result, and determining a target successor task node among the at least two successor task nodes based on the relay execution result; determining a target execution path between task nodes in the workflow job instance based on the target successor task node, and executing the workflow job instance according to the target execution path. This technical solution enables the actual execution path of different job instances executing the same workflow to adapt to the differences in their intermediate running results, thereby improving execution efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and more particularly to a workflow execution method, apparatus, and electronic device based on a directed acyclic graph. Background Technology

[0002] Current workflow systems widely employ Directed Acyclic Graphs (DAGs) to model tasks and their dependencies. In traditional DAG models, the graph structure is static; once the workflow begins execution, all tasks and dependencies defined in the DAG are strictly followed, and the execution path from a task node to all its successor task nodes is fixed.

[0003] However, in the actual execution of DAG-based workflows, it is often necessary to determine the appropriate execution path based on the differences in intermediate running results between task nodes during runtime. Since the execution path from a task node to all its successor task nodes defined by DAG is fixed, the execution path cannot adapt to the differences in intermediate running results, resulting in relatively low execution efficiency. Summary of the Invention

[0004] This application provides a workflow execution method, apparatus, electronic device, and readable storage medium based on a directed acyclic graph. Since different job instances based on the same workflow often have different intermediate execution results, the execution result obtained by the predecessor task node in the job instance is used as the relay execution result. Based on the different relay execution results, the target execution path between task nodes is dynamically planned, so that the actual execution path of different job instances executing the same workflow can adapt to the differences in intermediate execution results, thereby improving execution efficiency.

[0005] In a first aspect, embodiments of this application provide a workflow execution method based on a directed acyclic graph, the method comprising: Generate workflow job instances based on a directed acyclic graph; the directed acyclic graph is pre-configured with a predecessor task node and at least two successor task nodes associated with the predecessor task node; The predecessor task node is executed through the workflow job instance to obtain the relay execution result, and the target successor task node is determined from the at least two successor task nodes based on the relay execution result. Based on the target successor task node, the target execution path between task nodes in the workflow job instance is determined, and the workflow job instance is executed according to the target execution path.

[0006] Optionally, determining the target execution path between task nodes in the workflow job instance based on the target successor task node includes: The target successor task node is identified as the pruning object, and the workflow job instance is pruned based on the pruning object to obtain the pruning result; the pruning result includes the identifier of the task node that is prohibited from being sent to the execution queue. The target execution path between task nodes in the workflow job instance is determined based on the identifier.

[0007] Optionally, the step of performing a pruning operation on the workflow job instance based on the pruning object to obtain the pruning result includes: Determine the directed dependency edges of the pruning object in the workflow job instance; Determine all downstream task nodes pointed to by the directed dependency edge; Logical severance operations are performed on the directed dependent edges and all downstream task nodes they point to to obtain the pruning result.

[0008] Optionally, the logical disconnection operation on the directed dependency edge and all its pointed-to downstream task nodes includes: Starting from the task node directly pointed to by the directed dependency edge, traverse downstream along the task node to find each downstream task node reached through the directed dependency edge. Each downstream task node is assigned an execution prohibition flag; the execution prohibition flag is used to prevent the task node from being sent to the execution queue.

[0009] Optionally, determining the target execution path between task nodes in the workflow job instance based on the target successor task node includes: The target successor task node is designated as the execution object, and an execution list containing the identifiers of the task nodes corresponding to the execution object is generated; The target execution path between task nodes in the workflow job instance is determined based on the execution list.

[0010] Optionally, the number of predecessor task nodes is multiple, and the step of executing the predecessor task nodes through the workflow job instance to obtain the relay execution result includes: Each predecessor task node is executed through the workflow job instance, and the execution result corresponding to each predecessor task node is stored in a pre-built shared variable pool, which is a global key-value storage space with the task node name as the index key. If it is determined that each predecessor task node has completed execution, the set of corresponding execution results is read from the shared variable pool using the name of each predecessor task node as the index key, and used as the relay execution result.

[0011] Optionally, the directed acyclic graph is also pre-configured with relay task nodes for changing the runtime topology of workflow job instances; the relay task nodes are pre-configured with built-in scripts and are configured between the predecessor task node and the at least two associated successor task nodes, and the built-in scripts are pre-injected with access handles of the shared variable pool. The process of retrieving the corresponding set of execution results from the shared variable pool as relay execution results includes: Based on the access handle, the corresponding set of execution results is read from the shared variable pool and used as the relay execution result.

[0012] Secondly, embodiments of this application provide a workflow execution apparatus based on a directed acyclic graph, the apparatus comprising: A generation unit is used to generate workflow job instances based on a directed acyclic graph; the directed acyclic graph is pre-configured with a predecessor task node and at least two successor task nodes associated with the predecessor task node; The first execution unit is used to execute the predecessor task node through the workflow job instance to obtain the relay execution result; The first determining unit is used to determine the target successor task node among the at least two successor task nodes based on the relay execution result; The second determining unit is used to determine the target execution path between task nodes in the workflow job instance based on the target successor task node. The second execution unit is used to execute the workflow job instance according to the target execution path.

[0013] Thirdly, embodiments of this application provide an electronic device, which includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the method described in the first aspect.

[0014] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the method described in the first aspect.

[0015] In this embodiment of the application, a predecessor task node and at least two successor task nodes associated with the predecessor task node are pre-configured in the directed acyclic graph of the workflow; a workflow job instance based on the directed acyclic graph is generated; the predecessor task node is executed through the generated workflow job instance to obtain the relay execution result; the target successor task node is determined among all successor task nodes based on the relay execution result; finally, the target execution path between task nodes in the workflow job instance is dynamically determined based on the determined target successor task node, and the workflow job instance is executed according to the target execution path.

[0016] For different job instances based on the same workflow, the intermediate execution results often differ. Therefore, the execution result obtained by the predecessor task node in the job instance running the workflow is used as the relay execution result. Based on the difference of the relay execution result, the target execution path between task nodes is dynamically planned so that the actual execution path of different job instances executing the same workflow can adapt to the difference in intermediate execution results and improve execution efficiency. Attached Figure Description

[0017] Figure 1 This is a schematic diagram of a workflow execution scenario in related technologies; Figure 2 This is a flowchart illustrating a workflow execution method based on a directed acyclic graph according to an embodiment of this application; Figure 3 A flowchart illustrating a specific implementation process for obtaining relay execution results, provided in an embodiment of this application; Figure 4 A flowchart illustrating a specific implementation process for determining a target execution path, provided as an embodiment of this application; Figure 5 A flowchart illustrating a specific implementation process for obtaining pruning results, provided as an embodiment of this application; Figure 6 This is a schematic diagram of the structure of a workflow execution device based on a directed acyclic graph according to an embodiment of this application; Figure 7 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of this application clearer, specific embodiments of this application will be described in further detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely for explaining this application and not for limiting it. It should also be noted that, for ease of description, only the parts relevant to this application are shown in the drawings, not all of them. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe operations (or steps) as sequential processes, many of these operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but may also have additional steps not included in the drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.

[0019] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0020] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0021] The workflow execution method, apparatus, electronic device, and readable storage medium based on directed acyclic graphs provided in this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.

[0022] Please see Figure 1 First, we will provide an exemplary introduction to workflow execution scenarios in related technologies: like Figure 1 As shown, Figure 1This is a schematic diagram of a workflow execution scenario in related technologies. Current workflow systems widely use Directed Acyclic Graphs (DAGs) to model tasks and their dependencies. In the traditional DAG model, the structure of the DAG is static; that is, once the workflow begins execution, all tasks and dependencies defined in the DAG will be strictly followed, and the execution path from one task node to all its successor task nodes is fixed (e.g., ...). Figure 1 The execution path from task node A to task node B, and then from task node B to task node C, or the execution path from task node A to task node D, and then from task node D to task node E.

[0023] However, in the actual execution of DAG-based workflows, it is often necessary to determine the appropriate execution path based on the differences in intermediate results between task nodes during runtime. For example, "if the data quality check passes (intermediate result), then execute the data loading task (execution path); otherwise, execute the alarm and terminate the process." Static DAG models cannot natively support flexible and dynamic conditional branches, resulting in insufficient workflow expressiveness. Because the execution path from a task node to all its successor task nodes is fixed in a DAG, the execution path cannot adapt to the differences in intermediate results, leading to relatively low execution efficiency.

[0024] It is worth noting that the above description of workflow execution scenarios in related technologies is only an illustrative example. In actual applications, other types of workflow execution scenarios may exist, and no specific limitations are made for them.

[0025] To address the aforementioned issues, this application provides a workflow execution method based on a directed acyclic graph (DAG), which enables the actual execution paths of different job instances executing the same workflow to adapt to differences in their intermediate execution results, thereby improving execution efficiency. For example... Figure 2 As shown, Figure 2 This is a flowchart illustrating a workflow execution method based on a directed acyclic graph according to an embodiment of this application. The method includes the following steps: S201. Generate workflow job instances based on directed acyclic graphs.

[0026] In a directed acyclic graph, a predecessor task node and at least two successor task nodes associated with the predecessor task node can be pre-configured.

[0027] A Directed Acyclic Graph (DAG) is a data structure in graph theory that consists of nodes and directed edges. A key characteristic of DAGs is that traversing along an edge never returns to a previously visited node (i.e., there are no cycles). In workflow systems, DAG nodes represent specific business tasks, while directed edges represent triggering dependencies between tasks (edges point from the first task to the next). The purpose of introducing DAGs into workflows is to leverage their topological sorting properties to ensure tasks are executed strictly according to their dependencies and to prevent circular deadlocks between tasks.

[0028] A workflow can refer to a computerized abstraction of a complete business process. It defines a series of tasks required to achieve a complete business goal (such as ETL data cleaning, model training, report generation, etc.), as well as the execution order and dependency rules between these tasks. A workflow can be the core object managed by a scheduling system. It contains the business code implementation of tasks and the connection relationships between tasks. In physical implementation, a workflow can usually exist in the form of a static definition file (such as a Python DAG file or JSON description). Users can submit it to the scheduler to generate specific running instances (job instances).

[0029] A workflow job instance can refer to a specific, independent runtime copy of a static workflow definition (including DAG structure) created and executed by the scheduler under specific triggering conditions. It can be the basic unit for the workflow scheduling system to perform task scheduling, status tracking, and resource allocation.

[0030] A predecessor task node can refer to any directed dependency edge in a Directed Acyclic Graph (DAG) that connects task nodes A and B, with task node A pointing to task node B (meaning task node B can only be triggered after task node A has completed execution). A is the predecessor task node of B. A predecessor can refer to all tasks that must be completed before the current node (including direct predecessors and indirect predecessors). In the embodiments of this application, the predecessor task node can refer to a direct predecessor task node, that is, there exists a direct directed edge from this node to the upstream task of the relay task node (or the current node).

[0031] In a Directed Acyclic Graph (DAG), for any directed edge connecting task node A and task node B, where task node A points to task node B (indicating that task node B can only be triggered after task node A has completed its execution), task node B is the successor task node of task node A. "Successor" can refer to all tasks that must be triggered after the current node (including direct and indirect successors). In this embodiment, the successor task node can refer to a direct successor task node, i.e., the downstream task pointed to by the relay task node (or the current node) through a direct directed edge.

[0032] Optionally, the method for generating workflow job instances based on directed acyclic graphs can include: when the workflow engine receives a trigger signal (such as a scheduled event, API call, or external event), the scheduler first loads the corresponding static DAG definition (containing the attribute configuration of all task nodes and their directed dependency edges) from its metadata database based on the workflow's unique identifier. Then, it creates an independent job instance (object) in memory for this trigger and assigns a globally unique instance ID to the workflow job instance. During the instantiation of the workflow, the scheduler can use the topology of the static DAG as a runtime DAG copy of the workflow job instance. At the same time, it can initialize an empty shared variable pool (global key-value storage space) for the workflow job instance to use, and uniformly set the initial state of all task nodes in the DAG to "pending scheduling". This transforms the workflow job instance from a static DAG into an executable entity with an independent lifecycle, independent data storage space, and independent variable topology, thereby enabling task scheduling based on its runtime DAG.

[0033] S202. Execute the predecessor task node through the workflow job instance to obtain the relay execution result, and determine the target successor task node among at least two successor task nodes based on the relay execution result.

[0034] The relay execution result refers to a set of runtime output data that is persistently stored in the shared variable pool corresponding to the workflow job instance after executing the direct predecessor task node in the current workflow job instance. It can directly originate from the business execution output of the direct predecessor task node. For example, a JSON object output by a data quality check task: {"error_count": 0, "schema_ok": true}.

[0035] The target successor task node can be some or all of the successor task nodes determined from at least two successor task nodes.

[0036] In one embodiment, a specific implementation process is described for executing a predecessor task node through a workflow job instance to obtain the relay execution result. Please refer to [reference needed]. Figure 3 , Figure 3 This is a flowchart illustrating a specific implementation process for obtaining relay execution results, provided as an embodiment of this application. Figure 3 As shown, the specific implementation steps to obtain the relay execution result are as follows: S2021. Execute each predecessor task node through the workflow job instance, and store the execution result corresponding to each predecessor task node into a pre-built shared variable pool.

[0037] The shared variable pool can be a global key-value storage space indexed by the task node name.

[0038] The number of predecessor task nodes can be multiple.

[0039] The execution result corresponding to each predecessor task node can refer to the output result of executing a specific predecessor task node. For example, if there are four predecessor task nodes, executing each of the four predecessor task nodes will yield four execution results.

[0040] A shared variable pool can refer to an independent, globally accessible memory storage space containing key-value pairs corresponding to the current workflow job instance. It can be used to write the output data (execution result) of the predecessor task node into the globally accessible memory storage space after the predecessor task node is executed, using the name of the predecessor task node as the index key. Subsequent relay task nodes can then read the data through access handles pre-injected in the runtime environment of the built-in script when executing the built-in script.

[0041] Optionally, the method of executing each predecessor task node separately through the workflow job instance may include: the scheduler, based on the runtime DAG of the current workflow job instance, identifies all predecessor task nodes whose dependency conditions have been met (i.e., all upstream task nodes have been completed) from the task queue, and assigns these predecessor task nodes one by one to available worker threads or containers for independent execution; each predecessor task node receives the input parameters and context information of the workflow job instance during execution, runs the business logic encapsulated inside the predecessor task node (such as data quality check, file download, model training, etc.) based on the received input parameters and context information, and returns the output result data (i.e. execution result, such as inspection report JSON, download path, model accuracy, etc.) to the scheduler in a preset serialization format after execution.

[0042] Optionally, the method of storing the execution result corresponding to each predecessor task node into the pre-built shared variable pool may include: after each predecessor task node executes successfully and returns the corresponding execution result, the scheduler immediately triggers the data persistence process: first, obtain the access handle of the shared variable pool of the workflow job instance from the relay task node, then use the name of the predecessor task node as the index key to encapsulate the returned execution result and execution metadata (such as execution timestamp and status flag) corresponding to the predecessor task node into a structured object, and then write the structured object into the key-value pair storage space exclusively occupied by the current workflow job instance through the atomic write interface provided by the shared variable pool.

[0043] S2022. If it is determined that each predecessor task node has completed execution, the set of corresponding execution results is read from the shared variable pool using the name of each predecessor task node as the index key, and used as the relay execution result.

[0044] The name of a predecessor task node can be a globally unique and readable string identifier assigned to each predecessor task node in the workflow definition. This identifier can be used to uniquely represent the task node in the static DAG structure, scheduling logs, script code, and user interface. The name of a predecessor task node cannot be repeated within the same workflow definition, and each predecessor task node's name is fixed during the definition phase and does not change with changes in the workflow's running instance.

[0045] An index key refers to a storage key in the shared variable pool used to uniquely identify and quickly locate a data record. In computer science, the index key is a core component of the key-value pair storage model, responsible for data writing location and reading retrieval. In some embodiments, the index key can use a string copy of the name of the predecessor task node as its value. After the scheduler successfully executes the predecessor task node, it writes the output result (execution result) with the name of the predecessor task node as the key value. When running the built-in script of the relay task node, the corresponding output result can also be read from the shared variable pool with the name as the key value.

[0046] The set of execution results can refer to the set of all execution results corresponding to all predecessor task nodes pre-configured in the DAG, that is, all execution results corresponding to all predecessor task nodes together constitute the above-mentioned relay execution results.

[0047] Optionally, assuming each predecessor task node has completed execution, the method of retrieving the corresponding set of execution results from the shared variable pool using the name of each predecessor task node as the index key and using it as the relay execution result may include: the directed acyclic graph also pre-configured with relay task nodes for changing the runtime topology of workflow job instances; the relay task nodes pre-configured with built-in scripts and configured between the predecessor task node and at least two associated successor task nodes, with access handles pre-injected into the shared variable pool in the built-in scripts; and the corresponding set of execution results can be retrieved from the shared variable pool based on the access handles in the pre-configured built-in scripts of the relay task nodes, and used as the relay execution result. In some embodiments, after all direct predecessor task nodes of a relay task node have completed execution and written their respective execution results to the shared variable pool, the scheduler can mark the relay task node as executable and trigger its execution. After the relay task node starts, its built-in script can traverse the name of each predecessor task node hard-coded in the code of the built-in script through the preset access interface of the shared variable pool, and use the string corresponding to the name of each predecessor task node as the index key to perform a key-value lookup operation in the shared variable pool exclusively occupied by the current workflow job instance to obtain the output result value (execution result) corresponding to each index key. After all key-value lookups are completed, the built-in script will organize the output results (execution results) of each predecessor task node read into a result set object in the form of key-value pairs. This result set object is the relay execution result mentioned above.

[0048] In this context, the topology can refer to the static connection relationship formed by all task nodes and their directed dependencies in a directed acyclic graph. It describes the execution order constraints between task nodes in the workflow (i.e., which task must be completed before which other task). The topology is fixed during the workflow definition phase. In this embodiment, the logical pruning operation only modifies the topology of the runtime DAG copy of the current workflow job instance (e.g., marking certain directed dependencies as "cut off"), without changing the static topology of the workflow definition.

[0049] A relay task node can refer to a special type of task node that does not perform actual business logic operations (such as not reading or writing to the database, or performing data transformation). Its function is to make decision-making and routing at key branch points in the workflow. That is, it reads the output results (execution results) of the predecessor task node by executing built-in scripts, generates control instructions, and thus dynamically affects whether or not subsequent branch task nodes are executed. In some embodiments, the relay task node may not contain actual business calculation code. It can connect the predecessor task node (data source) and the subsequent task node (control object), and dynamically decide which branches to prune at runtime based on the results of the predecessor.

[0050] Built-in scripts refer to a piece of executable program code (such as JavaScript code) configured in the attribute fields of relay task nodes. They serve as the sole workload of the relay task node when executed, carrying the implementation of the successor branch decision logic. In some embodiments, the built-in script can access the shared variable pool to read the output of the predecessor task node and perform successor branch pruning decisions based on these outputs. Using built-in scripts allows the successor branch decision logic to be intuitively and centrally defined within the relay task node, enabling tight integration with the workflow structure.

[0051] An access handle can refer to an intermediate reference object used for secure access to a specific resource or service, rather than directly exposing the resource itself. It can be an interface object pre-injected in the script execution environment of a relay task node for accessing a shared variable pool.

[0052] Optionally, the method for determining the target successor task node among at least two successor task nodes based on the relay execution result may include: the built-in script of the relay task node can extract key field values ​​from the relay execution result according to the branch judgment logic (such as ifelse, switch case, or ternary expression) pre-written by the developer, and perform condition judgments such as numerical comparison, Boolean operation, or string matching on these key field values, and dynamically determine the target successor task node among at least two successor task nodes based on the condition judgment results.

[0053] S203. Determine the target execution path between task nodes in the workflow job instance based on the target successor task node, and execute the workflow job instance according to the target execution path.

[0054] The target execution path refers to the actual execution trajectory of the current workflow job instance after the dynamic successor branch selection of the relay task node, starting from the relay task node and including only the direct successor task nodes that have not been excluded (i.e. actually selected for execution) and their downstream reachable task nodes. The target execution path is the basis for the scheduler's final scheduling and is different from the complete topology path defined in the static DAG.

[0055] In one embodiment, a specific implementation process for determining the target execution path between task nodes in a workflow job instance based on the target successor task node is described. Please refer to [reference needed]. Figure 4 , Figure 4 This is a flowchart illustrating a specific implementation process for determining a target execution path, as provided in an embodiment of this application. Figure 4 As shown, the specific implementation steps for determining the target execution path are as follows: S2031. Determine the target successor task node as the pruning object, and perform pruning operations on the workflow job instance based on the pruning object to obtain the pruning result.

[0056] The pruning results may include identifiers of task nodes that are prohibited from being sent to the execution queue.

[0057] The pruning object can refer to the target element directly acted upon by the scheduler when performing DAG logic pruning operations at runtime. Specifically, it can include directed dependency edges from relay task nodes to excluded successor task nodes, as well as downstream task nodes and their associated directed edges that are unreachable (i.e. can only be reached through the cut-off directed dependency edges) due to these cut-off directed dependency edges.

[0058] The pruning result can refer to the updated runtime DAG of the current workflow job instance obtained after the scheduler completes the logical marking of all pruned objects (such as cutting directed dependency edges and marking the skip status of successor task nodes). That is, the remaining executable topology structure after removing the excluded branches and all unreachable downstream nodes from the complete static DAG topology.

[0059] The identifier for task nodes that are prohibited from being sent to the execution queue can refer to a status flag or operation lock that the scheduler attaches to all unreachable task nodes on the pruned branches after completing runtime DAG pruning. The purpose of this identifier is to prevent the task node from being sent to the execution queue in subsequent scheduling loops, thereby achieving the effect of logically skipping it.

[0060] In one embodiment, a specific implementation process is described for pruning workflow job instances based on pruning objects to obtain pruning results. Please refer to [reference needed]. Figure 5 , Figure 5 This is a flowchart illustrating a specific implementation process for obtaining pruning results, provided as an embodiment of this application. Figure 5 As shown, the specific implementation steps to obtain the pruning results are as follows: S20311. Determine the directed dependency edges corresponding to the pruned objects in the workflow job instance.

[0061] In this context, a directed dependency edge can refer to a directed arrow connecting two task nodes in a directed acyclic graph. It can point from the predecessor task node to the successor task node and strictly defines the execution order constraint, that is, the successor task node pointed to by the arrow can only be triggered to execute after the predecessor task node pointed to by the arrow tail has been executed.

[0062] Optionally, the method for determining the directed dependency edge corresponding to the pruned object in the workflow job instance may include: the scheduler can traverse each task node name corresponding to the pruned object, and for each traversed task node name, the scheduler can locate the directed dependency edge (i.e., the direct directed edge from the relay task node to the direct successor task node) in the runtime DAG of the current workflow job instance by querying the adjacency list or edge list data structure maintained by the workflow job instance.

[0063] S20312. Determine all downstream task nodes pointed to by the directed dependency edges.

[0064] In a directed acyclic graph, a downstream task node can refer to all task nodes that can be reached from a specified task node (such as a relay task node or its excluded direct successor task node) along the direction of the directed dependent edge through one or more edges. That is, the set of all nodes located after the specified task node (including direct successors and indirect successors).

[0065] Optionally, the method for determining all downstream task nodes pointed to by a directed dependency edge may include: for each directed dependency edge corresponding to a pruned object, the scheduler, starting from the direct successor task node pointed to by the directed dependency edge, recursively traverses the current workflow job instance's runtime DAG using a depth-first or breadth-first traversal algorithm, layer by layer, downstream from the starting point; during the traversal, for each downstream task node encountered, the scheduler checks all backward reachable paths from that node to the relay task node. If all backward reachable paths contain at least one directed dependency edge corresponding to the pruned object (i.e., the node can only be connected to the relay task node through the cut edge), then the node is marked, and this mark is used to determine that it is a downstream task node pointed to by the directed dependency edge.

[0066] S20313. Perform logical severing operations on directed dependent edges and all downstream task nodes they point to to obtain the pruning result.

[0067] Optionally, the logical severing operation on the directed dependency edge and all the downstream task nodes it points to can include: starting from the task node directly pointed to by the directed dependency edge, traversing downstream along the task node to traverse each downstream task node reached through the directed dependency edge; assigning an execution prohibition flag to each downstream task node; the execution prohibition flag is used to prevent the task node from being sent to the execution queue.

[0068] The execution prohibition flag can be a Boolean status flag attached to all task nodes that are determined to need pruning. It can be used as a gating condition in subsequent scheduling loops. That is, before sending any task node into the execution queue, the scheduler must first check whether the task node is given the execution prohibition flag. If it is, the task node is skipped directly, thus logically preventing the task node from being actually executed.

[0069] In some embodiments, traversing downstream from the task node directly pointed to by the directed dependency edge to traverse all downstream task nodes reached through the directed dependency edge may include: using the direct successor task node pointed to by the directed dependency edge corresponding to the pruned object as the traversal starting point, the scheduler obtains a list of all outgoing directed dependency edges of the direct successor task node in the runtime DAG of the current workflow job instance, and recursively visits the next level of task nodes (downstream task nodes) along each outgoing directed dependency edge using a depth-first or breadth-first traversal algorithm; each time a downstream task node is reached... For each task node, the scheduler first checks whether it has been visited to avoid looping. Then, it retrieves all outgoing directed edges of the task node and repeats the recursive access process. The scheduler continues to recursively traverse until there are no more unvisited outgoing directed edges on the current branch path (i.e., reaching the end node of the DAG or the sink node without outgoing edges). Then, it backtracks to the previous branch point to continue processing other untraversed outgoing directed edges until all the end nodes of the branch paths reachable from the directed dependent edges corresponding to the pruned object have been visited. Finally, it outputs the set of all traversed downstream task nodes.

[0070] In some embodiments, the method of assigning an execution prohibition flag to each downstream task node may include: the scheduler sets a boolean status field in the memory data structure of the current workflow job instance for each downstream task node to the value corresponding to the execution prohibition flag, thereby completing the assignment of the execution prohibition flag.

[0071] S2032. Determine the target execution path between task nodes in a workflow job instance based on the identifier.

[0072] Optionally, the method for determining the target execution path between task nodes in a workflow job instance based on the identifier can be as follows: During the process of exploring downstream from the relay task node along the directed dependency edge, the scheduler skips all task nodes carrying the above-mentioned execution prohibition identifier and the cut-off directed dependency edges associated with these task nodes, and only retains the task nodes that do not carry the above-mentioned execution prohibition identifier and the connection relationships between these task nodes. The set of reachable execution trajectory sequences from the above-mentioned relay task node to each end node, formed by connecting all the retained task nodes according to the original dependency topology order in the DAG, is determined as the above-mentioned target execution path.

[0073] In some embodiments, another way to determine the target execution path between task nodes in a workflow job instance based on the target successor task node may include: designating the target successor task node as the execution object and generating an execution list containing the identifiers of the task nodes corresponding to the execution object; and determining the target execution path between task nodes in the workflow job instance based on the execution list.

[0074] The execution target can refer to the direct successor task node that is explicitly designated to be executed after the built-in script of the relay task node makes a branch judgment based on the execution result of the predecessor task node.

[0075] An execution list can refer to an array of strings consisting of the identifiers of the task nodes corresponding to the execution objects, used to explicitly indicate the direct successor branches that need to be executed in the current workflow job instance.

[0076] In some embodiments, the method of designating a target successor task node as an execution object and generating an execution list containing the identifier of the task node corresponding to the execution object may include: during the execution of the built-in script of the relay task node, a structured data object is generated as a control instruction based on branch judgment logic and returned to the scheduler, and the control instruction contains the above-mentioned execution list.

[0077] In some embodiments, determining the target execution path between task nodes in a workflow job instance based on the execution list may include: after the scheduler receives and parses the execution list, it first verifies whether the name corresponding to each task node in the execution list is a direct successor task node of the current relay task node. Then, based on the execution list, in the runtime DAG of the current workflow job instance, it ignores the directed dependency edges that the relay task node points to all other direct successor task nodes that do not appear in the execution list, and recursively traverses downstream along the ignored directed dependency edges, ignoring all downstream task nodes that can only be reached through the ignored directed dependency edges. For the direct successor task node specified in the execution list and all its reachable downstream task nodes, the scheduler keeps them in the executable state. Subsequently, starting from the current relay task node, the scheduler performs a topology traversal downstream along all the directed dependency edges that are kept in the executable state, collecting only all downstream task nodes that have not been ignored, and connecting these task nodes according to the original dependency topology order to form a set of reachable execution trajectory sequences, which is used as the target execution path of the current workflow job instance.

[0078] Optionally, the method of executing workflow job instances according to the target execution path may include: after the scheduler completes the pruning operation of the runtime DAG and determines the target execution path, it first obtains all task nodes in the current workflow job instance that have not been assigned an execution prohibition flag and whose direct predecessor task nodes have not been assigned an execution prohibition flag, and arranges these nodes into an execution order sequence that meets the dependency constraints according to the topology sorting algorithm; then the scheduler iterates from the first task node in the execution order sequence, and checks in each round of scheduling loop whether all direct predecessor task nodes of the current task node have been successfully completed. If all are satisfied, the task node is sent to the execution queue to be assigned to a worker thread or container for execution; if there are uncompleted predecessor task nodes, it waits until they are completed.

[0079] The following example illustrates the DAG-based workflow execution process of this application: Assume an ETL process, which describes the process of extracting, transforming, and loading data from the source to the destination. This process includes the following steps: The first step, Task_CheckData, checks the quality of the source data file and outputs a JSON string, {"error_count":5,"schema_ok":true}.

[0080] The second step, Relay_Decision: a relay task node that depends on Task_CheckData.

[0081] The third step, Task_Process: The core processing task, is executed if and only if the data quality is acceptable (error_count==0&&schema_ok ==true).

[0082] The fourth step, Task_Alert: Alert task, executed when data quality is unacceptable.

[0083] Step 5, Task_Archive: This is an archiving task. Regardless of the data quality, the source files need to be archived after the inspection is completed.

[0084] In the Directed Acyclic Graph (DAG), Task_CheckData is the predecessor task node of Relay_Decision. Task_Process, Task_Alert, and Task_Archive are all successor task nodes of Relay_Decision.

[0085] The workload0 of the Relay_Decision node can be defined in the script as follows: const checkResult = world.Task_CheckData.result; let excluded = []; if (checkResult.error_count === 0&&checkResult.schema_ok) { / / Quality passed, alarm cleared. excluded.push('Task_Alert'); } else { / / Quality not up to standard, task excluded. excluded.push('Task_Process'); } return {'EXCLUDE_SUCC': excluded}; Based on this, let's assume two execution scenarios, for example: Execution Scenario 1 (Data quality is acceptable): checkResult is {"error_count":0, "schema_ok":true}. The script returns {'EXCLUDE_SUCC':['Task_Alert']}. After receiving the instruction, the scheduler will not schedule the Task_Alert task, but will schedule the Task_Process and Task_Archive tasks normally.

[0086] Execution Scenario 2 (Data Quality Issues): checkResult is {"error_count":5, "schema_ok":true}. The script returns {'EXCLUDE_SUCC':['Task_Process']}. The scheduler will ignore the Task_Process task, but will execute the Task_Alert and Task_Archive tasks.

[0087] In this embodiment of the application, a predecessor task node and at least two successor task nodes associated with the predecessor task node are pre-configured in the directed acyclic graph of the workflow; a workflow job instance based on the directed acyclic graph is generated; the predecessor task node is executed through the generated workflow job instance to obtain the relay execution result; the target successor task node is determined among all successor task nodes based on the relay execution result; finally, the target execution path between task nodes in the workflow job instance is dynamically determined based on the determined target successor task node, and the workflow job instance is executed according to the target execution path.

[0088] For different job instances based on the same workflow, the intermediate execution results often differ. Therefore, the execution result obtained by the predecessor task node in the job instance running the workflow is used as the relay execution result. Based on the difference of the relay execution result, the target execution path between task nodes is dynamically planned so that the actual execution path of different job instances executing the same workflow can adapt to the difference in intermediate execution results and improve execution efficiency.

[0089] Corresponding to the above method embodiments, this application also provides a workflow execution device based on a directed acyclic graph, such as... Figure 6 As shown, Figure 6 This is a schematic diagram of a workflow execution device based on a directed acyclic graph according to an embodiment of this application. The device includes: The generation unit 601 is used to generate workflow job instances based on a directed acyclic graph; the directed acyclic graph is pre-configured with a predecessor task node and at least two successor task nodes associated with the predecessor task node. The first execution unit 602 is used to execute the predecessor task node through the workflow job instance to obtain the relay execution result; The first determining unit 603 is used to determine the target successor task node among at least two successor task nodes based on the relay execution result; The second determining unit 604 is used to determine the target execution path between task nodes in a workflow job instance based on the target successor task node. The second execution unit 605 is used to execute workflow job instances according to the target execution path.

[0090] Optionally, the second determining unit 604 is specifically used to determine the target successor task node as the pruning object, and perform pruning operation on the workflow job instance based on the pruning object to obtain the pruning result; the pruning result includes the identifier of the task node that is prohibited from being sent to the execution queue; and determine the target execution path between task nodes in the workflow job instance based on the identifier.

[0091] Optionally, the second determining unit 604 is specifically used to determine the directed dependency edge corresponding to the pruning object in the workflow job instance; determine all downstream task nodes pointed to by the directed dependency edge; and perform logical severing operations on the directed dependency edge and all downstream task nodes pointed to by it to obtain the pruning result.

[0092] Optionally, the second determining unit 604 is specifically used to traverse downstream from the task node directly pointed to by the directed dependency edge, so as to traverse each downstream task node reached through the directed dependency edge; to assign an execution prohibition flag to each downstream task node; the execution prohibition flag is used to prevent the task node from being sent into the execution queue.

[0093] Optionally, the second determining unit 604 is used to designate the target successor task node as the execution object and generate an execution list containing the identifiers of the task nodes corresponding to the execution object; and determine the target execution path between task nodes in the workflow job instance based on the execution list.

[0094] Optionally, there are multiple predecessor task nodes. The first execution unit 602 is specifically used to execute each predecessor task node through the workflow job instance, and store the execution result corresponding to each predecessor task node into a pre-built shared variable pool. The shared variable pool is a global key-value storage space with the task node name as the index key. When it is determined that each predecessor task node has been executed, the set of corresponding execution results is read from the shared variable pool with the name of each predecessor task node as the index key, and used as the relay execution result.

[0095] Optionally, the directed acyclic graph also pre-configures relay task nodes for changing the runtime topology of workflow job instances; the relay task nodes are pre-configured with built-in scripts and are configured between the predecessor task node and at least two associated successor task nodes, and the built-in scripts are pre-injected with access handles of the shared variable pool; the first execution unit 602 is specifically used to read the corresponding set of execution results from the shared variable pool according to the access handles, and use it as the relay execution result.

[0096] like Figure 7 As shown, this application embodiment also provides an electronic device, including a processor 701, a memory 702, and a program or instructions stored in the memory 702 and executable on the processor 701. When the program or instructions are executed by the processor 701, they implement the various processes of the above-described workflow execution method embodiment based on a directed acyclic graph and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0097] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described workflow execution method embodiment based on a directed acyclic graph and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0098] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0099] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0100] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0101] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

[0102] The above description is merely a preferred embodiment and the technical principles employed in this application. This application is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions that can be made by those skilled in the art will not depart from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of this application, the scope of which is determined by the scope of the claims.

Claims

1. A workflow execution method based on a directed acyclic graph, characterized in that, The method includes: Generate workflow job instances based on a directed acyclic graph; the directed acyclic graph is pre-configured with a predecessor task node and at least two successor task nodes associated with the predecessor task node; The predecessor task node is executed through the workflow job instance to obtain the relay execution result, and the target successor task node is determined from the at least two successor task nodes based on the relay execution result. Based on the target successor task node, the target execution path between task nodes in the workflow job instance is determined, and the workflow job instance is executed according to the target execution path.

2. The method according to claim 1, characterized in that, Determining the target execution path between task nodes in the workflow job instance based on the target successor task node includes: The target successor task node is identified as the pruning object, and the workflow job instance is pruned based on the pruning object to obtain the pruning result; the pruning result includes the identifier of the task node that is prohibited from being sent to the execution queue. The target execution path between task nodes in the workflow job instance is determined based on the identifier.

3. The method according to claim 2, characterized in that, The step of performing a pruning operation on the workflow job instance based on the pruning object to obtain the pruning result includes: Determine the directed dependency edges of the pruning object in the workflow job instance; Determine all downstream task nodes pointed to by the directed dependency edge; Logical severance operations are performed on the directed dependent edges and all downstream task nodes they point to to obtain the pruning result.

4. The method according to claim 3, characterized in that, The logical disconnection operation on the directed dependency edge and all its pointed-to downstream task nodes includes: Starting from the task node directly pointed to by the directed dependency edge, traverse downstream along the task node to find each downstream task node reached through the directed dependency edge. Each downstream task node is assigned an execution prohibition flag; the execution prohibition flag is used to prevent the task node from being sent to the execution queue.

5. The method according to claim 1, characterized in that, Determining the target execution path between task nodes in the workflow job instance based on the target successor task node includes: The target successor task node is designated as the execution object, and an execution list containing the identifiers of the task nodes corresponding to the execution object is generated; The target execution path between task nodes in the workflow job instance is determined based on the execution list.

6. The method according to claim 1, characterized in that, The number of predecessor task nodes is multiple, and the execution of the predecessor task nodes through the workflow job instance to obtain the relay execution result includes: Each predecessor task node is executed through the workflow job instance, and the execution result corresponding to each predecessor task node is stored in a pre-built shared variable pool, which is a global key-value storage space with the task node name as the index key. If it is determined that each predecessor task node has completed execution, the set of corresponding execution results is read from the shared variable pool using the name of each predecessor task node as the index key, and used as the relay execution result.

7. The method according to claim 6, characterized in that, The directed acyclic graph is also pre-configured with relay task nodes for changing the runtime topology of workflow job instances; the relay task nodes are pre-configured with built-in scripts and are configured between the predecessor task node and the at least two associated successor task nodes, and the built-in scripts are pre-injected with access handles of the shared variable pool. The process of retrieving the corresponding set of execution results from the shared variable pool as relay execution results includes: Based on the access handle, the corresponding set of execution results is read from the shared variable pool and used as the relay execution result.

8. A workflow execution device based on a directed acyclic graph, characterized in that, The device includes: A generation unit is used to generate workflow job instances based on a directed acyclic graph; the directed acyclic graph is pre-configured with a predecessor task node and at least two successor task nodes associated with the predecessor task node; The first execution unit is used to execute the predecessor task node through the workflow job instance to obtain the relay execution result; The first determining unit is used to determine the target successor task node among the at least two successor task nodes based on the relay execution result; The second determining unit is used to determine the target execution path between task nodes in the workflow job instance based on the target successor task node. The second execution unit is used to execute the workflow job instance according to the target execution path.

9. An electronic device, characterized in that, It includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein when the program or instructions are executed by the processor, they implement the workflow execution method based on a directed acyclic graph as described in any one of claims 1-7.

10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the workflow execution method based on a directed acyclic graph as described in any one of claims 1-7.