arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.08810cs.SE
收藏

MigrateLib: 一种用于端到端Python库迁移的工具

MigrateLib: a tool for end-to-end Python library migration

University of Alberta(阿尔伯塔大学);North Dakota State University(北达科他州立大学);New York University Abu Dhabi(纽约大学阿布扎比分校)

Mohayeminul Islam, Ajay Kumar Jha, May Mahmoud, Sarah Nadi

AI总结:

MigrateLib利用大型语言模型、静态分析和动态分析,实现端到端的Python库迁移,能准确迁移32%的迁移任务。

摘要:

库迁移是将软件项目中的库替换为功能相似的库的过程。手动库迁移耗时且容易出错,因为它需要开发人员理解两个库的编程接口(API),映射等效的API,并执行必要的代码转换。由于库迁移过程的困难,现有的自动化技术和工具大多停留在API映射阶段或仅支持有限的库和代码转换。在本文中,我们开发了一个端到端的解决方案,可以自动在任意一对提供相似功能的Python库之间迁移代码。由于大型语言模型(LLMs)在代码生成和转换方面的强大能力,我们使用LLMs作为迁移的主要引擎。在构建工具之前,我们首先研究了LLMs在321个真实世界库迁移基准上的库迁移能力。我们发现LLMs可以有效进行库迁移,但一些后处理步骤可以进一步提高性能。基于此,我们开发了MigrateLib,一个命令行应用程序,结合了LLMs、静态分析和动态分析的威力,以提供准确的库迁移。我们对717个非来自我们基准的现实世界Python应用程序进行了评估。我们发现MigrateLib可以正确迁移32%的迁移。剩余的迁移中,只有14%的迁移相关更改需要开发人员修复,超过一半的项目中需要修复。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑