A library entity dependency conflict identification method for a python environment
By constructing a quadruplet graph structure and using graph neural networks to predict entity dependency conflicts in Python libraries, this approach addresses the limitations of existing tools in static analysis and the lack of dynamic behavior awareness. It achieves efficient identification and proactive early warning of implicit conflicts, thereby improving the robustness and performance of the system.
Patent Information
- Application Number
- CN202511135488.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-14
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2045-08-14
AI Technical Summary
Existing Python dependency management tools cannot effectively integrate runtime dynamic behavior, resulting in delayed conflict detection and an inability to proactively identify high-risk implicit conflicts. Furthermore, existing dynamic analysis tools suffer significant performance overhead and cannot handle the complex dependencies of large-scale projects in real time.
By monitoring function call flow, resource usage timing, and abnormal events, a call frequency matrix, resource feature sequence, and encoded anomaly set are constructed. A four-tuple graph structure is established, and graph neural networks and temporal tensors are used to predict conflict probabilities. Version numbers are optimized in conjunction with dependency conflict solutions to identify and predict library entity dependency conflicts.
It enables comprehensive identification and proactive early warning of implicit conflicts, improves the accuracy and efficiency of conflict prediction, reduces system crashes caused by dependency conflicts, and optimizes system performance and stability.
Smart Images

Figure CN120631736B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of dependency conflict recognition, and particularly relates to a library entity dependency conflict recognition method for a Python environment. BACKGROUND
[0002] In the field of software development, Python is a widely used programming language, and its dependency management problems are increasingly prominent. With the complication of the Python ecosystem, software projects often depend on multiple third-party libraries, and there may be implicit dependency problems such as version conflicts, resource competition, or API call incompatibility between these libraries. Traditional dependency management tools mainly rely on static analysis techniques to determine version compatibility by parsing the declared dependencies in the project.
[0003] The core logic of existing dependency management tools (such as pip, conda, etc.) is based on static constraint solving, focusing only on version compatibility during installation, and unable to perceive the dynamic interaction behavior at runtime. For example, two libraries may be compatible in static version declaration, but may cause functional abnormalities due to cross-library API call conflicts, resource competition, or exception events during actual runtime. Such problems are particularly prominent in large projects, but existing tools lack the ability to monitor runtime behavior, resulting in delayed conflict detection and inability to predict.
[0004] To make up for the shortcomings of static analysis, some research attempts to capture dynamic behavior through runtime monitoring. For example, techniques based on bytecode injection or interpreter hooks can record function call flows and resource occupation data. However, runtime monitoring requires deep integration with the Python interpreter, resulting in significant performance loss and difficulty in real-time processing of complex dependency relationships in large-scale projects.
[0005] Moreover, existing dynamic analysis tools are mostly post-repair, providing repair suggestions only after conflicts occur, and are unable to identify high-risk implicit conflicts prospectively. In addition, dependency graphs are constructed based only on static edge relationships based on version declarations, ignoring runtime dynamic interactions, resulting in insufficient conflict prediction accuracy.
[0006] Therefore, to solve the above problems, there is an urgent need for a method that can integrate runtime dynamic behavior, construct a time-enhanced dependency graph, and efficiently predict conflicts. SUMMARY
[0007] The application provides a library entity dependency conflict recognition method for a Python environment, which can integrate runtime dynamic behavior, construct a time-enhanced dependency graph, and efficiently predict conflicts.
[0008] The technical scheme adopted by the application is:
[0009] A library entity dependency conflict recognition method for a Python environment, comprising:
[0010] According to the monitored function call flow data, resource occupation time sequence, and exception event set, a call frequency matrix, a resource feature sequence, and an encoded exception set are obtained through preprocessing;
[0011] According to the Python library entity, a graph node is set, a directed edge is established according to the dependency relationship between each Python library entity, a weight matrix is established according to the call frequency matrix, the resource feature sequence, and the encoded exception set between the corresponding graph nodes of each edge, and a time sequence tensor is obtained according to the statistical features between the corresponding graph nodes of each edge, to obtain a four-tuple graph structure;
[0012] According to the embedding vector of each edge corresponding graph node, the neighborhood aggregation is adjusted through the edge feature vector, and the conflict probability is obtained by combining the time sequence tensor, to obtain the Python library entity of the dependency conflict.
[0013] The library entity dependency conflict recognition method for Python environment disclosed in the application also has the following additional technical features:
[0014] According to the Python library entity, a graph node is set, and specifically:
[0015] The graph node at least includes a library name, a version number, and environment configuration information.
[0016] The resource occupation time sequence is specifically:
[0017] The resource occupation time sequence at least includes any one of the real-time statistical memory occupation, central processing unit utilization, graphics processor memory occupation, and file input / output throughput.
[0018] According to the call frequency matrix, the resource feature sequence, and the encoded exception set between the corresponding graph nodes of each edge, a weight matrix is established, and specifically:
[0019] ,
[0020] Among them, i and j respectively represent the first i and the first j graph node, represent the call frequency between the graph nodes, represent the feature coefficient of resource conflict between the graph nodes, which is obtained by quantifying the synchronization of graph node resource occupation through covariance, represent the encoded exception between the graph nodes, , , respectively represent the preset adjustment parameters, represent the weight coefficient between the graph nodes obtained.
[0021] According to the embedding vectors of the corresponding graph nodes of each edge, neighborhood aggregation is performed through edge feature vector adjustment, specifically:
[0022] According to the initial embedding vectors of the graph nodes , the embedding vectors are updated through the edge feature vectors between nodes to obtain the embedding vectors through neighborhood fusion by the graph neural network,
[0023] wherein L is the number of layers of the graph neural network, and the edge feature vector is obtained through a weight matrix and a time series tensor.
[0024] The time series tensor is combined to obtain the conflict probability, specifically:
[0025] According to the time series tensor, a state vector is extracted through a long short-term memory network.
[0026] The two embedding vectors of adjacent graph nodes , and the state vector are spliced to obtain the conflict probability
[0027] .
[0028] The library entity dependency conflict identification method for the Python environment further comprises:
[0029] According to the Python library entity of the dependency conflict, the dependency conflict solution is screened in combination with the encoding exception set
[0030] According to the highest version number and the lowest version number corresponding to the conflict solution, the final version number is determined.
[0031] According to the plurality of conflict solutions of the determined version number and the Euclidean distance of the corresponding graph nodes before the solution, the solution with the smallest Euclidean distance is selected as the final solution.
[0032] After selecting the final solution, further comprising:
[0033] According to the updated Python library entity, the embedding vector is updated.
[0034] According to the cosine similarity between the updated Python library entity and the Python library entity before the update, the attention weight is set.
[0035] According to the embedding vector after the performance change parameter adjustment, the model is updated.
[0036] The application further discloses a storage medium,
[0037] The storage medium stores a computer program, which, when executed, implements the steps of the library entity dependency conflict identification method for a Python environment.
[0038] The application further discloses a processing device, comprising:
[0039] A memory for storing a computer program;
[0040] A processor for executing the computer program to implement the steps of the library entity dependency conflict identification method for a Python environment.
[0041] Thanks to the above technical solutions, the application has the following advantages:
[0042] 1. In the application, function call flow data, resource occupation time sequence and abnormal event set are monitored, and call frequency matrix, resource feature sequence and coded abnormal set are generated through preprocessing. This method can identify implicit conflicts (such as API call incompatibility and resource competition) that cannot be found by static analysis by monitoring dynamic behavior in real time. By quantifying the interaction intensity between libraries through the call frequency matrix (such as high-frequency calls that may cause resource competition), and combining the time sequence statistics of the resource feature sequence (such as memory occupation fluctuation), the identification ability of potential conflicts is significantly improved.
[0043] According to the Python library entity construction graph node and directed edge, a weight matrix is generated through the call frequency matrix, resource feature sequence and coded abnormal set, and a time sequence tensor is obtained by combining the statistical characteristics, forming a four-tuple graph structure. The weight matrix integrates the dynamic characteristics in real time, for example, the resource conflict coefficient quantifies the synchronization of resource occupation between libraries through covariance, so that the graph structure is more consistent with the real running scene. The time sequence tensor captures the dynamic evolution law by sliding window statistics, and can identify conflicts that gradually intensify over time (such as performance degradation caused by long-term resource competition).
[0044] The edge feature vector is adjusted and then aggregated in the neighborhood, and the conflict probability is calculated by combining the time sequence tensor to identify the library entities with dependency conflicts. The graph neural network (GNN) combines the node embedding vector with the edge feature vector through the neighborhood aggregation mechanism, and captures the multi-hop dependency relationship between library entities. The time sequence tensor combined with the embedding vector can distinguish between static conflicts (such as version incompatibility) and dynamic conflicts (such as runtime resource competition), thereby improving the robustness of the prediction.
[0045] The application solves the technical defects of existing Python dependency management tools in static analysis limitations, lack of dynamic behavior perception and conflict prediction lag through dynamic behavior monitoring, time sequence enhanced dependency graph modeling and graph neural network conflict prediction, and realizes comprehensive identification and forward-looking early warning of implicit conflicts. Attached Figure Description
[0046] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings:
[0047] Figure 1 This is a flowchart illustrating the library entity dependency conflict identification method for a Python environment according to one embodiment of the present invention. Detailed Implementation
[0048] To more clearly illustrate the overall concept of the present invention, a detailed description will be provided below with reference to the accompanying drawings and examples.
[0049] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and therefore the scope of protection of the invention is not limited to the specific embodiments disclosed below.
[0050] like Figure 1 As shown, a method for identifying library entity dependency conflicts in a Python environment includes:
[0051] S100: Based on the function call stream data, resource usage time sequence, and abnormal event set obtained from monitoring, preprocess to obtain the call frequency matrix, resource feature sequence, and encoded anomaly set.
[0052] The core objective of this step is to construct a structured feature representation by monitoring dynamic behavioral data at runtime, providing quantifiable input for subsequent dependency conflict identification.
[0053] This step monitors the following: function call stream data, recording cross-library call chains via interpreter hooks (such as `sys.monitoring`), including microsecond-level timestamps and parameter hash values. Lightweight data collection is achieved through a low-intrusion monitoring agent (such as interpreter hooks), avoiding performance overhead caused by deep integration with the Python interpreter. Resource usage time-series data is collected at fixed sampling periods, including metrics such as memory usage, CPU utilization, GPU memory usage, and I / O throughput, forming a dynamic sequence with timestamps. An exception event set is also monitored, predefined with conflict-related exception types (such as resource contention and API call incompatibility), recording the exception type, timestamp, and call stack signature when an exception is triggered.
[0054] It should be noted that the pre-processing performed includes data cleaning and standardization. Abnormal cleaning is used to filter noise data generated during monitoring (such as internal calls of the agent module). Time window alignment is used to aggregate discrete events according to a fixed time window (such as 500ms) to generate window statistical features (such as resource occupation mean, variance).
[0055] Based on the monitoring data, the inter-library call frequency per unit time is counted, and the matrix element quantitatively represents the call intensity (such as the number of calls from library A to library B per time window), and a call frequency matrix is obtained. The frequency domain feature vector of resource occupation is extracted by sliding window Fourier transform to capture periodic fluctuation patterns and obtain a resource feature sequence. The abnormal events are converted into binary feature vectors by One-Hot encoding, marking the conflict points in the call chain, and obtaining an encoded abnormal set.
[0056] This step generates a dynamic behavior feature tensor containing the call frequency matrix, resource feature sequence and encoded abnormal set, which is used as input for downstream dependency modeling, significantly improving the comprehensiveness of conflict detection, multi-dimensional feature fusion, and the robustness of conflict modeling., laying the foundation for proactive conflict prediction (such as resource deadlock, performance degradation).
[0057] This step realizes the paradigm shift from "static dependency analysis" to "dynamic conflict prediction" through runtime monitoring and structured feature extraction, multi-dimensional feature modeling, dynamic behavior perception, and provides a high-quality data foundation for subsequent dependency conflict identification.
[0058] S200: Set a graph node according to each Python library entity, establish a directed edge according to the dependency relationship between each Python library entity, establish a weight matrix according to the call frequency matrix, resource feature sequence and encoded abnormal set between the corresponding graph nodes of each edge, and obtain a time series tensor according to the statistical features between the corresponding graph nodes of each edge. To get a four-tuple graph structure.
[0059] The core purpose of this step is to deeply integrate runtime dynamic behavior data and static dependency declaration by constructing a four-tuple graph structure, and to provide a structured modeling foundation for subsequent dependency conflict prediction.
[0060] Each Python library entity is a graph node, and its metadata includes library name, precise version number and environment configuration information (such as operating system, Python interpreter version). When the node is initialized, the dependency relationship explicitly declared in the project is inherited.
[0061] According to the function call flow data obtained by monitoring, a directed edge is constructed (such as library A calling library B, then the edge direction is A→B). The edge not only represents the static dependency relationship, but also quantifies the interaction intensity (such as call frequency) through runtime data.
[0062] According to the call frequency matrix between the corresponding edges of the graph nodes, the resource feature sequence and the encoding exception set, the dependency relationship between adjacent graph nodes is quantified, and a weight matrix is constructed. This step constructs a weight matrix through dynamic behavior data, which significantly improves the accuracy of conflict modeling.
[0063] The sliding window is applied to the resource feature sequence (such as memory occupancy, CPU utilization), and the time series statistical features (such as mean, variance, periodic fluctuation) are calculated. The frequency domain feature vector of resource occupation is extracted through sliding window Fourier transform to capture long-term dependence mode. This step captures dynamic evolution mode through time series tensor, provides time series feature input for conflict prediction, and realizes the identification of untriggered implicit conflicts.
[0064] In this way, a four-tuple graph structure is constructed The node set represents the Python library entity and its metadata; the edge set represents the directed edge representing the dependency relationship; the weight matrix W quantifies the interaction intensity; and the time series tensor T captures the dynamic evolution mode.
[0065] S300: According to the embedding vectors of the corresponding graph nodes of each edge, the neighborhood aggregation is performed after adjusting the edge feature vector, and the time series tensor is combined to obtain the conflict probability, so as to obtain the Python library entity of the dependency conflict.
[0066] The core purpose of this step is to use the fusion architecture of graph neural network (GNN) and time series analysis to calculate the conflict probability between nodes based on dynamic behavior data (call frequency, resource competition, abnormal event) and time series evolution mode, so as to accurately identify the Python library entity of the dependency conflict.
[0067] Each graph node (Python library entity) generates an initial embedding vector based on its metadata (library name, version number, environment configuration), and encodes the static attributes through a pre-trained model (such as Word2Vec or BERT). Through the neighborhood aggregation mechanism of GNN, the node embedding is updated combined with the edge feature vector. The long short-term memory network (LSTM) is applied to the time series tensor T to extract the dynamic state vector, which is used to capture the long-term dependence mode of resource occupation (such as memory leak trend).
[0068] The node embedding is updated through the edge feature vector to identify high-risk dependency relationships (such as library pairs with resource competition coefficients close to the threshold) in advance, reducing system crashes caused by dependency conflicts.
[0069] The embedding vectors of adjacent graph nodes and the time series state vector are spliced and input into MLP, and the conflict probability P is output. This step captures the dynamic evolution mode through the time series tensor, realizes the identification of untriggered implicit conflicts (such as predicting future performance bottlenecks that may be caused by resource competition).
[0070] As a preferred embodiment of the present application, the graph nodes are set according to each Python library entity, specifically:
[0071] The graph nodes at least include library name, version number, and environment configuration information.
[0072] The core purpose of the present embodiment is to build a dependency graph model containing key metadata through fine graph node definition, and to provide structured input for subsequent dynamic conflict prediction and optimization decision.
[0073] Define node metadata, library name is used to uniquely identify Python library entities (such as numpy, pandas). Consistency is ensured through standard naming conventions (such as PyPI package name).
[0074] The version number records the exact version number (such as 1.23.4), rather than relying on the version range in the declaration (such as >=1.0). Support for version compatibility analysis (such as judging compatibility between versions through semantic versioning rules). The accurate recording of version number (rather than range declaration) can directly associate the known conflicts of specific versions (such as the compatibility problem of pandas 1.5.0 and numpy 1.23.0), avoid misjudgment caused by ambiguous version, and guide version upgrade strategy.
[0075] Environment configuration information includes operating system type (such as Linux, Windows), Python interpreter version (such as 3.9.7), runtime dependent hardware architecture (such as x86_64), etc. Environment variables or system information are collected through runtime monitoring agents. The influence of environment on dependency conflicts is quantified through environment configuration information. The introduction of environment configuration information enables the model to identify implicit conflicts in specific environments (such as compatibility problems caused by syntax changes in Python 3.8), reducing online problems caused by environmental differences.
[0076] Among them, the library name and version number are parsed from the declared dependency relationship in the project configuration file (such as requirements.txt, setup.py). The actual loaded library version is dynamically verified through importlib.metadata or pkg_resources module at runtime.
[0077] Environment configuration information is obtained through system calls or interpreter API (such as sys.platform, sys.version_info). Unstructured information (such as operating system type) is standardized coded (such as Linux→L, Windows→W).
[0078] In the project loading phase, the initial nodes are generated based on the declared dependencies and the library entities actually loaded at runtime. By combining version numbers and environment configurations, duplicate nodes are avoided (e.g., numpy-1.23.4-Linux and numpy-1.23.4-Windows are considered different nodes), or considered as upgrades of nodes.
[0079] When a library version upgrade or environment configuration change is detected, the version number or environment configuration attribute of the corresponding node is automatically updated. By using version control tools (such as Git) or package managers (such as pip), dependency change events are monitored. Standardized encoding of library names, version numbers, and environment configurations provides a unified node feature representation for subsequent graph neural networks (GNNs), improving model training efficiency.
[0080] As a preferred embodiment of the present application, the resource occupation time sequence specifically includes:
[0081] The resource occupation time sequence includes at least any one of real-time statistics of memory occupation, central processing unit utilization, graphics processing unit memory occupation, and file input / output throughput.
[0082] The core purpose of the present embodiment is to provide a quantitative basis for dependency conflict recognition by constructing dynamic behavior feature data through real-time statistics of key resource occupation indicators.
[0083] Among them, the memory occupation is used to record the real-time memory allocation and release at the process or thread level. The central processing unit (CPU) utilization is quantitatively calculated by sampling the CPU core usage rate. The graphics processing unit (GPU) memory occupation is used to monitor the memory allocation peak and usage mode of GPU acceleration libraries (such as pytorch and tensorflow). The file input / output (I / O) throughput rate is used to calculate the disk read / write speed and I / O delay to capture storage resource competition.
[0084] Specifically, memory and CPU utilization quantify computing resource consumption and reveal inter-library competition (such as concurrent invocation of two CPU-intensive libraries causing performance bottlenecks). GPU memory occupation captures memory contention conflicts in GPU acceleration scenarios (such as memory allocation conflicts between pytorch and tensorflow). I / O throughput identifies storage resource bottlenecks (such as high-frequency file read / write of multiple libraries causing I / O blocking).
[0085] The present embodiment identifies high-risk dependencies (such as GPU memory contention) in advance through multi-dimensional resource occupation monitoring and dynamic feature modeling, reduces system crashes caused by resource competition, and includes GPU memory occupation, I / O throughput, and other indicators in dependency conflict detection, breaking through the single focus of traditional tools on computing resources.
[0086] As a preferred embodiment of the present application, a weight matrix is established according to the call frequency matrix between nodes corresponding to each edge, the resource feature sequence and the coding anomaly set, specifically:
[0087] ,
[0088] wherein, i and j represent the first i and the first j node, represent the call frequency between nodes, represent the feature coefficient of resource conflict between nodes, which is obtained by quantifying the synchronization of resource occupation of nodes through covariance, represent the coding anomaly between nodes, , , represent the preset adjustment parameters, represent the obtained weight coefficient between nodes.
[0089] The main purpose of the embodiment is to establish a weight matrix that can comprehensively consider various features between nodes, so as to more accurately reflect the correlation strength and importance between nodes. Specifically, the establishment of the weight matrix aims to realize comprehensive evaluation of the relationship between nodes by quantifying the call frequency, resource conflict feature and coding anomaly between nodes.
[0090] represent the call frequency between the first i node and the first j node. The number of calls of each node to other nodes is counted to form a frequency matrix. The node pair with high call frequency has a larger value, indicating that the two nodes are closely related in function or data flow.
[0091] represent the feature coefficient of resource conflict between the first i node and the first j node. It is obtained by quantifying the synchronization of resource occupation of nodes through covariance. Specifically, the synchronization of resource (such as memory, CPU, etc.) occupation of two nodes is analyzed. If the synchronization is high (i.e. the number of simultaneous resource occupation is large), the value is large, indicating that there is high conflict in resource use between the two nodes.
[0092] represent the coding anomaly between the first i node and the first j node. The abnormal situation between nodes at the coding level is detected and recorded, such as inconsistent data format, incompatible interface, etc. If There is, then is 1, otherwise 0.
[0093] The three features (call frequency, resource conflict feature, and coding exception) are linearly combined to obtain the final weight matrix . Among them, , , is a preset adjustment parameter for adjusting the relative importance of each feature in weight calculation.
[0094] The embodiment comprehensively considers the call frequency, resource conflict, and coding exception, and the weight matrix can more comprehensively and accurately reflect the actual relationship between the graph nodes, avoiding one-sidedness caused by a single indicator. The call frequency helps to optimize system performance, and the high-frequency node pair is given priority to optimize; the resource conflict feature helps to identify and alleviate resource competition and improve system stability; the coding exception helps to discover and repair potential compatibility problems in time and ensure normal operation of the system.
[0095] Therefore, the embodiment realizes comprehensive evaluation of the relationship between the graph nodes by constructing a comprehensive weight matrix, which helps to improve the performance, stability, and compatibility of the system.
[0096] As a preferred embodiment of the present application, according to the embedding vectors of the graph nodes corresponding to each edge, the neighborhood aggregation is performed after adjusting the edge feature vector, specifically:
[0097] According to the initial embedding vector of the graph node , the embedding vector is updated through the edge feature vector between nodes to obtain the embedding vector through neighborhood fusion by the graph neural network,
[0098] wherein L is the number of layers of the graph neural network, and the edge feature vector is obtained through the weight matrix and the time sequence tensor.
[0099] The core purpose of the embodiment is to dynamically update the embedding vector of the graph node by combining the edge feature vector (composed of the weight matrix and the time sequence tensor) through the neighborhood aggregation mechanism of the graph neural network (GNN), so as to capture the complex dependency relationship between nodes.
[0100] The initial embedding vector of each graph node i is generated based on its metadata (library name, version number, environment configuration) and encoded by a pre-training model (such as Word2Vec).
[0101] The edge feature vector is , wherein the weight matrix is , and the time sequence tensor is In other embodiments, which have been described in detail, will not be repeated here. By introducing edge feature vectors (weight matrices and temporal tensors), the neighborhood aggregation process can dynamically model the complex dependency relationship between nodes.
[0102] Performing neighborhood aggregation updates,
[0103] ,
[0104] where the neighborhood nodes are embedded and edge feature vectors are spliced to retain the multi-dimensional features of neighborhood interactions. The aggregation function uses methods such as average pooling, maximum pooling or LSTM to integrate neighborhood information and generate node embeddings of the current layer. Through L layer GNN iteration, the range of neighborhood information fusion is gradually expanded, so that node embeddings integrate more extensive context information.
[0105] Multi-layer neighborhood aggregation and edge feature fusion significantly enhance the expression ability of node embeddings, enabling the model to more accurately identify high-risk dependency relationships (such as conflicts caused by resource contention) and reduce system crashes caused by dependency conflicts.
[0106] Specifically, the conflict probability is obtained by combining the temporal tensor, which is specifically:
[0107] According to the temporal tensor, a state vector is extracted by a long short-term memory network;
[0108] Splice the two embedding vectors , of adjacent graph nodes and the state vector to obtain the conflict probability
[0109] .
[0110] The main purpose of this embodiment is to accurately calculate the conflict probability between nodes by combining the embedding vectors of the temporal tensor and the graph nodes.
[0111] According to the temporal tensor, a state vector is extracted by a long short-term memory network (LSTM). LSTM can capture long-term dependencies in time series data, resulting in a vector representation that reflects the current state. This state vector contains information in the time dimension, providing a temporal context for subsequent conflict probability calculations.
[0112] Splice the two embedding vectors , of adjacent graph nodes and the state vector , wherein the embedding vectors , respectively represent the feature information of the node i and the node j in the graph structure, and the state vector provides the state information in the time dimension. By splicing the three together, a feature vector that integrates spatial (graph structure) and temporal (time sequence) information can be obtained.
[0113] The spliced feature vector is input into a multi-layer perception (MLP) to obtain the conflict probability P. As a nonlinear model, the MLP can learn the complex relationship between the input features, thereby predicting the conflict probability between the nodes. The sigmoid function sigma maps the output of the MLP to the interval (0, 1) to obtain a probability value.
[0114] By combining the embedding vectors of the graph nodes and the time sequence state vectors, the embodiment can consider the information in both the spatial (graph structure) and temporal (time sequence) dimensions, making the prediction of the conflict probability more accurate and comprehensive, and achieving accurate prediction of the conflict probability between the nodes.
[0115] As a preferred embodiment of the present application, the library entity dependency conflict identification method for the Python environment further comprises:
[0116] According to the dependency conflict Python library entity, in combination with the encoding exception set, the dependency conflict resolution scheme is screened,
[0117] According to the highest version number and the lowest version number corresponding to the conflict resolution scheme, the final version number is determined.
[0118] According to the multiple conflict resolution schemes for determining the version number and the Euclidean distance of the corresponding graph node before resolution, the solution with the smallest Euclidean distance is selected as the final solution.
[0119] The core purpose of the present embodiment is to realize accurate screening and optimal selection of the dependency conflict resolution scheme through encoding exception association screening, version number constraint matching and Euclidean distance optimization.
[0120] The coding exception set ε includes typical exception types in conflict scenarios (such as ImportError, AttributeError, ResourceConflict). The current exception type of the conflict is matched with the pre-stored solution library (such as the pyproject.toml repair record of Poetry and the version constraint adjustment scheme of pip). Through natural language processing (NLP) or a rule engine, solutions directly related to the exception type are screened out (for example, if the conflict is caused by incompatible versions of requests and flask, the version constraint adjustment scheme is preferred). Through semantic matching of the coding exception set and the solution library, the relevant repair scheme is quickly located.
[0121] The version number constraint (such as "requests>=2.0,<3.0") is extracted from the solution and parsed into the maximum version number And The installed version of the current conflict library is obtained If The scheme is feasible; otherwise, the version constraint needs to be adjusted or the scheme is excluded. Combined with the semantic version rule (SemVer) and version range matching, it is ensured that the recommended version meets the compatibility requirements and avoids introducing new problems by using outdated versions.
[0122] A feature vector is constructed, and the Euclidean distance is obtained according to the embedding vector of the current node and the embedding vector of the solution after the node. The solution with the smallest Euclidean distance is selected as the final recommendation. By quantifying the similarity between the environment and the scheme, the scheme with the least impact on the current system is selected.
[0123] Specifically, after selecting the final scheme, the following steps are included:
[0124] The embedding vector is updated according to the updated Python library entity;
[0125] The attention weight is set according to the cosine similarity between the updated Python library entity and the Python library entity before the update;
[0126] The model is updated by adjusting the performance change parameter according to the updated embedding vector.
[0127] The core purpose of this embodiment is to realize the continuous adaptation of the Python library entity dependency relationship and the optimization of the model performance by dynamically updating the embedding vector, adjusting the attention weight, and optimizing the performance parameter.
[0128] The embedding vector of the affected Python library entity is recalculated according to the finally selected dependency conflict resolution scheme (such as version number adjustment and library replacement).
[0129] According to the embedding vectors of the library entity before updating and the embedding vectors of the library entity after updating, the cosine similarity is calculated. When the cosine similarity is greater than or equal to a threshold value, it is considered that the update of the library entity has a small influence on the dependency relationship; otherwise, attention needs to be paid, and a decay coefficient is set to reduce the dependence on the historical parameters and memory of the model. The attention weight adjustment based on the cosine similarity makes the model automatically focus on the node pairs that are greatly affected by the update, thereby improving the accuracy of conflict prediction.
[0130] The performance change parameters are extracted to quantify the performance change after the update, including memory occupation (Delta Memory), CPU utilization (Delta CPU), response time (Delta Latency), etc., as additional feature vectors of the model input p .
[0131] LoRA or Adapter Tuning method is adopted to update only the performance-related parameters (such as attention weights and activation function coefficients) in the model, avoiding full-parameter retraining.
[0132] ,
[0133] where Delta theta (p) is the gradient update amount based on the performance parameter p.
[0134] The application further provides a storage medium,
[0135] The storage medium has a computer program stored thereon, and the computer program is executed to realize the steps of the library entity dependency conflict identification method for the Python environment.
[0136] Therefore, any effect of the library entity dependency conflict identification method for the Python environment can be realized, which will not be repeated here.
[0137] The application further provides a processing device, comprising:
[0138] A memory is configured to store a computer program.
[0139] A processor is configured to execute the computer program to realize the steps of the library entity dependency conflict identification method for the Python environment.
[0140] Therefore, any effect of the library entity dependency conflict identification method for the Python environment can be realized, which will not be repeated here.
[0141] In the application, the unmentioned parts can be realized by using or referring to the existing technology.
[0142] The various embodiments in the specification are described in progressive manner, and the same or similar parts between the various embodiments can be mutually referred to, and each embodiment focuses on the difference from other embodiments.
[0143] The above merely describes the embodiments of the present application, and is not intended to limit the present application. The present application can be variously changed and modified by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the scope of the claims of the present application.
Claims
1. A method for identifying library entity dependency conflicts in a Python environment, characterized in that, include: Based on the function call stream data, resource usage time sequence, and abnormal event set obtained from monitoring, preprocessing is performed to obtain the call frequency matrix, resource feature sequence, and encoded abnormal set. Graph nodes are set up according to each Python library entity, directed edges are established according to the dependencies between the Python library entities, and a weight matrix is established according to the call frequency matrix, the resource feature sequence, and the encoding anomaly set between the graph nodes corresponding to each edge. , The temporal tensor is obtained based on the statistical characteristics between the corresponding graph nodes of each edge, thus yielding a quadruplet graph structure, where... i and j They represent the first i The and the first j Each graph node This indicates the frequency of calls between graph nodes. The characteristic coefficients representing resource conflicts between graph nodes are obtained by quantifying the synchronicity of resource occupancy of graph nodes through covariance. This indicates an encoding anomaly between graph nodes. If it exists, then The value is 1 if it is 1, otherwise it is 0. , , These represent the preset adjustment parameters. This represents the weight coefficients between the obtained graph nodes; Based on the embedding vectors of the graph nodes corresponding to each edge, neighborhood aggregation is performed after adjustment using the edge feature vectors. Specifically, this involves using the initial embedding vectors of the graph nodes... Through the edge feature vectors between nodes The embedding vector is updated to obtain the new embedding vector through neighborhood fusion using a graph neural network. , By combining the temporal tensor, the conflict probability is obtained to obtain the Python library entities that depend on the conflict, where L is the number of layers in the graph neural network, and the edge feature vectors are obtained through the weight matrix and the temporal tensor.
2. The library entity dependency conflict identification method for a Python environment according to claim 1, characterized in that, Graph nodes are set according to the entities in each Python library, specifically as follows: The graph nodes include at least the library name, version number, and environment configuration information.
3. The library entity dependency conflict identification method for a Python environment according to claim 1, characterized in that, The resource usage time sequence is as follows: The resource usage time series includes at least one of the following: real-time statistics of memory usage, CPU utilization, graphics processor memory usage, and file input / output throughput.
4. The library entity dependency conflict identification method for a Python environment according to claim 1, characterized in that, By combining the temporal tensors, the conflict probability is obtained, specifically: Based on the temporal tensor, a state vector is extracted using a long short-term memory network; splicing two embedding vectors of adjacent graph nodes , and state vector To obtain the conflict probability, 。 5. The library entity dependency conflict identification method for a Python environment according to claim 2, characterized in that, Also includes: Based on the Python library entities involved in dependency conflicts, and combined with the set of coding anomalies, filter for solutions to dependency conflicts. The final version number is determined based on the highest and lowest version numbers corresponding to the conflict resolution solutions. Based on the multiple conflict solutions with determined version numbers, and their Euclidean distances to the corresponding graph nodes before resolution, the solution with the smallest Euclidean distance is selected as the final solution.
6. The library entity dependency conflict identification method for a Python environment according to claim 5, characterized in that, After selecting the final solution, the following steps are also included: Update the embedding vector based on the updated Python library entities; Set attention weights based on the cosine similarity between the updated Python library entities and the unupdated Python library entities; Based on the updated embedding vector, the model is updated after adjusting the performance variation parameters.
7. A storage medium, characterized in that, The storage medium stores a computer program that, when executed, implements the steps of the library entity dependency conflict identification method for a Python environment as described in any one of claims 1 to 6.
8. A processing apparatus, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the library entity dependency conflict identification method for a Python environment as described in any one of claims 1 to 6 when executing the computer program.
Citation Information
Patent Citations
Directed graph-based code warehouse code block level conflict sorting and grouping method
CN115098109A
Python project dependency conflict detection and solution method and device
CN118550546A