Method for driving dynamic matching of data model by open script
Through the open script-driven dynamic matching method of data models, the problem that data in the existing technology is not fixed by unified online management and data processing codes is solved, dynamic matching and adjustment of data models is realized, and data management and processing efficiency is improved. Simplifies operations and ensures data security.
Patent Information
- Application Number
- CN202411440103.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-10-15
AI Technical Summary
In the existing technology, in engineering design, mathematical applications and AI model processing, data is not managed online, resulting in missing data and difficulty in processing complex data. The data processing code is fixed, and it cannot flexibly respond to future needs, which increases the workload of code modification. and platform complexity.
The open script-driven dynamic matching method is adopted, and dynamic matching and adjustment of the data model is achieved by calling script checking programs, parameter code conversion programs and script running programs, and unified online management of data and data interaction between multiple models.
It improves the efficiency of data management and processing, simplifies designer operations, improves design efficiency, ensures data security, and reduces the workload of code modification and platform complexity.
Smart Images

Figure CN119473495A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of software integration calling and processing, and in particular relates to a method for dynamic matching of open script-driven data models. Background Art
[0002] In the process of engineering design, mathematical application, AI model processing, etc., due to the strong subject specialization, some data are not uniformly managed online. Designers classify and manage them locally in the form of Excel tables and pass them to others. In addition, data unit conversion, data extraction, type conversion and other processing are generally solidified in the code of the application platform and cannot be changed, or the relationship between data is realized by configuring calculation formulas. This type of data storage management and processing is mostly simple and targeted, suitable for a certain situation. In the face of complex data processing, frequent adjustments, structural customization and reorganization, etc., the original code needs to be modified on a large scale or even redeveloped to achieve targeted adjustment of data.
[0003] This method has the following problems: a) Some scientific research data are isolated and scattered among designers in the form of Excel spreadsheets, without unified management and unable to form a system, which can easily lead to the loss of R&D data; b) The application platform is limited to data in a certain application scenario, and the processing method is solidified in the current project code, with poor portability. At the same time, it is mostly suitable for simpler data processing and cannot meet more complex and diverse data processing needs; c) The application platform's code development for data processing is generally targeted at current stage needs, and cannot flexibly respond to future data processing needs, and cannot be dynamically adjusted at any time. There is a risk of a large workload for code modification, and even increases the complexity of the overall platform design and reduces the platform's operating efficiency. Summary of the invention
[0004] Purpose of the invention: The present invention proposes an open script-driven data model dynamic matching method for improving the management and processing of scientific research data in relevant application fields, while simplifying designer operations, improving design efficiency, and ensuring data security.
[0005] The present application provides a method for dynamic matching of an open script-driven data model, the method comprising:
[0006] Call the script checker to compile the script program file and check whether there are syntax errors in the customized script calculation module;
[0007] If it is correct, call the parameter code conversion program to convert the parameters of the parameter model defined by the backend language into a format that conforms to the Python language specification, and fill the converted Python code into the input module of the script program to complete the code update, save and display the complete code of the current script program;
[0008] According to the calculation requirements, enter the data of some parameters in the parameter model, click Calculate, call the script to run the program, which will fill the entered parameter data into the input module, then read the latest script program file, compile the code, execute the main function, obtain the calculation results, and return the response object in the form of a dictionary;
[0009] Get the response result, parse the response content, and determine whether the calculation is successful based on the execution status in the result;
[0010] If successful, locate each parameter according to the primary key of the parameter dictionary, overwrite the old data with the new data obtained by processing or assign a value directly, and perform object type conversion at the same time, map the parameter dictionary back to the initial parameter object, and output it as a whole. At this time, the target parameter model with data is obtained, and the dynamic adjustment and matching of the model is completed.
[0011] Preferably, the calling of the script checking program, compiling the script program file, and checking whether the customized script calculation module has a syntax error, further includes:
[0012] Design configurable data model templates, parameterize data through data model templates, standardize the format and data structure of parameter objects in the data model, and users can set the properties of parameter objects according to their needs;
[0013] Based on the designed data model template, create the target parameter model, assign a unique ID to each created parameter model, realize model location search, and interconnect the data between the parameter models. Then, add each parameter object to the created parameter model according to the parameter calculation requirements.
[0014] Call the parameter conversion program to adjust the data structure of the parameter object, expand and reorganize its attributes, and obtain a standardized data structure;
[0015] Based on the standardized data structure, each parameter object in the current parameter model is mapped to a parameter dictionary supported by Python. If some parameters do not exist in the parameter model, the parameter data of other existing models must be read.
[0016] Preferably, based on the standardized data structure, each parameter object in the current parameter model is mapped to a parameter dictionary supported by Python. If some parameters do not exist in the parameter model and parameter data of other existing models need to be read, the method further includes:
[0017] Design a script program template to complete the calculation and adjustment of some parameters in the parameter model. At the same time, specify the program entry main function in the script program template;
[0018] The input module as a whole uses an empty set as program input; in the customized script calculation module, according to the parameter data processing requirements, based on the Python language, the code logic is written and the entire program is saved.
[0019] Preferably, the attributes of the parameter object include parameter name, identifier, value type, unit, and type.
[0020] Preferably, the data model has basic add, delete and modify functions.
[0021] Preferably, the method further comprises:
[0022] If some parameters in the parameter model need to read parameter data of other existing models, they can be obtained based on the unique identifier of the parameter.
[0023] Preferably, the script program consists of an input module and a customized script calculation module, and the entire script program template is stored in a specified path in .py format.
[0024] Preferably, the format that complies with the Python language specification is in the form of a parameter dictionary.
[0025] The beneficial effects of the present invention are as follows:
[0026] Design flexible and configurable data model templates, parameterize data tables, and realize online unified management of data tables and data in the form of parameter models (i.e. data models), as well as data interaction between multiple models (i.e. multiple data tables). In addition, open script program templates are used to complete the location search of parameter models and customized processing of parameter data, thereby realizing dynamic matching and adjustment of data models, effectively improving data management efficiency.
[0027] After the back-end developers embed this method into the application platform, there is no need to perform other subsequent adjustments and operations. Designers only need to create models, customize script programs, enter data, click save, click calculate, and other operations in the visual application platform. There is no need to worry about the back-end operation status. The front and back ends are separated and independent. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 The present invention is a flowchart of a method for dynamic matching of data models driven by an open script. DETAILED DESCRIPTION
[0029] See also Figure 1 The present invention proposes a method for dynamic matching of an open script-driven data model, which comprises the following steps:
[0030] Based on the data table, users parameterize the data and design flexible and configurable data model templates. The data model is composed of various parameter objects, also known as parameter models. According to the needs, create a target parameter model, map the parameter objects in the model to a general parameter dictionary structure through the parameter conversion program, and complete the customized script calculation module code editing based on the unified data format and script program template to achieve data conversion, extraction, calculation and other processing of the current parameter model. Finally, the script driver completes the program inspection, operation, acquisition of processing results and mapping back to the original parameter object, and outputs the processed target parameter model, and finally completes the model positioning, dynamic adjustment and matching. The specific implementation process is divided into the following steps:
[0031] The first step is to design a configurable data model template, parameterize the data, and standardize the format and data structure of parameter objects in the data model. Users can set the parameter name, identifier, value type, unit, type and other attributes of the parameter object according to their needs. The data model has basic functions such as addition, deletion and modification.
[0032] The second step is to create a target parameter model based on the designed data model template, assign a unique ID to each created parameter model, implement model location search, and interconnect the data between parameter models. Then, according to the parameter calculation requirements, add each parameter object to the created parameter model.
[0033] The third step is to call the parameter conversion program to adjust the data structure of the parameter object, expand and reorganize its attributes, and obtain a standardized data structure.
[0034] The fourth step is to map each parameter object in the current parameter model into a parameter dictionary supported by Python based on the standardized data structure. If some parameters in the parameter model need to read parameter data from other existing models, they are obtained based on the parameter unique identifier. Otherwise, proceed to the fifth step.
[0035] The fifth step is to design a script program template to complete the calculation and adjustment of some parameters in the parametric model. The script program is mainly composed of an input module and a customized script calculation module. The entire script program template is stored in the specified path in .py format. At the same time, the program entry main function must be specified in the template.
[0036] In the sixth step, the input module as a whole uses an empty set as the program input; in the customized script calculation module, according to the parameter data processing requirements, based on the Python language, complete the code logic writing and save the entire program.
[0037] The seventh step is to call the script checker to compile the script program file and check whether there are syntax errors in the customized script calculation module. If the compilation fails, return to the sixth step to make corrections, otherwise, go to the eighth step.
[0038] In the eighth step, the parameter code conversion program is called to convert the parameters of the parameter model defined by the backend language into the Python definition format, and the format is the parameter dictionary form of the fourth step, and the converted Python code is filled into the input module of the script program to complete the code update, save and display the complete code of the current script program.
[0039] In the ninth step, according to the calculation requirements, enter the data for some parameters in the parameter model, click Calculate, call the script to run the program, the script program will fill the entered parameter data into the input module, then read the latest script program file, compile the code, execute the main function, obtain the calculation results, and return the response object in the form of a dictionary.
[0040] Step 10. Get the response result, parse the response content, and determine whether the calculation is successful based on the execution status in the result. If it fails, return to step 8 to check whether there are any logical problems in the code. Otherwise, go to step 11.
[0041] In the eleventh step, each parameter is located according to the primary key of the parameter dictionary, and the old data is overwritten with the new data obtained through processing or directly assigned. At the same time, object type conversion is performed, and the parameter dictionary is mapped back to the initial parameter object and output as a whole. At this time, the target parameter model with data is obtained, and the dynamic adjustment and matching of the model is completed.
[0042] In other embodiments of the present application, the user creates a target parameter model at the data model template of the application according to the data table and adds a parameter object to the model. The application automatically completes the conversion between data formats according to the parameter conversion program, and then completes the code logic editing and parameter data entry at the script model of the application according to the data processing requirements. Click Save and Calculate, and the script driver and script checker will automatically complete the code update, file compilation, obtain calculation results, map back to parameter objects and model output. The specific process is divided into the following steps:
[0043] In the first step, the user adjusts the data model template according to the data information in the data table. The user can add, delete, and modify data classification, attributes, types, and other information to complete the data model data table design.
[0044] The second step is to embed the data model template into the web application design. The user creates a target parameter model in the data model template and adds corresponding parameter objects according to the data types in the data table.
[0045] The third step is to add the parameter conversion program to the application, bind the conversion program to the "Save" component of the application, click Save, and the system will assign a unique identification ID to the parameter model and a unique identification KEY value to its parameter object, convert the parameter object into a parameter dictionary format, and store the relevant information in the database.
[0046] In the fourth step, some parameter models need to read other existing model data. The parameter conversion program also adds "model ID + parameter KEY" positioning search to achieve interconnection between data models. At the same time, each parameter object in the current parameter model is mapped to a parameter dictionary supported by Python to achieve unified online management of parameter models.
[0047] The fifth step is to integrate the script program template into the application system parameter model management, based on the Python language, specify the input module, customized script calculation module, program entry and other information.
[0048] In the sixth step, users only need to locate and read parameters according to the identification KEY of each parameter in the main program area of the customized script calculation module of the script program template, and complete the code processing logic editing according to data processing requirements, without doing any operation on the input module.
[0049] In the seventh step, the script check program is stored in the specified path of the server where the application system is located, and its basic information is configured in the application project. The subsequent driver service executes the check program according to the configuration information, and then compiles the script program file to check whether there are syntax errors in the customized script calculation module. If the compilation fails, return to step 6 for correction, otherwise, go to step 8.
[0050] The eighth step is to add the parameter code conversion program to the application project. It can convert the parameters of the parameter model defined in languages such as C#, Java, or C++ into Python definition format, fill the converted Python code into the input module of the script program, store the entire script program calculation file in the specified path of the server, and configure its basic information in the application project.
[0051] The ninth step is to complete the script driver integration script check and script program calculation based on Python language; deploy the script driver in the server where the application runs, publish the script driver in the server, so that the driver service is always in running state, ready to drive the execution of script program calculation files at any time; bind the script driver to the application system, and configure its execution path and IP address and other related information in the application project; the application binds the script program to the "Calculation" component, and the user only needs to complete the data entry in the application according to the parameter data entry requirements and click "Calculate", and the parameter code conversion program in the eighth step can be called to automatically fill the data into the input module to complete the code update, and establish a connection with the script driver according to the configured communication information, trigger the driver service, implement script program inspection, main function execution, obtain calculation results, and return the response object in the form of a dictionary.
[0052] In the tenth step, parse the returned response result and determine whether the calculation is successful based on the execution status in the result. If it fails, return to the sixth step to check whether there are any logical problems in the code. Otherwise, go to the eleventh step.
[0053] In the eleventh step, the new data is assigned according to the unique identifier KEY of the parameter, and the object type is converted at the same time, and the parameter dictionary is mapped back to the initial parameter object, and finally a parameter model with target data is obtained.
[0054] In a feasible implementation, taking the rotor system R&D platform developed by a certain research institute as an example, in order to solve the problem of completing the processing and circulation of various professional data in the form of data tables in the existing rotor design system R&D model, and to unify the management of scientific research data and make the whole process of rotor design unified online design and management, the research institute deployed and built a rotor system R&D platform, and used the mainstream Web framework F l ask and Python language to embed the method into the rotor system R&D platform according to the implementation plan steps in the present invention, and provided it to the model chief engineer, project leader and designer for use. Now, taking this scenario as an example, the implementation process of this application is explained:
[0055] In the first step, the model chief designer determines the data model template information according to the rotor design working mode and the scientific research data flow profile, and divides the scientific research data into two categories: professional parameters (input by designers) and reference parameters (upstream parameters). The professional parameters are further divided into input parameters and output parameters. The output parameters are generally used as reference parameters for mutual reading of data between models. It is stipulated that each parameter should contain attributes such as parameter name, identification, value type, unit, parameter type, and required items, so that the configurable data model template becomes concrete and customized.
[0056] In the second step, the back-end developers design the corresponding parameter model data table in the database according to the data model template information, store the parameter model information and its parameter objects, and embed the interface design code of the data model template into the application system to make the data model template visual and operable. The designer completes the creation of the target parameter model and the addition of parameter objects based on the visual data model template.
[0057] In the third step, the back-end developer adds the parameter conversion program to the project code structure of the platform, and expands and adjusts its own general basic type IOParm according to the determined parameter object attributes, completing the mapping of the parameter object to a parameter dictionary, whose ID attribute corresponds to the parameter model identifier, and the KEY attribute corresponds to the parameter object identifier.
[0058] The fourth step is to complete the acquisition and assignment of existing model data based on the four attributes of the IOParm data type, namely Value, OriginalValue, KEY and ID. In addition, the adjusted parameter conversion program needs to be bound to the Button component of the application front end. The designer clicks the "Save" button at the parameter model creation to trigger the parameter conversion program and realize its series of functions.
[0059] In the fifth step, the back-end developer integrates the script program template into the front-end interface of the parameter model management of the application system, and can view the parameter object information of the parameter model at any time.
[0060] In the sixth step, based on the Python language, the designer only needs to locate and read the parameters according to the identification KEY of each parameter in the main program area of the customized script calculation module of the script program template, and complete the code processing logic editing according to the data processing requirements, and output the parameter object of the entire data model as a result set, without any operation on the input module inputs set.
[0061] In the seventh step, the back-end developer stores the script check program in the specified path of the server where the application system is located, and adds the check program related information to the web.conf ig file of the application project.
[0062] In the eighth step, the back-end developer adds the parameter code conversion program to the project code structure of the platform. The parameter code conversion program covers multiple languages to Python definition formats. The parameter model of the platform is defined in C# language. The conversion program can locate the corresponding Python format conversion according to the code ID of the C# language, and add each parameter object in the converted Python-defined parameter model to the input module inputs collection of the script program. In addition, the entire script program calculation file (.py file) needs to be stored in the specified path of the server, and its basic information must be configured in the web.confi g file of the application project.
[0063] In the ninth step, the back-end developer deploys the script driver (script check and script program calculation have been integrated) in the server where the application is running, publishes the script driver as a web service in the server, keeps the driver service running, and uses enumeration to configure the driver execution path and its IP address and other related information in the application project, completes the binding of the script driver with the application system, and then creates an HttpWeb request based on the HttpWebRequest class, passes in the service path of the script driver, and establishes a connection between the script program and the script driver. In addition, the script program edited in the sixth step needs to be bound to the front-end "Calculate" Button component. Designers only need to complete data entry in the application according to the parameter data entry requirements and click the "Calculate" button to automatically fill the data into the input module of the script program, complete the code update, and establish a connection with the script driver according to the configured communication information, trigger the driver service, implement script program inspection, main function execution, obtain calculation results, and return the response object in the form of a dictionary.
[0064] In the tenth step, the JsonConvert.DeserializeObject() function encapsulated by the ServiceMessage class deserializes the response content, and then obtains the execution status and calculation results to complete the parsing.
[0065] In the eleventh step, based on the parameter conversion program that has been set up, the system automatically assigns new data according to the unique identifier KEY of the parameter, and completes the conversion of the parameter type, and finally obtains a parameter model with target data.
[0066] It should be noted that:
[0067] Design flexible and configurable data model templates, parameterize data tables, and realize online unified management of data tables and data in the form of parameter models (i.e. data models), as well as data interaction between multiple models (i.e. multiple data tables). In addition, open script program templates are used to complete the location search of parameter models and customized processing of parameter data, thereby realizing dynamic matching and adjustment of data models, effectively improving data management efficiency.
[0068] After the back-end developers embed this method into the application platform, there is no need to perform other subsequent adjustments and operations. Designers only need to create models, customize script programs, enter data, click save, click calculate, and other operations in the visual application platform. There is no need to worry about the back-end operation status. The front and back ends are separated and independent.
[0069] The open script-driven data model dynamic matching method of the present application has the characteristics of strong portability, large reuse, easy modification, and light weight. It is suitable for multiple application scenarios such as spacecraft development, rotor design, calculus processing, and dynamic engineering calculations. It can be flexibly embedded in various application system platforms to optimize the data processing mode of the application system. The data model designed in the present method converts the locally managed data tables into unified online storage and management to form a system to achieve scientific digital management; the parameter code conversion program designed in the present method matches the data models defined in multiple languages, and can be fine-tuned according to actual conditions to achieve code conversion between different languages; after the open script program designed in the present method is embedded in the application platform, the data flow speed and accuracy are effectively improved, which simplifies many manual operations, and can realize multiple rounds of dynamic processing of data to obtain a lot of valuable data information, while improving the implementation effect of the application system platform.
Claims
1. A method for dynamic matching of data models driven by an open script, characterized in that: The method comprises: Call the script checker to compile the script program file and check whether there are syntax errors in the customized script calculation module; If it is correct, call the parameter code conversion program to convert the parameters of the parameter model defined by the backend language into a format that conforms to the Python language specification, and fill the converted Python code into the input module of the script program to complete the code update, save and display the complete code of the current script program; According to the calculation requirements, enter the data of some parameters in the parameter model, click Calculate, call the script to run the program, which will fill the entered parameter data into the input module, then read the latest script program file, compile the code, execute the main function, obtain the calculation results, and return the response object in the form of a dictionary; Get the response result, parse the response content, and determine whether the calculation is successful based on the execution status in the result; If successful, locate each parameter according to the primary key of the parameter dictionary, overwrite the old data with the new data obtained by processing or assign a value directly, and perform object type conversion at the same time, map the parameter dictionary back to the initial parameter object, and output it as a whole. At this time, the target parameter model with data is obtained, and the dynamic adjustment and matching of the model is completed.
2. The method according to claim 1, characterized in that The calling of the script checking program, compiling the script program file, and checking whether there is a syntax error in the customized script calculation module also includes: Design configurable data model templates, parameterize data through data model templates, standardize the format and data structure of parameter objects in the data model, and users can set the properties of parameter objects according to their needs; Based on the designed data model template, create the target parameter model, assign a unique ID to each created parameter model, realize model location search, and interconnect the data between the parameter models. Then, add each parameter object to the created parameter model according to the parameter calculation requirements; Call the parameter conversion program to adjust the data structure of the parameter object, expand and reorganize its attributes, and obtain a standardized data structure; Based on the standardized data structure, each parameter object in the current parameter model is mapped to a parameter dictionary supported by Python. If some parameters do not exist in the parameter model, the parameter data of other existing models must be read.
3. The method according to claim 2, characterized in that Based on the standardized data structure, each parameter object in the current parameter model is mapped to a parameter dictionary supported by Python. If some parameters do not exist in the parameter model and the parameter data of other existing models need to be read, the following is also included: Design a script program template to complete the calculation and adjustment of some parameters in the parameter model. At the same time, specify the program entry main function in the script program template; The input module as a whole uses an empty set as program input; in the customized script calculation module, according to the parameter data processing requirements, based on the Python language, the code logic is written and the entire program is saved.
4. The method according to claim 3, characterized in that The attributes of the parameter object include parameter name, identifier, value type, unit, and type.
5. The method according to claim 3, characterized in that: The data model has basic add, delete and modify functions.
6. The method according to claim 3, characterized in that The method further comprises: If some parameters in the parameter model need to read parameter data of other existing models, they can be obtained based on the unique identifier of the parameter.
7. The method according to claim 3, characterized in that The script program consists of an input module and a customized script calculation module. The entire script program template is stored in the specified path in .py format.
8. The method according to claim 3, characterized in that The format that complies with the Python language specification is the parameter dictionary format.
Citation Information
Patent Citations
Data processing method and device, storage medium and electronic equipment
CN115904525A
Dynamic script execution algorithm based on CSharp script compiling
CN116126343A
Business script rendering method and device, storage medium and electronic equipment
CN117873463A
Code example generation method and device, equipment, medium and program product
CN117931295A
Method and system for exporting database table into python executable script
CN118132563A
Cited By
Code associated file searching method and device, equipment and storage medium
CN120336266A