Dependency bloat is a persistent challenge in Python projects, which increases maintenance costs and security risks. While numerous tools exist for detecting unused dependencies in Python, removing these dependencies across the source code and configuration files of a project requires manual effort and expertise. To tackle this challenge we introduce PYTRIM, an end-to-end system to automate this process. PYTRIM eliminates unused imports and package declarations across a variety of file types, including Python source and configuration files such as requirements.txt and setup.py. PYTRIM's modular design makes it agnostic to the source of dependency bloat information, enabling integration with any detection tool. Beyond its contribution when it comes to automation, PYTRIM also incorporates a novel dynamic analysis component that improves dependency detection recall. Our evaluation of PYTRIM's end-to-end effectiveness on a ground-truth dataset of 37 merged pull requests from prior work, shows that PYTRIM achieves 98.3% accuracy in replicating human-made changes. To show its practical impact, we run PYTRIM on 971 open-source packages, identifying and trimming bloated dependencies in 39 of them. For each case, we submit a corresponding pull request, 6 of which have already been accepted and merged. PYTRIM is available as an open-source project, encouraging community contributions and further development. Video demonstration: https://youtu.be/LqTEdOUbJRI Code repository: https://github.com/TrimTeam/PyTrim


翻译:依赖膨胀是Python项目中长期存在的挑战,它会增加维护成本和安全风险。尽管已有多种工具可用于检测Python中未使用的依赖项,但在项目的源代码和配置文件中移除这些依赖项仍需人工操作和专业经验。为应对这一挑战,我们引入了PYTRIM——一个实现该过程自动化的端到端系统。PYTRIM能在多种文件类型(包括Python源文件及requirements.txt、setup.py等配置文件)中自动删除未使用的导入语句和包声明。其模块化设计使其不依赖于特定的依赖膨胀检测工具,可与任意检测工具集成。除自动化功能外,PYTRIM还包含一种新颖的动态分析组件,能提升依赖检测的召回率。我们在包含37个历史合并拉取请求的真实数据集上评估了PYTRIM的端到端效能,结果显示PYTRIM在复现人工修改方面达到98.3%的准确率。为展示其实用价值,我们对971个开源软件包运行PYTRIM,成功在39个软件包中识别并清理了冗余依赖。针对每个案例我们都提交了相应拉取请求,其中已有6个被接受并合并。PYTRIM已作为开源项目发布,以促进社区贡献和持续发展。视频演示:https://youtu.be/LqTEdOUbJRI 代码仓库:https://github.com/TrimTeam/PyTrim

0
下载
关闭预览

相关内容

【2022新书】Python DevOps,245页pdf
专知会员服务
91+阅读 · 2022年7月11日
【干货书】数值Python计算,Numerical Python,709页pdf
专知会员服务
116+阅读 · 2021年5月30日
【干货书】PyTorch 深度学习,255页pdf
专知会员服务
281+阅读 · 2021年4月3日
【干货书】Python 数据科学学习手册,548页pdf
专知会员服务
87+阅读 · 2021年3月14日
手把手教你用Python实现“坦克大战”,附详细代码!
机器学习算法与Python学习
12+阅读 · 2019年6月8日
一个牛逼的 Python 调试工具
机器学习算法与Python学习
15+阅读 · 2019年4月30日
Pupy – 全平台远程控制工具
黑白之道
43+阅读 · 2019年4月26日
快速上手笔记,PyTorch模型训练实用教程(附代码)
从基础概念到实现,小白如何快速入门PyTorch
机器之心
13+阅读 · 2018年2月26日
大家好,这是香港科技大学PyTorch四日速成教程
机械鸡
110+阅读 · 2017年10月8日
干货| PyTorch相比TensorFlow,存在哪些自身优势?
全球人工智能
15+阅读 · 2017年10月4日
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
31+阅读 · 2015年12月31日
国家自然科学基金
12+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Arxiv
0+阅读 · 3月10日
VIP会员
最新内容
《新兴技术武器化及其对全球风险的影响》
专知会员服务
8+阅读 · 4月29日
《帕兰泰尔平台介绍:信息分析平台》
专知会员服务
20+阅读 · 4月29日
智能体化世界建模:基础、能力、规律及展望
专知会员服务
11+阅读 · 4月28日
相关资讯
手把手教你用Python实现“坦克大战”,附详细代码!
机器学习算法与Python学习
12+阅读 · 2019年6月8日
一个牛逼的 Python 调试工具
机器学习算法与Python学习
15+阅读 · 2019年4月30日
Pupy – 全平台远程控制工具
黑白之道
43+阅读 · 2019年4月26日
快速上手笔记,PyTorch模型训练实用教程(附代码)
从基础概念到实现,小白如何快速入门PyTorch
机器之心
13+阅读 · 2018年2月26日
大家好,这是香港科技大学PyTorch四日速成教程
机械鸡
110+阅读 · 2017年10月8日
干货| PyTorch相比TensorFlow,存在哪些自身优势?
全球人工智能
15+阅读 · 2017年10月4日
相关基金
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
31+阅读 · 2015年12月31日
国家自然科学基金
12+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员