A federated learning local data service encapsulation method and device
By encapsulating databases, file sharing, APIs, and command lines into a unified service interface, the problem of repetitive development in existing technologies is solved, and efficient automation and full lifecycle management of local data access for federated learning are achieved, improving system scalability and ease of maintenance.
Patent Information
- Application Number
- CN202611002590.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-07
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies cannot realize the shift from developing for each access type individually to developing for a unified service type, resulting in high repetitive development costs and slow response to business needs, which seriously restricts the large-scale promotion of federated learning.
The four heterogeneous data source access methods—database, file sharing, API, and command line—are encapsulated into corresponding encapsulation modules, and standardized operations are provided through a unified service interface to decouple the access layer from the processing layer. The metaprogramming concept is used to build a pre-built automatic adapter and four encapsulation modules, automatically generate deployable service code, and establish a full lifecycle management process.
It significantly improves the development efficiency and code reusability of local data access in federated learning, reduces the complexity of system expansion and maintenance costs, and realizes automated service-oriented encapsulation and full lifecycle management of data access.
Smart Images

Figure CN123178113A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method and apparatus for encapsulating local data services in federated learning. Background Technology
[0002] Federated learning raw data must not leave the local machine; each training node must independently complete data access and preprocessing, and cannot be processed uniformly by a central server. In existing technologies, enterprise-developed point-to-point access solutions require separate access programs for heterogeneous data sources such as databases, files, APIs, and command lines. The access logic and data processing logic are tightly coupled, resulting in extremely low code reusability and an inability to handle the expansion needs of new data source types. While solutions based on general data integration tools like Apache NiFi support multi-source access, they are designed for broad integration scenarios and cannot adapt to the special constraints of federated learning, such as data not leaving the local domain and incremental preparation on demand. The efficiency and maintainability of local data preparation remain limited by manual configuration and script development.
[0003] Therefore, existing technologies cannot realize the transformation from developing for each access type individually to developing for a unified service type, resulting in high repetitive development costs and slow response to business needs, which seriously restricts the large-scale promotion of federated learning. Summary of the Invention
[0004] This invention provides a method and apparatus for encapsulating local data services in federated learning. This method can significantly improve the development efficiency and code reusability of local data access for federated learning training nodes, enhance the system's scalability and maintenance convenience in heterogeneous data environments, and realize automated service encapsulation and full lifecycle management of data access.
[0005] Firstly, a method for encapsulating local data services in federated learning is provided, including: Obtain connection configuration information for heterogeneous data sources, including databases, file shares, APIs, and command lines; Based on the connection configuration information, the access methods of database, file sharing, API and command line are encapsulated into corresponding encapsulation modules, and service interfaces are provided to the outside world through the encapsulation modules; the service interfaces are used to convert the operation semantics of each access method into standardized operations; The system receives data access requests through a service interface, determines the target access method based on the content of the data access request, and routes the request to the corresponding encapsulation module for processing. The encapsulation module is used to perform protocol conversion between standardized operations and the native operations of the corresponding access method. The processing results of the encapsulated module are returned to the local data processing program of the federated learning training node through the service interface.
[0006] In this way, by encapsulating the four heterogeneous data source access methods—database, file sharing, API, and command line—into corresponding encapsulation modules and providing a unified service interface, the operational semantics of each access method are converted into standardized operations. The encapsulation modules perform the protocol conversion between standardized operations and native operations, so that the upper-layer data processing program does not need to care about the specific type and access protocol of the underlying data source. It only needs to complete the data acquisition through the unified service interface, thereby decoupling the data access layer from the data processing layer. This overcomes the shortcomings of the existing technology, such as tight coupling between access logic and processing logic and low code reusability, and significantly improves the development efficiency and system scalability of federated learning local data access.
[0007] In some possible implementations, based on the connection configuration information, the access methods for databases, file sharing, APIs, and command lines are encapsulated into corresponding encapsulation modules, including: For database access methods, drivers for multiple databases are pre-integrated, and the differences in access protocols between different databases are shielded through a unified data access interface; For file sharing access methods, the access operations of different file sharing protocols are converted into a unified file operation semantics, and unified access to different file sharing protocols is achieved through protocol conversion; For API access, the interface address, request headers and request parameters in the connection configuration information are passed through to execute remote service calls. For command-line access, a program execution interface is encapsulated. This interface is used to receive runtime parameters and return program execution results.
[0008] In this way, by designing a unified encapsulation mechanism for each access method, the differences in access protocols of heterogeneous data sources are shielded, so that the addition of new data source types only requires configuration extension at the encapsulation layer without modifying the upper-layer processing code, which significantly reduces the complexity of system expansion and maintenance costs.
[0009] In some possible implementations, service interfaces are provided externally by encapsulating modules, including: The modules corresponding to database, file sharing, API, and command-line access methods are uniformly encapsulated into a network service interface; The data access requests received by the network service interface contain operation instructions and routing identifiers; The operation instructions must include at least one of the following types: database query instructions, file access instructions, remote service call instructions, and local program execution instructions; The route identifier is auxiliary routing information carried in the data access request, used to help determine the target access method corresponding to the operation instruction.
[0010] In this way, by uniformly encapsulating each module into a network service interface, and carrying operation instructions and routing identifiers in the data access request, all data access requests from federated learning training nodes are accessed through the same network service interface, providing a unified call entry point for the upper-layer data processing program and further strengthening the decoupling between the access layer and the processing layer.
[0011] In some possible implementations, data access requests are received through a service interface, including: The network server listens on the port and receives data access requests from the local data processing program of the federated learning training node. Parse the data access request to obtain the operation instructions and routing identifiers carried in the data access request; The operation command is used to determine the target access method, and the routing identifier is used to help confirm the target access method when there is ambiguity in the operation command.
[0012] In this way, by listening to the port on the network server and parsing the operation instructions and routing identifiers in the request, a data foundation is provided for subsequent route distribution; the routing identifier helps to confirm the target access method when there is ambiguity in the operation instructions, avoiding misrouting caused by operation instruction prefix conflicts and improving the accuracy of route judgment.
[0013] In some possible implementations, the target access method is determined based on the content of the data access request, and the request is routed to the corresponding encapsulation module for processing, including: Routing is performed based on the prefix pattern of the operation instructions in the data access request; When the operation command is a database query command, the target access method is determined to be a database access method, and the data access request is routed to the database driver encapsulation module for processing. When the operation command is a file access command, the target access method is determined to be a file sharing access method, and the data access request is routed to the file protocol conversion module for processing. When the operation command is a remote service call command, the target access method is determined to be API access method, and the data access request is routed to the protocol conversion module for processing. When the operation command is a local program execution command and meets the security verification rules, the target access method is determined to be the command line access method, and the data access request is routed to the command line execution encapsulation module for processing.
[0014] In this way, by using a routing matching mechanism based on the prefix pattern of the operation command, different types of operation commands are automatically routed to the corresponding encapsulation modules, thus realizing automatic request distribution. For the command line access method, security verification rules are added to ensure that only local program execution requests that meet the security verification are routed to the command line execution encapsulation module, thereby ensuring node security in the federated learning scenario.
[0015] Among some possible implementations, the method also includes: When the prefix of an operation command matches multiple routing rules, the routing rule corresponding to the longest matching prefix shall prevail. When the target access method cannot be uniquely determined based on the prefix of the operation instruction, the target access method is confirmed based on the auxiliary routing information carried in the data access request.
[0016] In this way, the longest prefix priority principle solves the routing conflict problem when a prefix matches multiple routing rules at the same time. Auxiliary routing information is used to assist in confirmation when the prefix cannot uniquely determine the target access method, avoiding routing ambiguity and further improving the accuracy and robustness of route matching.
[0017] In some possible implementations, the processing results of the encapsulation module are returned to the local data processing program of the federated learning training node through a service interface, including: Obtain the processing result of the data access request from the encapsulation module; The processing results are encapsulated into response data in a unified format; The response data is returned to the local data processing program of the federated learning training node through the service interface; the type of the processing result corresponds to the target access method.
[0018] In this way, by uniformly encapsulating the processing results of each encapsulation module into response data of a unified format and returning it, the local data processing program of the federated learning training node can obtain the same format response regardless of the data source accessed. The upper-layer processing logic does not need to write differentiated parsing code due to different types of underlying data sources, which further improves the code reusability.
[0019] Secondly, a local data service encapsulation device for federated learning is provided, comprising: The first processing module is used to obtain connection configuration information for heterogeneous data sources, including databases, file shares, APIs, and command lines. The second processing module is used to encapsulate the access methods of database, file sharing, API and command line into corresponding encapsulation modules according to the connection configuration information, and provide service interfaces to the outside world through the encapsulation modules; wherein, the service interface is used to convert the operation semantics of each access method into standardized operations; The third processing module is used to receive data access requests through the service interface, determine the target access method based on the content of the data access request, and route it to the corresponding encapsulation module for processing; wherein, the encapsulation module is used to perform protocol conversion between standardized operations and the native operations of the corresponding access method; The fourth processing module is used to return the processing results of the encapsulation module to the local data processing program of the federated learning training node through the service interface.
[0020] In some possible implementations, the second processing module is specifically used for: For database access methods, drivers for multiple databases are pre-integrated, and the differences in access protocols between different databases are shielded through a unified data access interface; For file sharing access methods, the access operations of different file sharing protocols are converted into a unified file operation semantics, and unified access to different file sharing protocols is achieved through protocol conversion; For API access, the interface address, request headers and request parameters in the connection configuration information are passed through to execute remote service calls. For command-line access, a program execution interface is encapsulated. This interface is used to receive runtime parameters and return program execution results.
[0021] In some possible implementations, the second processing module is specifically used for: The modules corresponding to database, file sharing, API, and command-line access methods are uniformly encapsulated into a network service interface; The data access requests received by the network service interface contain operation instructions and routing identifiers; The operation instructions must include at least one of the following types: database query instructions, file access instructions, remote service call instructions, and local program execution instructions; The route identifier is auxiliary routing information carried in the data access request, used to help determine the target access method corresponding to the operation instruction.
[0022] In some possible implementations, the third processing module is specifically used for: The network server listens on the port and receives data access requests from the local data processing program of the federated learning training node. Parse the data access request to obtain the operation instructions and routing identifiers carried in the data access request; The operation command is used to determine the target access method, and the routing identifier is used to help confirm the target access method when there is ambiguity in the operation command.
[0023] In some possible implementations, the third processing module is specifically used for: Routing is performed based on the prefix pattern of the operation instructions in the data access request; When the operation command is a database query command, the target access method is determined to be a database access method, and the data access request is routed to the database driver encapsulation module for processing. When the operation command is a file access command, the target access method is determined to be a file sharing access method, and the data access request is routed to the file protocol conversion module for processing. When the operation command is a remote service call command, the target access method is determined to be API access method, and the data access request is routed to the protocol conversion module for processing. When the operation command is a local program execution command and meets the security verification rules, the target access method is determined to be the command line access method, and the data access request is routed to the command line execution encapsulation module for processing.
[0024] In some possible implementations, the third processing module is specifically used for: When the prefix of an operation command matches multiple routing rules, the routing rule corresponding to the longest matching prefix shall prevail. When the target access method cannot be uniquely determined based on the prefix of the operation instruction, the target access method is confirmed based on the auxiliary routing information carried in the data access request.
[0025] In some possible implementations, the fourth processing module is specifically used for: Obtain the processing result of the data access request from the encapsulation module; The processing results are encapsulated into response data in a unified format; The response data is returned to the local data processing program of the federated learning training node through the service interface; the type of the processing result corresponds to the target access method.
[0026] Thirdly, an electronic device is provided, comprising: one or more processors; one or more memories; and one or more programs, wherein the one or more programs are stored in the one or more memories, and the one or more programs include instructions that, when executed by the one or more processors, cause the configured device to perform the method as described in the first aspect.
[0027] Fourthly, a computer storage medium is provided, the computer storage medium storing instructions that, when executed by a computer, cause the computer to perform the method described in the first aspect or the second aspect.
[0028] Fifthly, a computer program product is provided, the computer program product storing instructions that, when executed by a computer, cause the computer to perform the method described in the first aspect or the second aspect.
[0029] The beneficial effects of the second to fifth aspects can be referred to the introduction of the beneficial effects of the first aspect above, and will not be repeated here. Attached Figure Description
[0030] Figure 1 This is a flowchart illustrating a method for encapsulating local data services in federated learning, as provided in an embodiment of the present invention. Figure 2 This is a schematic diagram illustrating the service technology implementation principle of an embodiment of the present invention; Figure 3 This is a schematic diagram illustrating the distributed service publishing lifecycle management process according to an embodiment of the present invention; Figure 4 This is a comparative schematic diagram showing the embodiments of the present invention and conventional methods. Figure 5 This is a flowchart illustrating a method for encapsulating local data services in federated learning, as shown in an embodiment of the present invention. Figure 6 This is a schematic diagram of a federated learning local data service encapsulation apparatus that can be used to implement the method of the present invention; Figure 7 This is a schematic diagram of an electronic device provided by the present invention. Detailed Implementation
[0031] The solutions provided by the embodiments of the present invention will now be described with reference to the accompanying drawings. In the embodiments of the present invention, "multiple" refers to two or more objects, and "various kinds" refers to two or more types. Terms such as "first," "second," etc., are only used to distinguish similar objects and are not necessarily used to describe a specific order or number of objects.
[0032] Federated learning is a distributed machine learning approach that enables collaborative modeling of multi-source data by training models locally on each participating node and exchanging only model parameters, not the original data, without requiring the data to leave the local machine. In this architecture, because the original data is strictly prohibited from leaving the local machine, each training node must independently complete the access, transformation, and preprocessing of its local data; centralized collection and processing by a central server is not feasible. Therefore, the efficiency and quality of local data preparation directly determine the successful execution of the federated learning task. However, when a training node joins a federated learning task for the first time or when the task requirements change, data access and preparation must still be completed individually for each local heterogeneous data environment. Existing technologies exhibit the following significant limitations.
[0033] One related technology is a point-to-point access solution developed by the enterprise itself. Each participating party independently develops access programs based on its own data environment to achieve local data access and preprocessing. However, this method solves the problem of single-point access to a specific data source, requiring customized development for each data source type. It does not decouple the access logic from the data processing logic, and it does not establish a standardized abstract link from heterogeneous data sources to a unified service interface. Therefore, it cannot answer the scalability question of how to access the ever-increasing types of data sources in a unified manner.
[0034] The second related technology is a solution based on general data integration tools such as Apache NiFi, Airbyte, and SeaTunnel, which supports unified access and data synchronization of multiple heterogeneous data sources. However, this solution is designed for general data integration scenarios and adopts a symmetrical architecture with equal access to each data source. Each connector is configured and runs independently, lacking unified service encapsulation and automated deployment capabilities for federated learning scenarios. This makes it difficult to directly adapt to the data preparation requirements of federated training nodes under special constraints such as data not leaving the domain, incremental preparation on demand, and alignment with federated task specifications. The efficiency and maintainability of local data access are still limited by manual configuration and script development.
[0035] In summary, existing technologies have not provided a unified operational abstraction and service encapsulation for the four types of heterogeneous data sources involved in local data access for federated learning: databases, file sharing protocols, API interfaces, and command-line tools. This makes it impossible to shift from developing for each access type individually to developing a unified approach for each service type. Consequently, federated learning training nodes still need to consume a lot of resources for repetitive access development when facing diverse data environments, making it difficult to quickly respond to changes in business needs. This severely restricts the efficiency of large-scale deployment and promotion of federated learning.
[0036] To address the technical problems in existing technologies, such as the lack of a unified access abstraction for heterogeneous data sources, tight coupling between data access and processing logic, and the inability to automate the generation and full lifecycle management of data access services, this invention proposes a local data service encapsulation method for federated learning. This method standardizes and abstracts the access methods of four heterogeneous data sources—databases, files, APIs, and command lines—into a unified HTTP API service interface. It constructs a pre-built automatic adapter and a general program template for the four encapsulation modules using metaprogramming principles, automatically generating deployable service code based on user configuration. Furthermore, it establishes a distributed full lifecycle management process from connection definition, service generation, service publication, service registration to service delisting. This invention constructs a standardized abstract link from heterogeneous data sources to a unified service interface, achieving full decoupling and independent evolution between the access layer and the processing layer. It avoids the shortcomings of poor scalability and high maintenance costs caused by point-to-point development and tightly coupled architectures in existing solutions, realizing automated and service-oriented data access, and significantly improving the efficiency of local data preparation for federated learning and its adaptability to heterogeneous data environments.
[0037] Figure 1 A flowchart illustrating a method for encapsulating local data services in federated learning, as shown in an embodiment of the present invention, is as follows: Figure 1 As shown, the specific steps include: In step S1, the connection configuration information for heterogeneous data sources is defined.
[0038] In this embodiment of the invention, the user defines the data source connection through an interactive interface or configuration file. Four core access methods are supported: database, file sharing, API, and command line.
[0039] File sharing methods cover FTP, SMB, NFS, and HTTP-based file download scenarios.
[0040] The API approach covers any RESTful API interface based on the HTTP / HTTPS protocol. Fourth, the command-line approach covers various compiled binary executables or containerized programs, such as Java-jar, Java-cp, etc.
[0041] The specific parameters configured by the user include: access method type, IP address, port, username, password, database name, file path, API URL address, request headers, command line parameters, etc.
[0042] Connection tests are performed based on user configuration. For example, for database access, an attempt is made to establish a connection and execute test queries using the corresponding database driver; for file sharing, an attempt is made to connect and list the files in the target directory; for API access, an attempt is made to send an HTTP request and verify the response status code; for command-line access, verification is made to confirm the existence of the executable file, the validity of the signature, and whether it is on the whitelist. Taking a participating node in federated learning needing to access a local database as an example, the user selects "Database" as the access method, "Kingbase" as the specific type, and sets the IP address to 192.168.1.100, port 54321, username data_owner, password, and database name federated_db.
[0043] After the connection test passes, copy a general program template code. Sensitive credentials are not written directly to the service code, but are injected through the node's local encrypted credential Vault or environment variables, and dynamically read when the service starts, avoiding the distribution of credentials with the code package.
[0044] In step S2, the automatic adapter performs route matching and distribution based on the request content.
[0045] In this embodiment of the invention, the general program template pre-configures an automatic adapter as a unified entry point for all requests. The automatic adapter uses the longest prefix priority principle combined with explicit route identifiers for route determination. The request body must carry a service-type field as an auxiliary route identifier to avoid misrouting due to content ambiguity.
[0046] Specifically, the routing rules are as follows: Structured Query Language (SCL) requests starting with SELECT or SHOW are routed to the database processing module. FTP-like operation requests starting with DIR, GET, or LESS are routed to the file processing module. URL requests starting with http: / / or https: / / are routed to the API processing module. Other requests that conform to the command whitelist rules are routed to the command execution module. For example, suppose a federated learning training node needs to query the number of samples in a local data table, then the request body is constructed as "SELECT COUNT(*) FROM training_samples", and the service-type field in the request header or request body is marked as "database". The automatic adapter recognizes the SELECT prefix and routes it to the database processing module. Similarly, if a list of model parameter files in the local file system is needed, the request body is "DIR / data / models / " and the service-type field is marked as "file", and the automatic adapter routes it to the file processing module. If a local RESTful API is needed to obtain feature statistics, the request body is "https: / / localhost:8080 / api / stats" and the service-type field is marked as "api", and the automatic adapter routes it to the API processing module. If a locally compiled data validation program needs to be executed, and the request body is " / data / bin / validator --check integrity" and the program is on the whitelist, the automatic adapter will route it to the command execution module.
[0047] In other alternative embodiments, routing can also be performed using regular expression matching or multi-level routing rules based on configuration tables; this embodiment does not impose any restrictions on this.
[0048] In step S3, the four encapsulation modules respectively complete the protocol conversion and unified access of various data sources.
[0049] Figure 2 A schematic diagram illustrating the technical implementation principle of the service provided in the embodiments of the present invention. (See diagram below.) Figure 2 As shown, the architecture consists of three parts: the interface layer, the adaptation and encapsulation layer, and the data source layer. The adaptation and encapsulation layer includes an automatic adapter, a database driver encapsulation module, a file protocol conversion module, an HTTP protocol conversion module, and a command-line execution encapsulation module.
[0050] The interface layer serves as the unified entry point for data access services, exposing standardized HTTP API interfaces. Local data processing programs on federated learning training nodes initiate data access requests through this interface. The request body contains operation instructions and their parameters, as well as a service-type field used to assist in route determination.
[0051] The adapter and encapsulation layer is deployed between the interface layer and the data source layer, including the automatic adapter and the four encapsulation modules connected to it.
[0052] The automatic adapter, as the core component of request routing, connects to the interface layer at its input and to the database driver encapsulation module, file protocol conversion module, HTTP protocol conversion module, and command-line execution encapsulation module at its output. The automatic adapter performs route matching based on the prefix pattern of the request content, following the longest prefix priority principle, and combines the service-type field in the request body as an auxiliary routing identifier to route the request to the corresponding encapsulation module.
[0053] The database driver encapsulation module pre-integrates drivers for multiple databases, providing unified Driver, Connection, Statement, and ResultSet interfaces. The module's input connects to the automatic adapter, and its output connects to the database in the data source layer. This module executes Structured Query Language (SCL) requests that begin with SELECT or SHOW, returning the results via a ResultSet.
[0054] The file protocol conversion module's input is connected to the automatic adapter, and its output is connected to the file system in the data source layer. This module is used to convert file sharing protocols such as SMB and NFS into FTP-like operations, including DIR directory listing operations, GET file download operations, and LESS text content viewing operations. The module also maps the semantics of FTP-like operations to HTTP request construction rules to enable file access based on the HTTP protocol.
[0055] The HTTP protocol conversion module connects to the automatic adapter at its input and to the HTTP API service in the data source layer at its output. This module is used to pass through the URL, request headers, and parameters in requests starting with http: / / or https: / / , execute the HTTP call, and return the response body as the service result.
[0056] The command-line execution encapsulation module connects to the automatic adapter at its input and to a local executable or containerized program in the data source layer at its output. This module encapsulates system call interfaces, receives runtime parameters, and returns standard output and standard error output. Internally, the command-line execution encapsulation module is configured with a whitelist and digital signature verification mechanism, allowing only pre-installed executables on the node that have been reviewed and signed by the platform administrator, and prohibiting the direct execution of interpreted scripts.
[0057] The data source layer is located at the bottom of the architecture and includes four types of data sources: database, file system, HTTP API service, and local executable program. These data sources are connected to the four corresponding encapsulation modules in the adaptation and encapsulation layer.
[0058] Figure 2 In the diagram, the connection line between the automatic adapter and the database driver encapsulation module is a solid line, while the connection line between the automatic adapter and the file protocol conversion module, the HTTP protocol conversion module, and the command-line execution encapsulation module is a dashed line. Solid and dashed lines distinguish the actual path of the current request route from the unsuccessful candidate path, indicating that a single data access service instance can simultaneously support any number of the four access methods, but a single request can only be routed to one of the encapsulation modules for processing in a single access session.
[0059] In this embodiment of the invention, a database driver encapsulation module is pre-built into the general program template. This module pre-integrates and encapsulates JDBC / ODBC-like drivers for mainstream databases, providing unified Driver, Connection, Statement, and ResultSet interfaces. Driver specifies the driver class for a particular database. Connection connects to the specified database using the user-defined IP address, port, username, and password. Statement is used to execute SQL statements, allowing only SELECT and SHOW operations, and prohibiting data modification or structure alteration operations such as INSERT, UPDATE, DELETE, and DROP to ensure data security in federated learning scenarios. ResultSet is the dataset returned by the SQL execution, serving as the return result of the entire service.
[0060] For example, for the database connection configured by the user in step S1, the database driver encapsulation module loads Kingbase's JDBC driver, establishes a connection to 192.168.1.100:54321 / federated_db, executes the "SELECT COUNT(*) FROM training_samples" statement, and returns the query results through ResultSet, which are then encapsulated into a unified JSON format for output.
[0061] In this embodiment of the invention, a file protocol conversion module is pre-built into the general program template. This module implements two types of protocol conversion: The first type is converting file sharing protocols such as SMB and NFS into FTP-like operations. Both SMB and NFS have directory browsing and file reading functions, and the core of the conversion is the mapping of operation semantics. The interface layer adopts the three types of FTP operations, and the file protocol conversion module converts these FTP operations into corresponding operations of the SMB or NFS protocol, and then encapsulates the results into a unified FTP-like operation return format. The second type is protocol conversion based on HTTP file download scenarios. The difference from SMB and NFS is that the semantics of FTP-like operations are mapped to HTTP request URL construction rules. For example, "GET / data / file1.csv" is mapped to an HTTP GET request of "http: / / fileserver / data / file1.csv", and the HTTP response body is returned as the service result. For example, if a user needs to retrieve a configuration file located in an NFS shared directory, the request body is "DIR / nfs / shared / configs / " and the service-type is "file". The file protocol conversion module maps this DIR operation to an NFS protocol directory listing operation, reads the file list in the directory, and then encapsulates it into the output format of an FTP-type DIR command and returns it.
[0062] In this embodiment of the invention, the general program template also includes a pre-built HTTP protocol conversion module. For requests starting with http: / / or https: / / , this module transmits the original API URL, request headers, and parameters, executes the HTTP call, and returns the response body in JSON format as the service result. For example, if the request body is "https: / / api.monitor.com / health?format=json" and the service-type is "api", the HTTP protocol conversion module directly initiates an HTTPS request to that URL, carrying the request headers and parameters from the original request, and returns the returned JSON response body as the service result.
[0063] In this embodiment of the invention, the general program template also includes a pre-built command execution encapsulation module. This module encapsulates the system call interface, receives runtime parameters, and returns the standard output and standard error output of the program execution. To ensure node security in federated learning scenarios, this module introduces a whitelist mechanism and signature verification: only executable programs pre-installed on the node and signed by the platform administrator are allowed to execute. Direct execution of interpreted scripts is prohibited; only calls to compiled binary files or containerized programs are supported to prevent injection attacks. The command execution encapsulation module also supports parameter validation, checking the format and value range of user-provided runtime parameters. For example, if a user requests to execute " / data / bin / validator --check integrity", the command execution encapsulation module first verifies whether the program is in the whitelist, then verifies whether the program's digital signature is valid. After successful verification, the program is executed by calling the module, and the validation result returned in the standard output and the warning information in the standard error are returned as the unified result of the entire service.
[0064] In step S4, the general capability component provides service governance and operational support.
[0065] In this embodiment of the invention, the general program template includes several pre-built general capability components. The HTTP Server listens on a user-configured or automatically assigned port, receives HTTP access requests, parses the request content, and calls the automatic adapter and corresponding encapsulation modules to process the requests before returning the results.
[0066] The error handling component returns standardized error codes and detailed error information for HTTP access. Error types include network failures, protocol errors, and common processing errors. For example, when a database connection fails, the error handling component returns the error code DB_CONNECTION_FAILED and a detailed description: "Connection to database failed: Connection timed out."
[0067] The traffic control component defines the maximum concurrent access count and access rate limit per unit time for a service through configuration files, preventing resource exhaustion caused by sudden surges in traffic to a single data access service. For example, the configuration file can set the maximum concurrent connections for the service to 50 and the maximum number of requests per second to 100.
[0068] The retry mechanism component defines the number of retries and exponential backoff parameters through a configuration file. When access fails due to network jitter or transient failures, it automatically retryes according to the exponential backoff strategy.
[0069] The logging component records detailed information for each HTTP call, including request time, request content, routing results, processing time, and return status, which is used by operations and maintenance personnel for troubleshooting and performance tuning.
[0070] The credential security component ensures that sensitive credentials in the connection parameters are not written to the service code. Specifically, only credential placeholders are stored in the service code; the actual credential value is dynamically read from the node's local encrypted credential Vault or environment variables when the service starts. For example, the database password is denoted as ${DB_PASSWORD} in the code, and this value is obtained from the environment variable when the service starts.
[0071] The configuration interface defines distributed environment parameters, load balancing strategies, retry mechanisms, and traffic control policies. Load balancing strategies are used to publish services to available servers within the distributed environment. For example, the configuration file can specify that servers in the same region as the data source should be prioritized for service deployment to reduce network latency.
[0072] In step S5, the distributed service release lifecycle management process is executed.
[0073] In this embodiment of the invention, the full lifecycle management of data access services is completed in five stages: connection definition, service generation, service publication, service registration, and service delisting.
[0074] Step S51, Connection Definition. As described in Step S1, the user selects the access method and its specific type through the interactive interface or configuration file, sets the connection parameters, and performs a connection test. After the test passes, a general program template code is copied, and non-sensitive connection information such as IP address, port, and database name (excluding the password) is written into the newly generated service code. For example, if the user defines the "database, Kingbase" access method, and the connection parameters are IP 192.168.1.100, port 54321, and database name federated_db, these parameters are written into the configuration section of the service code.
[0075] Step S52, Service Generation. Read the global configuration file, query the list of published services, and automatically generate a non-conflicting service name and service port. The service name format is {cluster ID}{node identifier}{access method}{access type}{version number}.
[0076] For example, Cluster01_NodeA_DB_KingbaseES_v1. Node identification uses logical node IDs instead of physical IP addresses to avoid strong coupling between service names and network topology. The generated code, service names, ports, and other information are packaged into a new service file and stored in the node's local service repository.
[0077] Step S53, Service Publication. Based on the load balancing strategy, the service file is distributed to an available server, and the service process is started via remote call. Upon service startup, the credential security component reads sensitive credentials from the node's local Vault and injects them into the service runtime environment. For example, the Cluster01_NodeA_DB_KingbaseES_v1 service file is distributed to server 192.168.1.50, the startup command is executed remotely, and the service listens on an assigned port, such as 38080, after startup.
[0078] Step S54, Service Registration. After the service starts successfully, its service name, IP address, port, and access URL are registered in the node's local registry. The registry is stored in JSON or YAML format. The local data processing program on each training node can dynamically discover and invoke the data access service by querying the registration file.
[0079] The local data processing program reads the registry. Since the Cluster01_NodeA_DB_KingbaseES_v1 service is accessible via http: / / 192.168.1.50:38080 / api / data, it directly constructs an HTTP request to invoke this service to retrieve data. This mechanism avoids reliance on a centralized registry center and conforms to the principle of autonomous federated learning nodes.
[0080] Step S55, Service Delisting. When a service becomes unavailable or requires an update, its entry is removed from the registry file. Upon detecting a change in the registry file, the background monitoring process automatically connects to the corresponding server, stops the service process, and releases the occupied port and memory resources.
[0081] For example, when the database corresponding to the Cluster01_NodeA_DB_KingbaseES_v1 service is migrated to a new server, the service is first taken offline, and a new version of the service is generated and re-released after the user redefines the connection configuration.
[0082] Figure 3 This is a schematic diagram illustrating the distributed service publishing lifecycle management process provided in an embodiment of the present invention. Figure 3 As shown, the process includes five stages: connection definition, service generation, service publication, service registration, and service delisting. Each stage is executed sequentially in chronological order, forming a complete closed-loop management system from user configuration definition to service launch and operation, and finally to service failure recovery.
[0083] First, the connection definition phase. For example... Figure 3As shown, the connection definition phase is located at the beginning of the process. This phase involves three input elements: access method, type, and connection parameters. The user selects the access method through an interactive interface or configuration file. The access methods include four types: database access, file sharing access, API access, and command-line access. The user further specifies the specific type under the selected access method; for example, under the file sharing access method, specific types include FTP, SMB, NFS, and HTTP file download. The user sets the connection parameters, which include IP address, port, username, password, database name, file path, API URL address, request headers, and command-line parameters. The system performs a connection test based on the user configuration. After the test passes, it copies the generic program template code and writes the non-sensitive connection information into the newly generated service code.
[0084] Next, the service generation phase begins. After the connection definition phase, the process enters the service generation phase, which involves two output elements: service name and port. The system reads the global configuration file, queries the list of published services, and automatically generates a non-conflicting service name and port. The service name specification is {cluster ID}{node identifier}{access method}{access type}{version number}, and the node identifier uses a logical node ID instead of a physical IP address to avoid strong coupling between the service name and the network topology. The system merges and populates the general program template code with the user configuration information, and packages the generated code along with the service name, port, and other information into a new service file.
[0085] Secondly, the service deployment phase. After the service generation phase is completed, the process enters the service deployment phase, which involves two operational elements: file transfer and service startup. The system distributes the service file generated in step S2 to an available server according to the load balancing strategy. After distribution, the system starts the service process on the target server via remote call. During service startup, sensitive credentials are dynamically read from the node's local encrypted credentials Vault or environment variables and injected into the runtime environment. The service process then begins listening on the assigned port.
[0086] Following the service deployment phase, the process enters the service registration phase, which involves one key operational element: service registration. After the service process successfully starts and completes a health check, the system registers the service name, IP address, port number, and access URL in the node's local registry. This local registry is stored in a structured file format. The local data processing program on the federated learning training node dynamically discovers and invokes data access services by querying this registry, without relying on a centralized registry center.
[0087] Finally, the service delisting phase. After the service registration phase, the process enters the service delisting phase, which involves two operational elements: stopping the service and deregistering. When a service fails or needs an update, the system first deletes the service entry from the node's local registry, triggering a registry change event. The background monitoring process listens for registry changes; upon detecting the deletion of the service entry, it automatically connects to the corresponding server, stops the service process, and releases the occupied port and memory resources, completing the service delisting.
[0088] By executing the above five stages in sequence, this invention achieves complete lifecycle management of data access services from definition, generation, publication, registration to delisting. The entire process supports distributed deployment, can automatically select servers and achieve load balancing, ensuring high availability and maintainability of local data access services for federated learning training nodes.
[0089] Figure 4 This is a comparative schematic diagram of the embodiments of the present invention and the conventional method provided for the purpose of this invention.
[0090] like Figure 4 As shown on the left, in the traditional workflow, federated learning training nodes face various heterogeneous data sources, including database servers, FTP servers, API services, and local executable programs. Training nodes need to independently develop corresponding client programs for each data source type, including database clients, FTP clients, API service callers, and command-line execution clients, and develop their own data processing logic for each.
[0091] After each client completes data access, it independently performs data processing operations. Database clients need to process the data and output it as a CSV file; FTP clients need to process the data; API service callers need to process the data; and command-line execution clients need to process the data.
[0092] The aforementioned access and processing paths are independent of each other, and each path requires separate development of access and processing code for a specific data source type, resulting in tight coupling between access and processing logic. When the number of data source types increases or business requirements change, new access and processing programs need to be developed repeatedly, leading to low code reusability, poor system scalability, and maintenance costs that increase linearly with the number of data source types.
[0093] like Figure 4As shown on the right, the four heterogeneous data sources—database server, FTP server, API service, and local executable program—do not directly interface with their respective independent clients. Instead, they are all connected to a unified service encapsulation layer. This layer standardizes and abstracts the access methods of these four heterogeneous data sources, providing a unified access interface. The local data processing program on the training node does not need to concern itself with the specific type and access protocol of the underlying data source; it only needs to use this unified interface to acquire and manipulate data.
[0094] Above the unified interface of the service encapsulation layer, all local data processing logic shares the same processing flow, providing unified processing for various heterogeneous data files, such as text files, image files, audio files, and 3D files. The decoupling between the access layer and the processing layer ensures that changes in the access method do not affect the processing code, and changes in the processing logic do not affect the access code; both can evolve independently.
[0095] pass Figure 4 A comparison of the two sides reveals a complex M×N correspondence between the M data source types and the N data processing requirements. Each new data source or processing requirement necessitates independent development, leading to exponentially increasing expansion costs. The method proposed in this invention unifies the access of the M data source types through a service encapsulation layer, decoupling them from the N data processing requirements into a linear relationship. Adding a new data source type only requires configuration extension within the service encapsulation layer, without modifying any upper-layer processing code, significantly improving system scalability and code reusability.
[0096] Figure 5 A flowchart illustrating a method for encapsulating local data services in federated learning, as shown in an embodiment of the present invention, is as follows: Figure 5 As shown, the specific steps include: 510: Obtain connection configuration information for heterogeneous data sources, including databases, file shares, APIs, and command lines.
[0097] 520: Based on the connection configuration information, the access methods of database, file sharing, API and command line are encapsulated into corresponding encapsulation modules, and service interfaces are provided to the outside world through the encapsulation modules; among them, the service interfaces are used to convert the operation semantics of each access method into standardized operations.
[0098] 530: Receive data access requests through the service interface, determine the target access method based on the content of the data access request, and route it to the corresponding encapsulation module for processing; the encapsulation module is used to perform protocol conversion between standardized operations and the native operations of the corresponding access method.
[0099] 540: Return the processing results of the encapsulation module to the local data processing program of the federated learning training node through the service interface.
[0100] In some embodiments, step 520 includes: For database access, drivers for multiple databases are pre-integrated, and the differences in access protocols between different databases are shielded through a unified data access interface. For file sharing access, access operations of different file sharing protocols are converted into unified file operation semantics, and unified access to different file sharing protocols is achieved through protocol conversion. For API access, the interface address, request header, and request parameters in the connection configuration information are transparently transmitted to execute remote service calls. For command-line access, a program execution interface is encapsulated, which is used to receive runtime parameters and return program execution results.
[0101] In some embodiments, step 520 includes: The modules corresponding to the access methods of database, file sharing, API and command line are uniformly encapsulated into a network service interface; the data access request received by the network service interface contains operation instructions and routing identifiers; the operation instructions include at least one of the following types: database query instructions, file access instructions, remote service call instructions, local program execution instructions; the routing identifier is auxiliary routing information carried in the data access request, used to help determine the target access method corresponding to the operation instruction.
[0102] In some embodiments, step 530 includes: The network server listens on the port and receives data access requests from the local data processing program of the federated learning training node; it parses the data access request and obtains the operation instructions and routing identifiers carried in the data access request; the operation instructions are used to determine the target access method, and the routing identifiers are used to help confirm the target access method when there is ambiguity in the operation instructions.
[0103] In some embodiments, step 530 includes: Routing is performed based on the prefix pattern of the operation instructions in the data access request. When the operation instruction is a database query instruction, the target access method is determined to be a database access method, and the data access request is routed to the database driver encapsulation module for processing. When the operation instruction is a file access instruction, the target access method is determined to be a file sharing access method, and the data access request is routed to the file protocol conversion module for processing. When the operation instruction is a remote service call instruction, the target access method is determined to be an API access method, and the data access request is routed to the protocol conversion module for processing. When the operation instruction is a local program execution instruction and conforms to the security verification rules, the target access method is determined to be a command line access method, and the data access request is routed to the command line execution encapsulation module for processing.
[0104] In some embodiments, step 530 includes: When the prefix of an operation command matches multiple routing rules, the routing rule corresponding to the longest matching prefix shall prevail; when the target access method cannot be uniquely determined based on the prefix of the operation command, the target access method shall be confirmed based on the auxiliary routing information carried in the data access request.
[0105] In some embodiments, step 540 includes: Obtain the processing result of the data access request from the encapsulation module; encapsulate the processing result into response data in a unified format; return the response data to the local data processing program of the federated learning training node through the service interface; wherein, the type of the processing result corresponds to the target access method.
[0106] Figure 6 This is a schematic diagram illustrating a local data service encapsulation device for federated learning, as shown in an embodiment of the present invention. Figure 6 As shown, it includes: The first processing module is used to obtain connection configuration information for heterogeneous data sources, including databases, file shares, APIs, and command lines.
[0107] The second processing module is used to encapsulate the access methods of database, file sharing, API and command line into corresponding encapsulation modules according to the connection configuration information, and provide service interfaces to the outside world through the encapsulation modules; wherein, the service interface is used to convert the operation semantics of each access method into standardized operations.
[0108] The third processing module is used to receive data access requests through the service interface, determine the target access method based on the content of the data access request, and route it to the corresponding encapsulation module for processing; wherein, the encapsulation module is used to perform protocol conversion between standardized operations and the native operations of the corresponding access method.
[0109] The fourth processing module is used to return the processing results of the encapsulation module to the local data processing program of the federated learning training node through the service interface.
[0110] Those skilled in the art will readily recognize that, based on the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein, the present invention can be implemented in hardware or a combination of hardware and computer software. Whether a function is implemented in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of the present invention.
[0111] It should be noted that, Figure 6The division of modules / units is illustrative and represents only one logical functional division; in actual implementation, other division methods are possible. For example, two or more functions can be integrated into a single data acquisition module. The integrated modules described above can be implemented either in hardware or as software functional modules.
[0112] An electronic device according to an embodiment of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements any of the above-mentioned federated learning local data service encapsulation methods. That is, an electronic device according to an embodiment of the present invention may include, but is not limited to: a processor and a memory; the memory is used to store the computer program; the processor is used to execute a federated learning local data service encapsulation method shown in any embodiment of the present invention by calling the computer program.
[0113] In one alternative embodiment, an electronic device is provided, such as Figure 7 As shown, Figure 7 The illustrated electronic device 700 includes a processor 701 and a memory 703. The processor 701 and the memory 703 are connected, for example, via a bus 702. Optionally, the electronic device 700 may further include a transceiver 704, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 704 is not limited to one type, and the structure of the electronic device 700 does not constitute a limitation on the embodiments of the present invention.
[0114] Among them, electronic devices can also be terminal devices, which can be any device that can install applications, including at least one of smartphones, tablets, laptops, desktop computers, smart speakers, smartwatches, smart TVs, and smart in-vehicle devices.
[0115] It should be noted that, Figure 7 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of the present invention.
[0116] An embodiment of the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements any of the above-described federated learning local data service encapsulation methods.
[0117] The above description is merely a preferred embodiment of the present invention and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of disclosure in this invention is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-disclosed concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this invention.
[0118] It should be noted that the terms "first," "second," etc., used in the specification and claims of this invention are used to distinguish similar objects and represent a limitation on a specific order or sequence. Where appropriate, the order of use for similar objects can be interchanged so that the embodiments of the invention described herein can be implemented in an order other than that shown or described.
[0119] Those skilled in the art will recognize that this invention can be implemented as a system, method, or computer program product. Therefore, this invention can be specifically implemented in the following forms: it can be entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software, generally referred to herein as a "circuit," "module," or "system." Furthermore, in some embodiments, this invention can also be implemented as a computer program product contained in one or more computer-readable media, which includes computer-readable program code.
[0120] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A method for encapsulating local data services in federated learning, characterized in that, include: Obtain connection configuration information for heterogeneous data sources, including databases, file shares, APIs, and command lines; Based on the connection configuration information, the access methods of database, file sharing, API, and command line are respectively encapsulated into corresponding encapsulation modules, and service interfaces are provided to the outside world through the encapsulation modules; wherein, the service interface is used to convert the operation semantics of each access method into standardized operations; The service interface receives data access requests, determines the target access method based on the content of the data access requests, and routes the data to the corresponding encapsulation module for processing. The encapsulation module is used to perform protocol conversion between the standardized operation and the native operation of the corresponding access method. The processing result of the encapsulation module is returned to the local data processing program of the federated learning training node through the service interface.
2. The method according to claim 1, characterized in that, The step of encapsulating the access methods of database, file sharing, API, and command line into corresponding encapsulation modules based on the connection configuration information includes: For the database access method, drivers for multiple databases are pre-integrated, and the differences in access protocols between different databases are shielded through a unified data access interface; For the file sharing access method, the access operations of different file sharing protocols are converted into a unified file operation semantics, and unified access to different file sharing protocols is achieved through protocol conversion; For the API access method, the interface address, request header and request parameters in the connection configuration information are passed through to execute the remote service call; For the command-line access method, a program execution interface is encapsulated, which is used to receive running parameters and return program execution results.
3. The method according to claim 1, characterized in that, The provision of service interfaces through the encapsulation module includes: The encapsulation modules corresponding to the database, file sharing, API, and command line access methods are uniformly encapsulated into a network service interface; The data access request received by the network service interface includes operation instructions and routing identifiers; The operation instructions include at least one of the following types: database query instructions, file access instructions, remote service call instructions, and local program execution instructions; The routing identifier is the auxiliary routing information carried in the data access request, which is used to help determine the target access method corresponding to the operation instruction.
4. The method according to claim 1, characterized in that, Receiving data access requests through the service interface includes: The network server listens on the port and receives data access requests from the local data processing program of the federated learning training node. Parse the data access request to obtain the operation instructions and routing identifier carried in the data access request; The operation instruction is used to determine the target access method, and the routing identifier is used to assist in confirming the target access method when there is ambiguity in the operation instruction.
5. The method according to claim 1, characterized in that, The step of determining the target access method based on the content of the data access request and routing it to the corresponding encapsulation module for processing includes: Routing is performed based on the prefix pattern of the operation instructions in the data access request; When the operation instruction is a database query instruction, the target access method is determined to be a database access method, and the data access request is routed to the database driver encapsulation module for processing; When the operation instruction is a file access instruction, the target access method is determined to be a file sharing access method, and the data access request is routed to the file protocol conversion module for processing. When the operation instruction is a remote service call instruction, the target access method is determined to be API access method, and the data access request is routed to the protocol conversion module for processing. When the operation instruction is a local program execution instruction and meets the security verification rules, the target access method is determined to be the command line access method, and the data access request is routed to the command line execution encapsulation module for processing.
6. The method according to claim 5, characterized in that, The method further includes: When the prefix of the operation instruction matches multiple routing rules simultaneously, the routing rule corresponding to the longest matching prefix shall prevail. When the target access method cannot be uniquely determined based on the prefix of the operation instruction, the target access method is confirmed based on the auxiliary routing information carried in the data access request.
7. The method according to claim 1, characterized in that, The step of returning the processing result of the encapsulation module to the local data processing program of the federated learning training node through the service interface includes: Obtain the processing result of the data access request by the encapsulation module; The processing results are encapsulated into response data in a unified format; The response data is returned to the local data processing program of the federated learning training node through the service interface; wherein the type of the processing result corresponds to the target access method.
8. A local data service encapsulation device for federated learning, characterized in that, include: The first processing module is used to obtain connection configuration information of heterogeneous data sources, including databases, file shares, APIs, and command lines; The second processing module is used to encapsulate the access methods of database, file sharing, API and command line into corresponding encapsulation modules according to the connection configuration information, and provide service interfaces to the outside world through the encapsulation modules; wherein, the service interface is used to convert the operation semantics of each access method into standardized operations; The third processing module is used to receive data access requests through the service interface, determine the target access method based on the content of the data access request, and route it to the corresponding encapsulation module for processing; wherein, the encapsulation module is used to perform protocol conversion between the standardized operation and the native operation of the corresponding access method; The fourth processing module is used to return the processing results of the encapsulation module to the local data processing program of the federated learning training node through the service interface.
9. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the federated learning local data service encapsulation method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one computer program, which is loaded and executed by a processor to enable the computer to implement the federated learning local data service encapsulation method as described in any one of claims 1 to 7.
