Method and device for automatically generating task calling code, computer equipment and computer readable storage medium

Through the overall calling process modeling and initial state configuration based on EFSM, combined with pre-judgment and result judgment code segments, the task calling code is automatically generated, which solves the problem of insufficient task dependency and pipeline flexibility in the existing technology, and realizes the modular design and efficient automation of the task calling process.

CN119512511APending Publication Date: 2025-02-25GUANGDONG GAOYU TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311039114.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-16
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

The existing technology does not consider the dependencies between tasks when designing Jenkins pipeline task templates, and the pipeline template does not have flexibility in different scenarios, resulting in difficulty in maintenance and expansion.

Method used

The overall calling process based on the extended finite state machine (EFSM) is adopted to determine the initial state of the task, generate a task sequence, and automatically generate the task call code through the preset pre-judgment code segment and result judgment code segment.

Benefits of technology

The modular design of the task calling process is realized, the dependency design between tasks is increased, the dependency design is adapted to different scenario needs, the task calling process is simplified, and efficiency and maintainability are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512511A_ABST
    Figure CN119512511A_ABST
Patent Text Reader

Abstract

The invention discloses a method and device for automatically generating task calling codes, computer equipment and a computer readable storage medium, and the method comprises the steps: determining an initial state of a task according to an overall calling process based on EFSM (Extended Finite State Machine) pre-modeling; generating a task sequence according to the initial state and the overall calling process; traversing the task sequence according to a pre-judgment code segment and a result judgment code segment of a preset calling task to generate a pre-judgment script and a result judgment script; and according to the task sequence, the pre-judgment script and the result judgment script, generating a calling process code and outputting the calling process code. According to the embodiment of the invention, the overall calling process based on EFSM pre-modeling is utilized, the dependency relationship design between execution tasks is increased through the preset pre-judgment code segment and the result judgment code segment, the change of the overall structure is better adapted, and continuous utilization is facilitated; by configuring and determining the initial state of the task, the assembly line design can adapt to different scene requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of software task calling, and in particular relates to a method, an apparatus, a computer device and a computer-readable storage medium for automatically generating a task calling code. Background Art

[0002] With the promotion of the concept of DevOps (a combination of Development and Operations, which is the general term for development and operation and maintenance), automated operation and maintenance has gradually been promoted within enterprises. Jenkins is a popular DevOps platform that implements pipeline orchestration through the groovy language. Through Jenkins' rich plug-ins, many functions can be performed, including executing code pull tasks, executing deployment tasks, and testing tasks. Although Jenkins' pipeline syntax and abstract DSL definition allow users to design pipelines according to their own needs.

[0003] A method for quickly creating a Jenkins pipeline that has been disclosed is as follows: first, the administrator user writes a task template for a commonly used pipeline, writes a pipeline script fragment in the task template, and specifies the variables that can be automatically obtained and exported in the task template, and specifies the parameters required for the execution of this part of the script fragment; then the administrator user arranges and combines the written task templates to obtain commonly used pipeline templates, and sets corresponding labels for different pipeline templates according to the type of pipeline template; finally, the administrator user imports the written pipeline templates and various task templates into the DevOps platform for users to choose to generate pipelines. However, in the aforementioned scheme, the design of the task template does not consider the dependency relationship between tasks, designs the input parameters of the task template, but does not manage the output of the task template. In addition, the pipeline template is only the arrangement and combination of the task template, which is a fixed template and does not have flexibility in different scenarios. In addition, users are required to write complex judgment logic, parameter definitions, etc. without good design. If there is no good design, the arranged pipeline will be difficult to maintain and expand. Summary of the invention

[0004] The technical problem to be solved by the embodiments of the present invention is to provide a method, device, computer equipment and computer-readable storage medium for automatically generating task calling codes to simplify the modular design of task calling process codes and adapt to different scenario requirements.

[0005] In order to solve the above technical problems, the present invention provides a method for automatically generating task calling codes, comprising:

[0006] Determine the initial state of the task according to the overall calling process pre-modeled based on the extended finite state machine EFSM;

[0007] Generate a task sequence according to the initial state and the overall calling process;

[0008] According to the preset pre-judgment code segment and result judgment code segment of the calling task, traverse the task sequence to generate a pre-judgment script and a result judgment script;

[0009] The calling process code is generated and outputted according to the task sequence, the pre-judgment script and the result judgment script.

[0010] It can be seen from the above steps that the embodiment of the present invention utilizes the overall calling process based on EFSM pre-modeling, and increases the dependency design between the execution tasks through the preset pre-judgment code segment and the result judgment code segment, which is more adaptable to the changes in the overall structure and conducive to continuous utilization; by configuring and determining the initial state of the task, the pipeline design can adapt to different scenario requirements.

[0011] Preferably, the determining of the initial state of the task according to the overall calling process based on the extended finite state machine EFSM pre-modeling specifically includes:

[0012] Read the status set of the established overall call process;

[0013] Determine a state transition path according to the state set;

[0014] Determine the initial input based on the input set in the overall calling process;

[0015] Determining an initial state of the task according to the state transition path and the initial input;

[0016] The state set specifically includes:

[0017] An input set, wherein the input set is a set of various inputs received during the execution of the system;

[0018] A dependency set, wherein the dependency set is a set of dependency relationships during the execution of the system;

[0019] An event set is a set of events that trigger state transition or operation execution during system execution.

[0020] Preferably, generating a task sequence according to the initial state and the overall calling process specifically includes:

[0021] Generate a preliminary task sequence based on the input set and event set in the overall calling process and in combination with the state transition path;

[0022] Determine the dependent tasks of each task in the preliminary task sequence according to the dependency set in the overall calling process;

[0023] The execution order of the tasks is recalculated to obtain the task sequence.

[0024] Preferably, the process of traversing the task sequence and generating the pre-judgment code and the result judgment code according to the preset pre-judgment code segment and the result judgment code segment of the calling task specifically includes:

[0025] Visit each task in the task sequence in turn;

[0026] For each task, before execution, a preset pre-judgment code segment is applied to generate a corresponding pre-judgment script, and the pre-judgment script is executed to determine whether the pre-judgment condition is met. If the pre-judgment condition is met, the task is executed;

[0027] After the task is executed, a preset result judgment code segment is applied to generate a corresponding result judgment script, and the result judgment script is executed to make a judgment based on the execution result of the task, and perform corresponding processing and subsequent operations based on the judgment result.

[0028] Preferably, the process of presetting the pre-judgment code segment and the result judgment code segment is:

[0029] Write the task calling code segment according to the syntax of the task calling platform;

[0030] In each task calling code segment, add a pre-judgment code segment for the dependent tasks based on the dependency relationship;

[0031] In each task calling code segment, add a result judgment code segment for judging the task execution result.

[0032] Preferably, the process of modeling the overall calling process based on the extended finite state machine EFSM is:

[0033] Split the tasks according to the overall calling process;

[0034] Divide the split tasks into different stages and name them;

[0035] Different stages are regarded as different states of the process call to form a state set of the process call.

[0036] Preferably, the calling process code includes the actual operation of executing the task and the control logic related to the task calling.

[0037] The present invention also provides a device for automatically generating task calling codes, comprising:

[0038] An initial state determination module is used to determine the initial state of the task according to the overall calling process pre-modeled based on the extended finite state machine EFSM;

[0039] A task sequence generation module, used for generating a task sequence according to the initial state and the overall calling process;

[0040] A script generation module, used to traverse the task sequence according to the preset pre-judgment code segment and result judgment code segment of the calling task, and generate a pre-judgment script and a result judgment script;

[0041] The output module is used to generate and output the calling process code according to the task sequence, the pre-judgment script and the result judgment script.

[0042] The present invention also provides a computer device, comprising:

[0043] one or more processors;

[0044] Memory;

[0045] One or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more application programs are configured to execute the method for automatically generating task calling codes.

[0046] The present invention also provides a computer-readable storage medium, which includes a stored computer program; wherein, when the computer program is running, it controls the device where the computer-readable storage medium is located to execute the method of automatically generating task calling code.

[0047] The implementation of the present invention has the following beneficial effects: (1) Streamlining and automation: The system automatically generates task call codes, and there is no need to manually write a large amount of code, which greatly improves the efficiency of task calls and reduces the errors caused by manually writing codes. At the same time, for complex systems, especially systems containing a large number of tasks or processes, this automated program generation method can significantly reduce repetitive work and error rates, and improve call efficiency. (2) Modular design: This method realizes the modular design of the task call process. Each task is regarded as a module with its own initial state, pre-judgment script and result judgment script. This also makes it possible to adjust or optimize a single module during system design and maintenance without affecting the operation of the entire system, accelerating the process of problem solving and system optimization. (3) High flexibility and scalability: Because the extended finite state machine EFSM is used for modeling, the entire system is managed modularly, which not only reduces complexity but also improves scalability. As system requirements change, new task modules can be easily added on the existing basis, and existing modules can also be adjusted or deleted, which facilitates system improvement and expansion. (4) Predictability and controllability: This method provides a pre-judgment code segment and a result judgment code segment for each task, which makes the execution status of the task clearly predictable and allows more precise control and adjustment of the task process. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0049] Figure 1 The present invention is a flowchart of a method for automatically generating task calling codes according to a first embodiment of the present invention.

[0050] Figure 2 The present invention is a method for automatically generating task calling codes according to a specific flow chart of the present invention.

[0051] Figure 3 This is a diagram of the calling process in the test phase of the example.

[0052] Figure 4 It is a schematic diagram of procedure calls from various starting points. DETAILED DESCRIPTION

[0053] The following descriptions of the embodiments refer to the accompanying drawings to illustrate specific embodiments in which the present invention may be implemented.

[0054] Please refer to Figure 1 As shown, the first embodiment of the present invention provides a method for automatically generating a task calling code, including:

[0055] Step S1, determining the initial state of the task according to the overall calling process pre-modeled based on the extended finite state machine EFSM;

[0056] Step S2, generating a task sequence according to the initial state and the overall calling process;

[0057] Step S3, traversing the task sequence according to the preset pre-judgment code segment and result judgment code segment of the calling task, and generating a pre-judgment script and a result judgment script;

[0058] Step S4, generating and outputting a calling process code according to the task sequence, the pre-judgment script and the result judgment script.

[0059] It can be seen from the above steps that the embodiment of the present invention utilizes the overall calling process based on EFSM pre-modeling, and increases the dependency design between the execution tasks through the preset pre-judgment code segment and the result judgment code segment, which is more adaptable to the changes in the overall structure and conducive to continuous utilization; by configuring and determining the initial state of the task, the pipeline design can adapt to different scenario requirements.

[0060] Specifically, the extended finite state machine EFSM (Extended Finite State Machine) is an extension of a finite state machine, which describes the operating state of the system and the transition between states. It can be understood that an EFSM model consists of a set of states and a set of operations. Each state represents the specific situation of the system at a certain point in time, while the operation represents the transition path of the system from one state to another. The overall call process refers to all operations performed by the entire system in different states, as well as the transition path between states, that is, starting from the initial state of the system, by performing a series of operations, the system transitions between various states to reach the target state of completing a specific task. In the overall call process, the system performs operations according to the state transition rules defined by the EFSM model and determines the next state according to specific conditions.

[0061] When the embodiment of the present invention models the overall call process based on EFSM, tasks are split according to different purposes, tasks are divided into different stages, and different stages are named as different states of the overall call process to generate a state set of the overall call process. Specifically, it includes the following aspects:

[0062] Task splitting: Split tasks based on the overall calling process, based on the function, complexity, relevance or other factors of the task. The purpose of splitting tasks is to break down the complex calling process into smaller and more manageable parts for better modeling and implementation.

[0063] Phase division: For split tasks, they can be divided into different phases according to the order of tasks, dependencies, etc. Each phase may contain a group of related tasks, which have certain logical associations during the execution of the system.

[0064] Stage Naming: Give each stage a name that accurately reflects the function or responsibility of the stage so that the purpose of the stage can be clearly identified and described to facilitate subsequent understanding and communication.

[0065] Forming a state set: Treat the phases as different states of a process call and form a state set of the process call. A state set is a collection of different states that may appear during the execution of the system. Each state reflects a specific state or phase of the system and contains a set of related tasks. These states can be switched by the system during execution. The state set specifically includes:

[0066] (1) Input set: The input set is a collection of various inputs received during the execution of the system, including various trigger events received by the system, user input, external input, etc. These inputs can trigger state transitions or the execution of operations, causing the system to switch from one state to another.

[0067] (2) Dependency set: The dependency set is a collection of dependencies during the execution of the system. These dependencies can be other systems, services, libraries, or resources. The system requires dependencies to complete specific tasks or operations in a specific state.

[0068] (3) Event set: It is a set of events that trigger state transitions or operation executions during the execution of the system. These events can be internal events (such as timer triggering, condition satisfaction, etc.) or external events (such as message arrival, sensor data change, etc.). For each event, the corresponding processing logic needs to be defined, including state switching and execution of corresponding operations. Different events may cause the system to switch from one state to another or execute corresponding operations.

[0069] The following is an example of modeling the overall calling process based on EFSM.

[0070] A task call is the transfer of data and control from one part of the code to another. The transfer process not only has a direction, but also often depends on a certain context. In a complex call process, there are dependencies between multiple process calls. This dependency is often because the latter process call requires the output of the previous process call as part of the call input, that is, the need for data transfer.

[0071] To fully describe this relationship, we need to use EFSM. Using EFSM, the test process call is modeled as the following six-tuple {s, s0, v, i, o, t}

[0072] s: state set: divides the calling process into different stages, and each stage is named as a different state of the calling process, such as compilation environment preparation, test program preparation, tested program preparation, test execution, analysis execution, etc.

[0073] i: the set of input parameters of all calls;

[0074] o: the output set generated by all calls, such as files, etc.;

[0075] t: the set of events executed at each stage, as well as the preconditions, input set, output set, stage dependencies, etc. of the execution events;

[0076] When describing the tasks performed at each stage, a set of multiple attributes is used - {head_t,i_t,p_t,acts,o_t,tail_t}:

[0077] +head_t: dependent stage; indicates the previous stage that the current stage depends on

[0078] +i_t: input set, and i_t∈i; represents the input parameter set of the current stage, which may come from the output of the previous stage or external input

[0079] +p_t: Precondition; indicates the precondition for the current stage to be executed, which may depend on the output of the previous stage

[0080] +acts: A collection of events executed within a stage; it indicates a series of events that are specifically executed in the current stage

[0081] +o_t: The output set of the stage; it indicates the output generated in the current stage, which may be used in subsequent stages

[0082] +tail_t: enter the stage; indicates that after the current stage is completed, the next stage is entered

[0083] v variable collection

[0084] +iV_node:String[]

[0085] +cV_node:String[]

[0086] +oV_node:String[]

[0087] S0: Initial state defines where to start.

[0088] Please combine Figure 2 As shown, after the overall calling process is modeled based on EFSM, step S1 determines the initial state of the task according to the overall calling process, specifically including:

[0089] Step S11, reading the modeled overall call process: first, reading the state set (including input set, dependency set and event set) defined in the established overall call process model;

[0090] Step S12, determine the state transition path: carefully analyze the state set defined in the overall call process, check the transition path between the states, and determine under what conditions the system switches from one state to another;

[0091] Step S13, determine the initial input: determine the possible inputs at the start of the task based on the input set in the overall call process; these inputs may come from external systems, user operations, or other events. Consider which inputs will cause the starting state of the task to change, and adjust the starting state as needed;

[0092] Step S14, determine the initial state of the task: comprehensively consider the state transition path and possible initial inputs to determine the final initial state of the task. This initial state is used to start the task execution and enter the next state of the overall calling process.

[0093] It is understandable that a task sequence is a series of tasks or operations that need to be performed. These tasks may include various operations, such as generating code, performing certain calculations, etc. Step S2 generates a task sequence based on the initial state and the overall calling process, and its purpose is to define this task sequence to determine which operations the system needs to perform under a given initial state.

[0094] Specifically, the process of generating a task sequence according to the initial state and the overall calling process includes:

[0095] Step S21, generating a preliminary task sequence according to the input set and event set in the overall calling process and in combination with the state transition path;

[0096] Step S22, determining dependent tasks of each task in the preliminary task sequence according to the dependency set in the overall calling process;

[0097] Step S23, recalculating the execution order of the tasks to obtain the task sequence.

[0098] As mentioned above, the state transition path is the transition path between different states in the overall call process. Based on the input set and event set in the overall call process, consider which inputs or events will trigger the transition from one state to another, and organize to form a preliminary task sequence. Furthermore, in the overall call process, it is also necessary to determine which tasks are subject to dependency constraints. To ensure that the tasks can meet the required dependencies during execution, for each task in the preliminary task sequence, determine its dependent tasks based on the dependency set in the overall call process, and set a pointer or link to the dependent task; then use algorithms such as topological sorting to recalculate the execution order of the tasks to obtain the final task sequence.

[0099] For example, in a source code generation process, first generate a preliminary task sequence including tasks such as "generate data structure definition code", "generate business logic code", "generate user interface code", and "compile code"; then, based on the dependency relationship, determine that "generate business logic code" depends on "generate data structure definition code", "generate user interface code" depends on "generate business logic code", and "compile code" depends on all code generation tasks. After recalculating the execution order of the tasks, the final task sequence is obtained: "generate data structure definition code" -> "generate business logic code" -> "generate user interface code" -> "compile code". It can be understood that this process can be implemented on the Jenkins platform through Pipeline DSL (domain-specific language) and Jenkinsfile.

[0100] In addition, if an exception occurs during the execution of a dependent task or the precondition is not met, error handling or rollback operations are required. In the task sequence, corresponding exception handling tasks or rollback tasks can be defined to handle the abnormal situations of the dependency relationship. The generated task sequence can also be verified and tested to ensure that it meets expectations in actual execution. Test the execution process, input, and output of the task sequence to verify the correctness and performance of the task sequence.

[0101] After the task sequence is generated, the present embodiment traverses the task sequence in step S3 according to the preset pre-judgment code segment and result judgment code segment of the calling task to generate the pre-judgment code and result judgment code. The following first introduces the process of setting the pre-judgment code segment and result judgment code segment of the calling task.

[0102] Step S31, write a task call code segment according to the syntax of the task call platform. In this embodiment, the pipeline syntax and Groovy language of the Jenkins platform are used. Taking the pipeline syntax of Jenkins as an example, tasks can be defined and executed by stages and steps. Each task corresponds to a stage, and the corresponding step is used to call the task.

[0103] Step S32, in each task calling code segment, add a pre-judgment code segment for the dependent task according to the dependency relationship. Specifically, a conditional statement (such as an if statement) can be used to check the execution status or result of the dependent task to determine whether the current task can be executed.

[0104] Step S33, in each task calling code segment, add a result judgment code segment for judging the task execution result. By adding the result judgment code segment, the execution status, log output or other signs of the task can be checked, and corresponding measures can be taken according to the execution result of the task.

[0105] After the pre-judgment code segment and the result judgment code segment of the calling task are pre-set according to the above process, they can be used to traverse the task sequence. A common method is to use a loop structure (such as a for loop or a foreach loop) to traverse the task sequence. During the traversal process, each task in the task sequence is accessed in turn. For each task, before execution, the preset pre-judgment code segment is first applied to generate a corresponding pre-judgment script, and the pre-judgment script includes conditional statements, loop structures, etc. Then the pre-judgment script is executed to determine whether the pre-judgment condition is met (that is, whether the dependency relationship for executing the task is met). If the pre-judgment condition is met, the task is executed. After the current task is executed, the preset result judgment code segment is applied to generate a corresponding result judgment script. The result judgment script is used to determine the result generated after executing each task, such as whether the task is successfully completed, whether an exception occurs, etc. The result judgment script can determine the execution result of the task based on the execution log, return value, output file, etc. of the task. Then the result judgment script is executed, and corresponding processing and subsequent operations are performed according to the judgment result.

[0106] After generating the pre-judgment script and the result judgment script, step S4 generates the final calling process code according to the task sequence and the pre-judgment script and the result judgment script. The calling process code includes the actual operation of executing the task, such as function call, method call, script command, etc., as well as the control logic related to the task call, such as pre-judgment and result judgment.

[0107] It should be noted that the pre-judgment code segment and the result judgment code segment refer to specific code segments written in the task call process to judge the pre-conditions and execution results of the task execution. These code segments are usually expressed in a specific syntax or logical structure, used to describe the judgment conditions and logic, and cooperate with the task sequence to make decisions on task calls. The pre-judgment script and the result judgment script are generated script files or functions, which are used to execute the logic of the pre-judgment code segment and the result judgment code segment. These scripts are usually called or executed to judge the execution conditions and results of the task, and perform corresponding processing and decisions based on the judgment results during the task call process.

[0108] The generated calling process code will be output to the specified path to facilitate the subsequent quick creation of the Jenkins pipeline. By adding the aforementioned output management, it is like the log interface in program design, which facilitates the output of process information.

[0109] It is understandable that the design of the pipeline is actually the call of a series of sequential tasks (or processes, consisting of multiple instructions or functions). According to the purpose of task execution, the pipeline is divided into different stages. It can be found that in different scenarios, the required stages are different, but the dependency between the stages is unchanged. In other words, different starting stages of tasks are required according to different scenarios. Taking the pipeline to implement continuous integration testing as an example, Figure 3 Several common testing phase calling processes are listed below.

[0110] Compoment Y: Based on the test results that have been generated, further analyze the results, group the results, etc. For example, this analysis was previously done manually, but now it is automated.

[0111] Compoment W: Bind the analysis and test binding processes to perform automatic analysis after testing.

[0112] Compoment X: The test object is dynamically generated or is a dynamic code repository. The latest code must be downloaded before testing.

[0113] Compoment Y: The process of testing and analyzing a dynamic repository in an environment where no testing tools are installed.

[0114] Compoment Z: Establish an automatically triggered test pipeline, such as a pipeline design for automatic testing and analysis after the developer submits the code, such as a Jenkins pipeline, which will start a container environment after being triggered.

[0115] If the overall modeling based on the EFSM model is not performed as in the embodiment of the present invention, and the initial state is not flexibly configured, it may be necessary to write five different task call design scripts. If some test and analysis processes are added, all scripts must be rewritten. For example Figure 4 As shown, 7 starting entry points are planned for procedure calls, and two more analysis procedures are planned.

[0116] Therefore, the advantages of modeling the overall calling process based on the EFSM model in the embodiment of the present invention are:

[0117] Added dependency design between execution tasks, just like linked list design in data structure, which is more adaptable to changes in the overall structure and conducive to continuous use;

[0118] By configuring the initial state, the need to start from different tasks in different scenarios can be met, the cost of repeated design in multiple scenarios can be reduced, and the pipeline design can adapt to the needs of different scenarios.

[0119] Corresponding to the method for automatically generating a task calling code described in the first embodiment of the present invention, the second embodiment of the present invention provides an apparatus for automatically generating a task calling code, including:

[0120] An initial state determination module is used to determine the initial state of the task according to the overall calling process pre-modeled based on the extended finite state machine EFSM;

[0121] A task sequence generation module, used for generating a task sequence according to the initial state and the overall calling process;

[0122] A script generation module, used to traverse the task sequence according to the preset pre-judgment code segment and result judgment code segment of the calling task, and generate a pre-judgment script and a result judgment script;

[0123] The output module is used to generate and output the calling process code according to the task sequence, the pre-judgment script and the result judgment script.

[0124] Preferably, the initial state determination module is specifically used to: read the state set in the established overall calling process; determine the state transition path according to the state set; determine the initial input according to the input set in the overall calling process; determine the initial state of the task according to the state transition path and the initial input; the state set specifically includes: an input set, which is a set of various inputs received during the system execution process; a dependency set, which is a set of dependency relationships during the system execution process; an event set, which is a set of events that trigger state transitions or operation executions during the system execution process.

[0125] Preferably, the task sequence generation module is specifically used to: generate a preliminary task sequence based on the input set and event set in the overall calling process, combined with the state transition path; determine the dependent tasks of each task in the preliminary task sequence based on the dependency set in the overall calling process; recalculate the execution order of the tasks to obtain the task sequence.

[0126] Preferably, the script generation module is specifically used to: sequentially access each task in the task sequence;

[0127] For each task, before execution, a preset pre-judgment code segment is applied to generate a corresponding pre-judgment script, and the pre-judgment script is executed to determine whether the pre-judgment conditions are met. If the pre-judgment conditions are met, the task is executed; after the task is executed, a preset result judgment code segment is applied to generate a corresponding result judgment script, and the result judgment script is executed to make a judgment based on the execution result of the task, and perform corresponding processing and subsequent operations based on the judgment result.

[0128] Preferably, the process of presetting the pre-judgment code segment and the result judgment code segment is:

[0129] Write the task calling code segment according to the syntax of the task calling platform;

[0130] In each task calling code segment, add a pre-judgment code segment for the dependent tasks based on the dependency relationship;

[0131] In each task calling code segment, add a result judgment code segment for judging the task execution result.

[0132] Preferably, the device for automatically generating task calling code also includes a modeling module, which is used to model the overall calling process based on the extended finite state machine EFSM; the modeling module is specifically used to: split the tasks according to the overall calling process; divide the split tasks into different stages and name them; use different stages as different states of the process call to form a state set of the process call.

[0133] Preferably, the calling process code includes the actual operation of executing the task and the control logic related to the task calling.

[0134] Corresponding to the method for automatically generating task calling codes described in the first embodiment of the present invention, the third embodiment of the present invention further provides a computer device, the computer device comprising:

[0135] one or more processors;

[0136] Memory;

[0137] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the method for automatically generating task calling codes described in Embodiment 1 of the present invention.

[0138] Corresponding to the method for automatically generating task calling code described in the aforementioned embodiment 1 of the present invention, embodiment 4 of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored computer program; wherein the computer program controls the device where the computer-readable storage medium is located to execute the method for automatically generating task calling code as described in embodiment 1 of the present invention when running.

[0139] Preferably, the computer program can be divided into one or more modules / units (such as computer program 1, computer program 2, ...), and the one or more modules / units are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units can be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program in the device.

[0140] The processor may be a central processing unit (CPU), or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor, or the processor may be any conventional processor. The processor is the control center of the device, and various parts of the device are connected using various interfaces and lines.

[0141] The memory mainly includes a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function, etc., and the data storage area can store related data, etc. In addition, the memory can be a high-speed random access memory, or a non-volatile memory, such as a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, and a flash card (Flash Card), etc., or the memory can also be other volatile solid-state storage devices.

[0142] It should be noted that the above-mentioned device may include but is not limited to a processor and a memory, which can be understood by those skilled in the art.

[0143] For the working principle and process of the above embodiment, please refer to the description of the above embodiment of the present invention, which will not be repeated here.

[0144] It can be seen from the above description that compared with the prior art, the beneficial effects of the present invention are:

[0145] Streamlining and automation: The system automatically generates task call codes, eliminating the need to manually write a large amount of code, greatly improving the efficiency of task calls and reducing errors caused by manual code writing. At the same time, for complex systems, especially those containing a large number of tasks or processes, this automated program generation method can significantly reduce duplication of work and error rates, and improve call efficiency.

[0146] Modular design: This method realizes the modular design of the task calling process. Each task is regarded as a module, with its own initial state, pre-judgment script and result judgment script. This also makes it possible to adjust or optimize a single module during system design and maintenance without affecting the operation of the entire system, which speeds up the process of problem solving and system optimization.

[0147] High flexibility and scalability: Because the extended finite state machine EFSM is used for modeling, the entire system is managed in a modular manner, which not only reduces complexity but also improves scalability. As system requirements change, new task modules can be easily added to the existing ones, and existing modules can also be adjusted or deleted, which facilitates system improvement and expansion.

[0148] Predictability and controllability: This method provides a pre-judgment code segment and a result judgment code segment for each task, which makes the execution status of the task clearly predictable and allows more precise control and adjustment of the task process.

[0149] The above disclosure is only the preferred embodiment of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.

Claims

1. A method for automatically generating task calling code, characterized in that: include: Determine the initial state of the task according to the overall calling process pre-modeled based on the extended finite state machine EFSM; Generate a task sequence according to the initial state and the overall calling process; According to the preset pre-judgment code segment and result judgment code segment of the calling task, traverse the task sequence to generate a pre-judgment script and a result judgment script; The calling process code is generated and outputted according to the task sequence, the pre-judgment script and the result judgment script.

2. The method according to claim 1, characterized in that The initial state of the task is determined according to the overall calling process based on the extended finite state machine EFSM pre-modeling, specifically including: Read the status set of the established overall call process; Determine a state transition path according to the state set; Determine the initial input based on the input set in the overall calling process; Determining an initial state of the task according to the state transition path and the initial input; The state set specifically includes: An input set, wherein the input set is a set of various inputs received during the execution of the system; A dependency set, wherein the dependency set is a set of dependency relationships during the execution of the system; An event set is a set of events that trigger state transition or operation execution during system execution.

3. The method according to claim 2, characterized in that The generating of the task sequence according to the initial state and the overall calling process specifically includes: Generate a preliminary task sequence based on the input set and event set in the overall calling process and in combination with the state transition path; Determine the dependent tasks of each task in the preliminary task sequence according to the dependency set in the overall calling process; The execution order of the tasks is recalculated to obtain the task sequence.

4. The method according to claim 1, characterized in that: The process of traversing the task sequence according to the preset pre-judgment code segment and result judgment code segment of the calling task to generate the pre-judgment code and result judgment code specifically includes: Visit each task in the task sequence in turn; For each task, before execution, a preset pre-judgment code segment is applied to generate a corresponding pre-judgment script, and the pre-judgment script is executed to determine whether the pre-judgment condition is met. If the pre-judgment condition is met, the task is executed; After the task is executed, a preset result judgment code segment is applied to generate a corresponding result judgment script, and the result judgment script is executed to make a judgment based on the execution result of the task, and perform corresponding processing and subsequent operations based on the judgment result.

5. The method according to claim 4, characterized in that The process of presetting the pre-judgment code segment and the result judgment code segment is: Write the task calling code segment according to the syntax of the task calling platform; In each task calling code segment, add a pre-judgment code segment for the dependent tasks based on the dependency relationship; In each task calling code segment, add a result judgment code segment for judging the task execution result.

6. The method according to claim 1, characterized in that The process of modeling the overall calling process based on the extended finite state machine EFSM is: Split the tasks according to the overall calling process; Divide the split tasks into different stages and name them; Different stages are regarded as different states of the process call to form a state set of the process call.

7. The method according to claim 1, characterized in that The calling process code includes the actual operation of executing the task and the control logic related to the task calling.

8. A device for automatically generating task calling codes, characterized in that: include: An initial state determination module is used to determine the initial state of the task according to the overall calling process pre-modeled based on the extended finite state machine EFSM; A task sequence generation module, used for generating a task sequence according to the initial state and the overall calling process; A script generation module, used to traverse the task sequence according to the preset pre-judgment code segment and result judgment code segment of the calling task, and generate a pre-judgment script and a result judgment script; The output module is used to generate and output the calling process code according to the task sequence, the pre-judgment script and the result judgment script.

9. A computer device, characterized in that: include: one or more processors; Memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the method for automatically generating task calling codes according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program; wherein, when the computer program is run, it controls the device where the computer-readable storage medium is located to execute the method for automatically generating task calling codes according to any one of claims 1 to 7.