PCART: 自动修复 Python API 参数兼容性问题
PCART: Automated Repair of Python API Parameter Compatibility Issues
AI总结:
PCART 是首个自动修复 Python API 参数兼容性问题的工具,通过自动化提取、仪器化、映射、评估、修复和验证,有效检测并修复多种参数变化问题。
摘要:
在现代软件开发中,Python 第三方库扮演着关键角色,尤其是在深度学习和科学计算领域。然而,这些库中的 API 参数在演变过程中经常发生变化,导致依赖特定版本的客户端应用程序出现兼容性问题。Python 灵活的参数传递机制进一步加剧了这一问题,因为不同的传递方法可能导致不同的 API 兼容性。目前,没有工具能够自动检测和修复 Python API 参数兼容性问题。为了填补这一空白,我们引入了 PCART,这是首个能够完全自动化执行 API 提取、代码仪器化、API 映射建立、兼容性评估、修复和验证过程的解决方案。PCART 能够处理各种类型的 Python API 参数兼容性问题,包括参数添加、删除、重命名、重新排序以及位置参数到关键字参数的转换。为了评估 PCART,我们构建了 PCBENCH,一个包含 47,478 个测试用例的大型基准测试集,这些测试用例是从 33 个流行 Python 库中 844 个参数变化的 API 中变异而来的。评估结果表明,PCART 既有效又高效,显著优于现有的工具(MLCatchUp 和 Relancer)以及大型语言模型 ChatGPT(GPT-4o),在检测 API 参数兼容性问题时的 F1 分数达到 96.残7%,修复精度达到 91.97%。进一步在 30 个真实的 Python 项目上进行评估,确认了 PCART 的实用性。我们相信 PCART 可以显著减少程序员在维护 Python API 更新上所花费的时间,并推进 Python API 兼容性问题修复的自动化进程。
英文摘要:
In modern software development, Python third-party libraries play a critical role, especially in fields like deep learning and scientific computing. However, API parameters in these libraries often change during evolution, leading to compatibility issues for client applications reliant on specific versions. Python's flexible parameter-passing mechanism further complicates this, as different passing methods can result in different API compatibility. Currently, no tool can automatically detect and repair Python API parameter compatibility issues. To fill this gap, we introduce PCART, the first solution to fully automate the process of API extraction, code instrumentation, API mapping establishment, compatibility assessment, repair, and validation. PCART handles various types of Python API parameter compatibility issues, including parameter addition, removal, renaming, reordering, and the conversion of positional to keyword parameters. To evaluate PCART, we construct PCBENCH, a large-scale benchmark comprising 47,478 test cases mutated from 844 parameter-changed APIs across 33 popular Python libraries. Evaluation results demonstrate that PCART is both effective and efficient, significantly outperforming existing tools (MLCatchUp and Relancer) and the large language model ChatGPT (GPT-4o), achieving an F1-score of 96.51% in detecting API parameter compatibility issues and a repair precision of 91.97%. Further evaluation on 30 real-world Python projects from GitHub confirms PCART's practicality. We believe PCART can significantly reduce the time programmers spend maintaining Python API updates and advance the automation of Python API compatibility issue repair.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。