Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the Application of document-driven Development pattern in AIMS

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on "how to understand the application of document-driven development pattern in AIMS". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to understand the application of document-driven development pattern in AIMS.

1. The characteristics of AI interface development.

Unlike the traditional API CRUD interface development, the AI development model usually includes the following steps:

Data cleaning

Model training

Parameter tuning

API is online.

The first three items are the strengths of our group and the focus of our work. But in practice, it is the launch of API that consumes most of our energy. Most of the AIMS project teams are engaged in the work related to the direction of AI, and they are not very familiar with the related libraries flask and tornado of API, which leads to developers need to spend a lot of time to understand the content related to network programming, and the quality of the programs developed may not be very high. Moreover, after the interface development, you also need to prepare a Swagger UI to the front-end developers, which is also a heavy work. In order to solve the pain point problem described above, AI interface development needs to meet the following two characteristics and requirements:

The core function of API is ready-made.

API development effort needs to be minimized.

two。 Document-driven development model

We found that the interface document of API already contains all the information about implementing the API interface. In other words, the information entropy of the API interface document is the same as that of the API interface code. Therefore, we only need to complete one item in the code or document, and the other item can be automatically generated by the framework, which avoids the problem of repeating the same thing twice. Considering that the document trumps the code in terms of readability, ease of writing, and maintainability, we decided to write the document and then generate the corresponding code based on the document.

We refer to the OpenAPI Specification3.0.1 standard, and JSON Schema defines a set of API description language, based on which developers write API documents. When the document is completed, the development of API is also completed, which greatly saves the development workload of API interface. After a preliminary estimate, using document-driven mode to develop an API interface can usually reduce the workload by 40% and 70%.

3. Introduction to AIMS framework

To implement the document-driven development model, AIMS implements a set of Web back-end frameworks based on tornado, as shown in the following figure.

3.1. Application Router component

Every API has a path, a regular expression [1]. All paths of multiple API in a microservice form a list of API paths.

When Application Router receives a request, it looks in the routing table based on the URI in the request. If it matches to a Request Handler, the routing module forwards the request to the Request Handler of the response. If all paths do not match, a 404 result [2] is returned.

3.2. Request Handler component

Request Handler processes responses from Application Router and is the core of the AIMS architecture, while Document is the core of Request Handler. In the AIMS architecture, Document refers to the document of the function, namely _ _ doc__. Request Handler is generated dynamically during the startup phase of the service.

In fact, in the AIMS architecture diagram, only Document must be written by the developer [3]. Other components are provided by AIMS or automatically generated by Document, so the AIMS development pattern is also known as the document-driven development pattern. Developers only need to maintain Document, so as to achieve the purpose of reducing developers' workload.

3.3. Watchman component

The Watchman component can be set to subscribe to exceptions for certain interfaces, and Exception Handler triggers the Watchman component when any exception occurs on the subscribed interface.

Because the Recorder component records that Arguments,Watchman can even automatically generate a test case that can reproduce the problem, it is convenient for developers to locate the problem.

3.4. Recorder component

Recorder is a collector that can collect all the details of each request, including request ID, request parameters, remote IP, called interface, response time, working directory, process number and so on. These data serve the following two purposes:

The maintainer of the system can use the data in Recorder to quickly locate and reproduce the existing network problems, which can be seen as a more powerful logging system.

By requesting ID, the training data collection system can associate request parameters and response data with user feedback data, which is equivalent to a marked piece of data.

3.5. Logger component

Logger is a log module encapsulated by AIMS, which is used in the same way as the logging.Logger that comes with python, minimizing the learning cost for developers.

4. Supplementary explanation

We notice that in the AIMS architecture diagram, Argument Parser, Schema Checker, Swagger UI, and OpenAPI Specification are homologous, that is, they all come from Document. This eliminates the inconsistency between the document (Swagger UI, OpenAPI Specification) and the function implementation (Argument Parser, Schema Checker). Developers also do not need to maintain Argument Parser, Schema Checker, Swagger UI and OpenAPI Specification-related code at the same time.

These are the advantages of document-driven development in the AIMS framework, which not only reduces the workload of developers, but also solves the problem of consistency. Facts have proved that the quality of automatically generated components is also better than the code developed by developers, and it is not easy to make mistakes, so as to improve the overall service quality and stability.

[1] in AIMS development, this field is written in the api_path field in _ _ doc__.

[2] in fact, the routing module forwards the request to NotFoundRequestHandler, which then responds to NotFoundRequestHandler.

[3] in the development of AI-related microservices, Function, that is, the core function, is ready.

At this point, I believe you have a deeper understanding of "how to understand the application of document-driven development patterns in AIMS". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report