Year: 2024
Type: dissertation
Abstract: Software developers reuse the same libraries, frameworks, and algorithms, and they use common programming idioms and best practices. Thus, when they evolve the code, they repeat similar code changes. When one or multiple developers make the same code change in multiple locations, it becomes a code change pattern (CPAT). Manually identifying CPATs and applying them in multiple locations is time-consuming, error-prone, and overwhelms developers. Existing approaches hard-code the analysis and transformation and cannot be extended to accommodate new CPATs. The thesis of this dissertation is: it is possible to design and implement scalable and usable data-driven code change pattern (CPATs) automation techniques. Python has become increasingly popular among developers due to the widespread adoption of data science and machine learning (ML). Despite the popularity of Python systems and its status as the lingua franca for ML development, the community lacks a comprehensive understanding of common CPATs in these systems, leading to missed opportunities for automation. We concentrate on developing techniques and applying them to understand and automate CPATs in a broad corpus of Python ML systems to assist ML developers in keeping up with rapidly evolving ML technologies. Thus, some of the CPATs discussed are unique to ML, while others are best practices that are common across other domains. However, the techniques discussed in this dissertation are applicable to a broader range of languages and applications beyond Python and ML. To develop a framework for automating CPATs, we first started with a formative, large-scale empirical study of 3000 Python-ML systems and 109 developers. Triangulating the results of static program analysis on repositories, surveys, and thematic analysis, we discovered the challenges of evolving and maintaining Python-based ML systems. Grounded on these results, we developed, a data-driven framework for mining, recommending, and automating frequent CPATs. The framework is made up of three components: (i) R-CPATMiner, which effectively discovers CPATs in the version history of Python systems in a refactoring-aware manner, (ii) PyEvolve, which identifies and applies discovered CPATs to source code locations, and (iii) PyCraft, which expands the number of locations where CPATs can be applied. We released rich datasets that have empirically justified, actionable implications for researchers, tool builders, library designers, ML developers, and educators. Our cross-validation results showed that the tool achieved a precision of 97% and a recall of 94% over 40,000 transformation trials performed. The evaluation of our tool received overwhelmingly positive feedback from the development community, with 88% (235 out of 267) of the CPAT instances submitted as pull requests accepted across major projects like Keras, PyTorch, and TensorFlow. A survey of professional developers confirmed the tool’s usefulness, highlighting its ability to identify code optimizations that even experts missed.
Author: Malwala Arachchige, Malinda Dilhara
Language: English
Subfield: Information Systems
Field: Computer Science
Domain: Physical Sciences
Open Access status: green
OpenAlex ID: W7113363386
