一句话:提出数据流/控制流感知的变换规则推断引擎,自动挖掘、推断并移植 Python ML 系统中的频繁代码变更。
由于软件的自然性和机器学习技术快速演进,Python ML 系统中频繁出现重复代码变更模式(CPAT),从简单 API 迁移到涉及 for 循环等复杂控制结构。人工执行繁琐,而现有变换规则推断方法难以处理未见过的复杂 CPAT 变体,召回率低。本文提出自动化工作流:挖掘 CPAT、推断变换规则并自动移植到新目标位置,并实现工具 PYEVOLVE。其核心是数据流与控制流感知的变换规则推断引擎。在超过 40,000 个变换上的评估达到 97% 精确率和 94% 召回率;若无该引擎,70% 的代码变更无法自动化;在知名开源项目中开发者接受 90% 的 PYEVOLVE 生成 CPAT。
Because of the naturalness of software and the rapid evolution of Machine Learning (ML) techniques, frequently repeated code change patterns (CPATs) occur often. They range from simple API migrations to changes involving several complex control structures such as for loops. While manually performing CPATs is tedious, the current state-of-the-art techniques for inferring transformation rules are not advanced enough to handle unseen variants of complex CPATs, resulting in a low recall rate. In this paper we present a novel, automated workflow that mines CPATs, infers the transformation rules, and then transplants them automatically to new target sites. We designed, implemented, evaluated and released this in a tool, PYEVOLVE. At its core is a novel data-flow, control-flow aware transformation rule inference engine. Our technique allows us to advance the state-of-the-art for transformation-by-example tools; without it, 70% of the code changes that PYEVOLVE transforms would not be possible to automate. Our thorough empirical evaluation of over 40,000 transformations shows 97% precision and 94% recall. By accepting 90% of CPATs generated by PYEVOLVE in famous open-source projects, developers confirmed its changes are useful.