Library migration is the process of replacing a library with a similar one in a software project. Manual library migration is time consuming and error prone, as it requires developers to understand the Application Programming Interfaces (API) of both libraries, map equivalent APIs, and perform the necessary code transformations. Due to the difficulty of the library migration process, most of the existing automated techniques and tooling stop at the API mapping stage or support a limited set of libraries and code transformations. In this paper, we develop an end-to-end solution that can automatically migrate code between any arbitrary pair of Python libraries that provide similar functionality. Due to the promising capabilities of Large Language Models (LLMs) in code generation and transformation, we use LLMs as the primary engine for migration. Before building the tool, we first study the capabilities of LLMs for library migration on a benchmark of 321 real-world library migrations. We find that LLMs can effectively perform library migration, but some post-processing steps can further improve the performance. Based on this, we develop MigrateLib, a command line application that combines the power of LLMs, static analysis, and dynamic analysis to provide accurate library migration. We evaluate MigrateLib on 717 real-world Python applications that are not from our benchmark. We find that MigrateLib can migrate 32% of the migrations with complete correctness. Of the remaining migrations, only 14% of the migration-related changes are left for developers to fix for more than half of the projects.


翻译:库迁移是指在软件项目中用功能相似的库替换原有库的过程。手动库迁移耗时且易出错,因为它要求开发者理解两个库的应用程序接口(API),映射等效API,并执行必要的代码转换。由于库迁移过程的复杂性,现有自动化技术与工具大多止步于API映射阶段,或仅支持有限的库集合与代码转换类型。本文开发了一种端到端解决方案,能够自动在任何提供相似功能的Python库对之间进行代码迁移。鉴于大语言模型(LLMs)在代码生成与转换方面展现出的潜力,我们采用LLMs作为迁移的核心引擎。在构建工具之前,我们首先基于包含321个真实世界库迁移任务的基准集,研究了LLMs执行库迁移的能力。研究发现,LLMs能够有效执行库迁移,但某些后处理步骤可进一步提升其性能。基于此,我们开发了MigrateLib——一个结合了LLMs、静态分析与动态分析能力的命令行应用程序,以提供精确的库迁移服务。我们在717个未包含于基准集的真实世界Python应用程序上评估了MigrateLib。结果表明,MigrateLib能够以完全正确的方式完成32%的迁移任务。在剩余的迁移案例中,对于超过半数的项目,仅需开发者修正14%与迁移相关的变更。

0
下载
关闭预览

相关内容

【AAAI2023】图上的非独立同分布迁移学习
专知会员服务
24+阅读 · 2022年12月25日
最新最全最详细中文版-《迁移学习简明手册》pdf分享
专知会员服务
102+阅读 · 2020年9月25日
《迁移学习简明手册》,93页pdf
专知会员服务
137+阅读 · 2019年12月9日
百闻不如一码!手把手教你用Python搭一个Transformer
大数据文摘
18+阅读 · 2019年4月22日
迁移自适应学习最新综述,附21页论文下载
【免费下载】迁移学习简明手册
新智元
21+阅读 · 2018年4月13日
迁移学习在深度学习中的应用
专知
24+阅读 · 2017年12月24日
独家 | 一文读懂迁移学习(附学习工具包)
数据派THU
13+阅读 · 2017年7月13日
国家自然科学基金
13+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
31+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
13+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
31+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员